重排序模型
“重排序模型”被训练用来接收两段文本(通常是用户问题和文档),并返回一个介于0和1之间的相关性分数,估计文档在回答问题时的有用性。重排序器通常比LLMs小得多,相比之下会非常快速且成本低廉。
在Continue中,@Codebase使用重新排序来选择向量搜索后最相关的代码片段。
推荐的重新排序模型
如果您有能力使用任何模型,我们推荐使用Voyage AI的rerank-2,下面列出了该模型以及其他重新排序器的选项。
Voyage AI
Voyage AI 提供了最佳的代码重排序模型,即他们的 rerank-2 模型。从这里获取API密钥后,您可以这样配置:
config.json
{
"reranker": {
"name": "voyage",
"params": {
"model": "rerank-2",
"apiKey": "<VOYAGE_API_KEY>"
}
}
}
Cohere
查看Cohere的重新排序器文档这里。
config.json
{
"reranker": {
"name": "cohere",
"params": {
"model": "rerank-english-v3.0",
"apiKey": "<COHERE_API_KEY>"
}
}
}
LLM
如果你只能访问一个LLM,那么你可以将其用作重新排序器。除非真正必要,否则不建议这样做,因为它会昂贵得多,而且仍然不如专门为此任务训练的上述模型准确。请注意,如果你使用的是本地模型,例如与Ollama一起使用,这将不起作用,因为需要发出太多的并行请求。
config.json
{
"reranker": {
"name": "llm",
"params": {
"modelTitle": "My Model Title"
}
}
}
"modelTitle" 字段必须与 config.json 中 "models" 数组中的某个模型匹配。
文本嵌入推理
Hugging Face Text Embeddings Inference 使您能够托管自己的 reranker endpoint。您可以按如下方式配置您的reranker:
config.json
{
"reranker": {
"name": "huggingface-tei",
"params": {
"apiBase": "http://localhost:8080",
"apiKey": "<TEI_API_KEY>",
"truncate": true,
"truncation_direction": "Right"
}
}
}
免费试用 (Voyage AI)
Continue 提供 Voyage AI 的重新排序模型的免费试用。
config.json
{
"reranker": {
"name": "free-trial"
}
}