跳到主要内容

VoyageRerankFunction

VoyageRerankFunction 是 milvus_model 中的一个类,它以 query 和 document 作为输入,并直接返回相似度分数而不是 embeddings。此功能使用底层的 Voyage 重排模型。

python
pymilvus.model.reranker.VoyageRerankFunction

构造函数​

构造一个适用于常见用例的 VoyageRerankFunction。

python
VoyageRerankFunction(
model_name: str = "rerank-lite-1",
api_key: Optional[str] = None
)

参数:

  • model_name (string)

    用于编码的 Voyage 模型名称。您可以指定任意可用的 Voyage 模型名称,例如 voyage-law-2、voyage-code-2 等。如果您未指定此参数,将使用 voyage-2。可用模型列表请参见 Voyage 官方文档。

  • api_key (string)

    用于访问 Voyage API 的 API 密钥。有关如何创建 API 密钥的信息,请参见 API Key and Python Client。

示例​

python
from pymilvus.model.reranker import VoyageRerankFunction

# Define the rerank function
voyage_rf = VoyageRerankFunction(
model_name="rerank-lite-1", # Specify the model name. Defaults to `rerank-lite-1`.
api_key=VOYAGE_API_KEY # Replace with your Voyage API key
)
最低 SDK 版本v2.4.x