Skip to content

Commit

Permalink
Update cohere embedding models (#3704)
Browse files Browse the repository at this point in the history
  • Loading branch information
vblagoje committed Dec 16, 2022
1 parent 4afdbc3 commit 4292659
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion haystack/nodes/retriever/_embedding_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,14 @@ def __init__(self, retriever: "EmbeddingRetriever"):
self.api_key = retriever.api_key
self.batch_size = min(16, retriever.batch_size)
self.progress_bar = retriever.progress_bar
self.model: str = next((m for m in ["small", "medium", "large"] if m in retriever.embedding_model), "large")
self.model: str = next(
(
m
for m in ["small", "medium", "large", "multilingual-22-12", "finance-sentiment"]
if m in retriever.embedding_model
),
"multilingual-22-12",
)
self.tokenizer = AutoTokenizer.from_pretrained("gpt2")

def _ensure_text_limit(self, text: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion haystack/nodes/retriever/dense.py
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ def _preprocess_documents(self, docs: List[Document]) -> List[Document]:
def _infer_model_format(model_name_or_path: str, use_auth_token: Optional[Union[str, bool]]) -> str:
if any(m in model_name_or_path for m in ["ada", "babbage", "davinci", "curie"]):
return "openai"
if model_name_or_path in ["small", "medium", "large"]:
if model_name_or_path in ["small", "medium", "large", "multilingual-22-12", "finance-sentiment"]:
return "cohere"
# Check if model name is a local directory with sentence transformers config file in it
if Path(model_name_or_path).exists():
Expand Down

0 comments on commit 4292659

Please sign in to comment.