Elffuss BraidHub

kikocis/continue public

e8ee99375f3e · 2.4 KiBRenderedRawPermalink
1---
2title: 重排序模型
3description: 重排序模型
4keywords: [重排序]
5sidebar_position: 4
6---
7
8"重排序模型" 是训练为采用两部分文本(通常一个用户问题和一个文档)并返回 0 和 1 之间的相关性得分,估算文档回答问题的可用性。重排序通常远小于 LLM ,在比较中非常快速和便宜。
9
10在 Continue 中,重排序用在 [@Codebase](../deep-dives/codebase.md) ,为了在向量搜索之后选择最想关的代码片断。
11
12## 推荐的重排序模型
13
14如果你有使用任何模型的能力,我们推荐 Voyage AI 的 `rerank-1` ,它独立列在下面,和其他的重排序选项一起。
15
16### Voyage AI
17
18Voyage AI 提供代码最好的重排序模型, 使用他们的 `rerank-1` 模型。在从 [这里](https://www.voyageai.com/) 获取 API key 后,你可以像这样配置:
19
20```json title="config.json"
21{
22 "reranker": {
23 "name": "voyage",
24 "params": {
25 "model": "rerank-1",
26 "apiKey": "<VOYAGE_API_KEY>"
27 }
28 }
29}
30```
31
32### Cohere
33
34在 [这里](https://docs.cohere.com/docs/rerank-2) 查看 Cohere 对于重排序的文档。
35
36```json title="config.json"
37{
38 "reranker": {
39 "name": "cohere",
40 "params": {
41 "model": "rerank-english-v3.0",
42 "apiKey": "<COHERE_API_KEY>"
43 }
44 }
45}
46```
47
48### LLM
49
50如果你只能访问一个单独的 LLM ,那么你可以使用它作为重排器。这是不推荐的,除非真正需要,因为它将会更昂贵,并且仍然比上面这些特殊任务训练的模型慢。注意,如果你使用本地的模型,这将不会工作,例如使用 Ollama ,因为会创建太多的并发请求。
51
52```json title="config.json"
53{
54 "reranker": {
55 "name": "llm",
56 "params": {
57 "modelTitle": "My Model Title"
58 }
59 }
60}
61```
62
63`"modelTitle"` 字段必须匹配在你的 `config.json` 中 "models" 列表中的一个模型。
64
65### 文本嵌入推理
66
67[Hugging Face 文本嵌入推理](https://huggingface.co/docs/text-embeddings-inference/en/index) 允许你托管自己的 [重排器端点](https://huggingface.github.io/text-embeddings-inference/#/Text%20Embeddings%20Inference/rerank) 。你可以像这样配置你的重排器:
68
69```json title="config.json"
70{
71 "reranker": {
72 "name": "huggingface-tei",
73 "params": {
74 "apiBase": "http://localhost:8080",
75 "truncate": true,
76 "truncation_direction": "Right"
77 }
78 }
79}
80```