CohereRerankFunction
CohereRerankFunction 是 milvus_model 中的一个类,它将 query 和 document 作为输入,并直接返回相似度分数而不是 embeddings。此功能使用底层的 Cohere 重排模型。
python
pymilvus.model.reranker.CohereRerankFunction
构造函数
为常见用例构造一个 CohereRerankFunction。
python
CohereRerankFunction(
model_name: str = "rerank-english-v2.0",
api_key: Optional[str] = None
)
参数:
-
model_name (string)
要使用的模型名称。您可以指定任何可用的 Cohere 重排器模型名称,例如
rerank-english-v3.0、rerank-multilingual-v3.0等。如果您未指定此参数,将使用rerank-english-v2.0。有关可用模型的列表,请参见 Rerank。 -
api_key (string)
用于访问 Cohere API 的 API 密钥。有关如何创建 API 密钥的信息,请参见 Cohere dashboard。
示例
python
from pymilvus.model.reranker import CohereRerankFunction
# Define the rerank function
cohere_rf = CohereRerankFunction(
model_name="rerank-english-v3.0", # Specify the model name. Defaults to `rerank-english-v2.0`.
api_key=COHERE_API_KEY # Replace with your Cohere API key
)