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

feat: added Vertex AI multilingual embeddings and text-embedding-004 #340

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions js/plugins/vertexai/src/embedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,51 @@ export const textEmbeddingGecko001 = embedderRef({
},
});

/*
// @TODO(huangjeff): Fix multilingual text embedding gecko
// For some reason this model returns 404 but it exists in the reference docs:
// https://cloud.google.com/vertex-ai/generative-ai/docs/embeddings/get-text-embeddings
export const textEmbedding004 = embedderRef({
name: 'vertexai/text-embedding-004',
configSchema: TextEmbeddingGeckoConfigSchema,
info: {
dimensions: 768,
label: 'Vertex AI - Text Embedding 004',
supports: {
input: ['text'],
},
},
});

export const textMultilingualEmbedding002 = embedderRef({
name: 'vertexai/text-multilingual-embedding-002',
configSchema: TextEmbeddingGeckoConfigSchema,
info: {
dimensions: 768,
label: 'Vertex AI - Text Multilingual Embedding 002',
supports: {
input: ['text'],
},
},
});

export const textEmbeddingGeckoMultilingual001 = embedderRef({
name: 'vertexai/textembedding-gecko-multilingual@001',
configSchema: TextEmbeddingGeckoConfigSchema,
info: {
dimensions: 768,
label: 'Vertex AI - Multilingual Text Embedding Gecko',
label: 'Vertex AI - Multilingual Text Embedding Gecko 001',
supports: {
input: ['text'],
},
},
});
*/

export const textEmbeddingGecko = textEmbeddingGecko003;

export const SUPPORTED_EMBEDDER_MODELS: Record<string, EmbedderReference> = {
'textembedding-gecko@003': textEmbeddingGecko003,
'textembedding-gecko@002': textEmbeddingGecko002,
'textembedding-gecko@001': textEmbeddingGecko001,
//'textembeddding-gecko-multilingual@001': textEmbeddingGeckoMultilingual001,
'text-embedding-004': textEmbedding004,
'textembedding-gecko-multilingual@001': textEmbeddingGeckoMultilingual001,
'text-multilingual-embedding-002': textMultilingualEmbedding002,
};

interface EmbeddingInstance {
Expand Down
12 changes: 12 additions & 0 deletions js/plugins/vertexai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ import {
} from './anthropic.js';
import {
SUPPORTED_EMBEDDER_MODELS,
textEmbedding004,
textEmbeddingGecko,
textEmbeddingGecko001,
textEmbeddingGecko002,
textEmbeddingGecko003,
textEmbeddingGeckoEmbedder,
textEmbeddingGeckoMultilingual001,
textMultilingualEmbedding002,
} from './embedder.js';
import {
VertexAIEvaluationMetric,
Expand All @@ -54,7 +60,13 @@ export {
geminiPro,
geminiProVision,
imagen2,
textEmbedding004,
textEmbeddingGecko,
textEmbeddingGecko001,
textEmbeddingGecko002,
textEmbeddingGecko003,
textEmbeddingGeckoMultilingual001,
textMultilingualEmbedding002,
VertexAIEvaluationMetricType as VertexAIEvaluationMetricType,
};

Expand Down
Loading