-
Notifications
You must be signed in to change notification settings - Fork 62
Closed
Description
Cohere reranker has an unnessesary dependency on sentence_transformers (as a leftover from HFCrossEncoderReranker implementation?)
!pip install -q cohere redisvl
import getpass
import os
# Set the API Key
api_key = os.environ.get("COHERE_API_KEY") or getpass.getpass("Enter your Cohere API key: ")
query = "What is the capital of the United States?"
docs = [
"Carson City is the capital city of the American state of Nevada. At the 2010 United States Census, Carson City had a population of 55,274.",
"The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean that are a political division controlled by the United States. Its capital is Saipan.",
"Charlotte Amalie is the capital and largest city of the United States Virgin Islands. It has about 20,000 people. The city is on the island of Saint Thomas.",
"Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district. The President of the USA and many major national government offices are in the territory. This makes it the political center of the United States of America.",
"Capital punishment (the death penalty) has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states. The federal government (including the United States military) also uses capital punishment."
]
from redisvl.utils.rerank import CohereReranker
cohere_reranker = CohereReranker(limit=3, api_config={"api_key": api_key})
This will trigger the error:
ModuleNotFoundError Traceback (most recent call last)
[<ipython-input-4-fb469037e79a>](https://localhost:8080/#) in <cell line: 1>()
----> 1 from redisvl.utils.rerank import CohereReranker
2
3 cohere_reranker = CohereReranker(limit=3, api_config={"api_key": api_key})
1 frames
[/usr/local/lib/python3.10/dist-packages/redisvl/utils/rerank/hf_cross_encoder.py](https://localhost:8080/#) in <module>
1 from typing import Any, Dict, List, Optional, Tuple, Union
2
----> 3 from sentence_transformers import CrossEncoder
4
5 from redisvl.utils.rerank.base import BaseReranker
ModuleNotFoundError: No module named 'sentence_transformers'
Adding sentence_transformers to pip install will fix the problem, but in the notebook will trigger a bunch of sentence-transformers - specific warnings.
Metadata
Metadata
Assignees
Labels
No labels