Skip to content

VertexAIEmbeddings

Reference docs

This page contains reference documentation for VertexAIEmbeddings. See the docs for conceptual guides, tutorials, and examples on using VertexAIEmbeddings.

VertexAIEmbeddings deprecated

Bases: BaseModel, Embeddings

Deprecated

Use GoogleGenerativeAIEmbeddings instead.

Google Cloud VertexAI embedding models.

METHOD DESCRIPTION
aembed_documents

Asynchronous Embed search docs.

aembed_query

Asynchronous Embed query text.

validate_environment

Validates that the python package exists in environment.

embed

Embed a list of strings.

embed_documents

Embed a list of documents.

embed_query

Embed a text.

project class-attribute instance-attribute

project: str | None = None

The default GCP project to use when making Vertex API calls.

location class-attribute instance-attribute

location: str = Field(default='us-central1')

The default location to use when making API calls.

model_name class-attribute instance-attribute

model_name: str | None = Field(default=None, alias='model')

Underlying model name.

credentials class-attribute instance-attribute

credentials: Any = Field(default=None, exclude=True)

The default custom credentials to use when making API calls.

(google.auth.credentials.Credentials)

If not provided, credentials will be ascertained from the environment.

max_retries class-attribute instance-attribute

max_retries: int = 6

The maximum number of retries to make when generating.

dimensions class-attribute instance-attribute

dimensions: int | None = None

Default output dimensionality for embeddings. If not specified, uses the model's default. Can be overridden per request in embed() method.

aembed_documents async

aembed_documents(texts: list[str]) -> list[list[float]]

Asynchronous Embed search docs.

PARAMETER DESCRIPTION
texts

List of text to embed.

TYPE: list[str]

RETURNS DESCRIPTION
list[list[float]]

List of embeddings.

aembed_query async

aembed_query(text: str) -> list[float]

Asynchronous Embed query text.

PARAMETER DESCRIPTION
text

Text to embed.

TYPE: str

RETURNS DESCRIPTION
list[float]

Embedding.

validate_environment

validate_environment() -> Self

Validates that the python package exists in environment.

embed

embed(
    texts: list[str],
    embeddings_task_type: EmbeddingTaskTypes | None = None,
    dimensions: int | None = None,
    title: str | None = None,
) -> list[list[float]]

Embed a list of strings.

PARAMETER DESCRIPTION
texts

The list of strings to embed.

TYPE: list[str]

embeddings_task_type

Optional embeddings task type, one of the following:

  • RETRIEVAL_QUERY - Text is a query in a search/retrieval setting
  • RETRIEVAL_DOCUMENT - Text is a document in a search/retrieval setting
  • SEMANTIC_SIMILARITY - Embeddings will be used for Semantic Textual Similarity (STS).
  • CLASSIFICATION - Embeddings will be used for classification.
  • CLUSTERING - Embeddings will be used for clustering.
  • CODE_RETRIEVAL_QUERY - Embeddings will be used for code retrieval for Java and Python.

The following are only supported on preview models: QUESTION_ANSWERING, FACT_VERIFICATION.

TYPE: EmbeddingTaskTypes | None DEFAULT: None

dimensions

Output embeddings dimensions.

Only supported on preview models. If not provided, uses the default dimensions specified in the constructor.

TYPE: int | None DEFAULT: None

title

Title for the text.

Only applicable when TaskType is RETRIEVAL_DOCUMENT.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
list[list[float]]

List of embeddings, one for each text.

embed_documents

embed_documents(
    texts: list[str], *, embeddings_task_type: EmbeddingTaskTypes = "RETRIEVAL_DOCUMENT"
) -> list[list[float]]

Embed a list of documents.

PARAMETER DESCRIPTION
texts

The list of texts to embed.

TYPE: list[str]

embeddings_task_type

The task type for embeddings.

TYPE: EmbeddingTaskTypes DEFAULT: 'RETRIEVAL_DOCUMENT'

RETURNS DESCRIPTION
list[list[float]]

List of embeddings, one for each text.

embed_query

embed_query(
    text: str, *, embeddings_task_type: EmbeddingTaskTypes = "RETRIEVAL_QUERY"
) -> list[float]

Embed a text.

PARAMETER DESCRIPTION
text

The text to embed.

TYPE: str

embeddings_task_type

The task type for embeddings.

TYPE: EmbeddingTaskTypes DEFAULT: 'RETRIEVAL_QUERY'

RETURNS DESCRIPTION
list[float]

Embedding for the text.