Skip to content

Commit b3b8a4f

Browse files
fix: Getting embeddings using text-embedding-005 (#12725)
1 parent 0c227d3 commit b3b8a4f

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

generative_ai/embeddings/code_retrieval_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
# [START generativeaionvertexai_embedding_code_retrieval]
1818
from vertexai.language_models import TextEmbeddingInput, TextEmbeddingModel
1919

20-
MODEL_NAME = "text-embedding-preview-0815"
20+
MODEL_NAME = "text-embedding-005"
2121
DIMENSIONALITY = 256
2222

2323

2424
def embed_text(
2525
texts: list[str] = ["Retrieve a function that adds two numbers"],
2626
task: str = "CODE_RETRIEVAL_QUERY",
27-
model_name: str = "text-embedding-preview-0815",
27+
model_name: str = "text-embedding-005",
2828
dimensionality: int | None = 256,
2929
) -> list[list[float]]:
3030
"""Embeds texts with a pre-trained, foundational model."""

generative_ai/embeddings/document_retrieval_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def embed_text() -> list[list[float]]:
3232
# The task type for embedding. Check the available tasks in the model's documentation.
3333
task = "RETRIEVAL_DOCUMENT"
3434

35-
model = TextEmbeddingModel.from_pretrained("text-embedding-004")
35+
model = TextEmbeddingModel.from_pretrained("text-embedding-005")
3636
inputs = [TextEmbeddingInput(text, task) for text in texts]
3737
kwargs = dict(output_dimensionality=dimensionality) if dimensionality else {}
3838
embeddings = model.get_embeddings(inputs, **kwargs)

generative_ai/embeddings/model_tuning_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
def tune_embedding_model(
2323
api_endpoint: str,
24-
base_model_name: str = "text-embedding-004",
24+
base_model_name: str = "text-embedding-005",
2525
corpus_path: str = "gs://cloud-samples-data/ai-platform/embedding/goog-10k-2024/r11/corpus.jsonl",
2626
queries_path: str = "gs://cloud-samples-data/ai-platform/embedding/goog-10k-2024/r11/queries.jsonl",
2727
train_label_path: str = "gs://cloud-samples-data/ai-platform/embedding/goog-10k-2024/r11/train.tsv",

0 commit comments

Comments
 (0)