Class TextEmbeddingModel (1.27.1)

TextEmbeddingModel(model_id: str, endpoint_name: typing.Optional[str] = None)

TextEmbeddingModel converts text into a vector of floating-point numbers.

Examples::

# Getting embedding:
model = TextEmbeddingModel.from_pretrained("textembedding-gecko@001")
embeddings = model.get_embeddings(["What is life?"])
for embedding in embeddings:
    vector = embedding.values
    print(len(vector))

Methods

TextEmbeddingModel

TextEmbeddingModel(model_id: str, endpoint_name: typing.Optional[str] = None)

Creates a LanguageModel.

This constructor should not be called directly. Use LanguageModel.from_pretrained(model_name=...) instead.

from_pretrained

from_pretrained(model_name: str) -> vertexai._model_garden._model_garden_models.T

Loads a _ModelGardenModel.

Exceptions
Type Description
ValueError If model_name is unknown.
ValueError If model does not support this class.