From 1c5fa02d1d31ca00274a361a5cb60be46f3526a8 Mon Sep 17 00:00:00 2001 From: Christopher Laffey <47035210+laffeychris@users.noreply.github.com> Date: Thu, 6 Jun 2024 11:22:43 +0100 Subject: [PATCH] fix: specify embedding retriever version (#7811) --- haystack/nodes/retriever/_embedding_encoder.py | 5 ++++- pyproject.toml | 2 +- ...-sentence-transformer-model-version-55b633e8b294189c.yaml | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/specify-sentence-transformer-model-version-55b633e8b294189c.yaml diff --git a/haystack/nodes/retriever/_embedding_encoder.py b/haystack/nodes/retriever/_embedding_encoder.py index f75b997123..d05af6ee45 100644 --- a/haystack/nodes/retriever/_embedding_encoder.py +++ b/haystack/nodes/retriever/_embedding_encoder.py @@ -135,7 +135,10 @@ def __init__(self, retriever: "EmbeddingRetriever"): # e.g. 'roberta-base-nli-stsb-mean-tokens' torch_and_transformers_import.check() self.embedding_model = SentenceTransformer( - retriever.embedding_model, device=str(retriever.devices[0]), use_auth_token=retriever.use_auth_token + retriever.embedding_model, + device=str(retriever.devices[0]), + use_auth_token=retriever.use_auth_token, + revision=retriever.model_version, ) self.batch_size = retriever.batch_size self.embedding_model.max_seq_length = retriever.max_seq_len diff --git a/pyproject.toml b/pyproject.toml index 5f576ac52a..42b8acda5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,7 +87,7 @@ dependencies = [ [project.optional-dependencies] inference = [ "transformers[torch,sentencepiece]==4.39.3", - "sentence-transformers>=2.2.0", # See haystack/nodes/retriever/_embedding_encoder.py, _SentenceTransformersEmbeddingEncoder + "sentence-transformers>=2.3.1", # See haystack/nodes/retriever/_embedding_encoder.py, _SentenceTransformersEmbeddingEncoder "huggingface-hub>=0.5.0", ] elasticsearch = [ diff --git a/releasenotes/notes/specify-sentence-transformer-model-version-55b633e8b294189c.yaml b/releasenotes/notes/specify-sentence-transformer-model-version-55b633e8b294189c.yaml new file mode 100644 index 0000000000..2c43594726 --- /dev/null +++ b/releasenotes/notes/specify-sentence-transformer-model-version-55b633e8b294189c.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fix bug causing latest version of sentence transformer model always being downloaded, even if specific version + is given.