• Python
    • DataImport
    • EmbeddingModels
      • BGEM3EmbeddingFunction
      • BM25EmbeddingFunction
      • CohereEmbeddingFunction
      • GeminiEmbeddingFunction
      • InstructorEmbeddingFunction
      • JinaEmbeddingFunction
      • MGTEEmbeddingFunction
      • MistralAIEmbeddingFunction
      • Model2VecEmbeddingFunction
      • NomicEmbeddingFunction
      • OnnxEmbeddingFunction
      • OpenAIEmbeddingFunction
      • SentenceTransformerEmbeddingFunction
      • SpladeEmbeddingFunction
      • TEIEmbeddingFunction
      • VoyageEmbeddingFunction
    • Exceptions
    • FileResource
    • MilvusClient
    • ORM
    • Rerankers

__call__()

This operation in TEIEmbeddingFunction takes a list of text strings and directly encodes them into vector embeddings.

The __call__() method of TEIEmbeddingFunction shares the same functionality as encode_documents() and encode_queries().

Request Syntax

# Instance created

tei_ef = TEIEmbeddingFunction()

# __call__ method will be called
tei_ef(
    texts: List[str]
) -> List[np.array]

PARAMETERS:

  • texts (List[str])

    A list of string values, where each string represents text that will be passed to the embedding model for encoding. The model will generate an embedding vector for each string in the list.

RETURN TYPE:

List[np.array]

RETURNS:

A list where each element is a NumPy array.

EXCEPTIONS:

  • RuntimeError

    This exception will be raised when the response from the TEI service does not contain the data key.

EXCEPTIONS:

  • ValueError

    This exception will be raised when an unsupported operation is attempted on the embedding object.

Example

from pymilvus.model.dense import TEIEmbeddingFunction

tei_ef = TEIEmbeddingFunction(
    api_url="http://localhost:8080", # Replace with the URL of your TEI service
)

docs = [
    "Artificial intelligence was founded as an academic discipline in 1956.",
    "Alan Turing was the first person to conduct substantial research in AI.",
    "Born in Maida Vale, London, Turing was raised in southern England.",
]

tei_ef(docs)

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?