Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for taskType and autoTruncate parameters for VertexAI Embeddings Model #5327

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

abir-taheer
Copy link

@abir-taheer abir-taheer commented Mar 22, 2025

Please review official Vertex AI Docs Here:

https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/text-embeddings-api

More specifically it lists a taskType parameter:

Used to convey intended downstream application to help the model produce better embeddings. If left blank, the default used is RETRIEVAL_QUERY.

As well as an autoTruncate parameter:

When set to true, input text will be truncated. When set to false, an error is returned if the input text is longer than the maximum length supported by the model. Defaults to true.

Currently these are inaccessible via the Vercel AI SDK so I've added them to the settings and updated the implementation of the embedding model for Vertex-AI to be able to pass in these parameters.

Before:

const model = vertex.textEmbeddingModel('text-embedding-004', {
  outputDimensionality: 512, // optional, number of dimensions for the embedding
});

After:

const model = vertex.textEmbeddingModel('text-embedding-004', {
  outputDimensionality: 512, // optional, number of dimensions for the embedding
  taskType: 'RETRIEVAL_DOCUMENT', // optional, task type for which embeddings will be used
  autoTruncate: true, // optional, whether to auto-truncate text exceeding token limit
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant