Elffuss BraidHub

kikocis/continue public

627d7d0d1f85 · 4.2 KiBRawPermalink
1---
2title: Rerank Role
3description: Rerank model role
4keywords: [rerank, reranking, model, role]
5sidebar_position: 6
6---
7
8A "reranking model" is trained to take two pieces of text (often a user question and a document) and return a relevancy score between 0 and 1, estimating how useful the document will be in answering the question. Rerankers are typically much smaller than LLMs, and will be extremely fast and cheap in comparison.
9
10In Continue, rerankers are designated using the `rerank` role and used by [@Codebase](../context/codebase.mdx) in order to select the most relevant code snippets after vector search.
11
12## Recommended reranking models
13
14If you have the ability to use any model, we recommend `rerank-2` by Voyage AI, which is listed below along with the rest of the options for rerankers.
15
16### Voyage AI
17
18Voyage AI offers the best reranking model for code with their `rerank-2` model. After obtaining an API key from [here](https://www.voyageai.com/), you can configure a reranker as follows:
19
20<Tabs>
21 <Tab title="Hub">
22 [Voyage Rerank 2 Block](https://hub.continue.dev/voyageai/rerank-2)
23 </Tab>
24 <Tab title="YAML">
25 ```yaml title="config.yaml"
26 models:
27 - name: My Voyage Reranker
28 provider: voyage
29 apiKey: <YOUR_VOYAGE_API_KEY>
30 model: rerank-2
31 roles:
32 - rerank
33 ```
34 </Tab>
35 <Tab title="JSON">
36 ```json title="config.json"
37 {
38 "reranker": {
39 "name": "voyage",
40 "params": {
41 "model": "rerank-2",
42 "apiKey": "<YOUR_VOYAGE_API_KEY>"
43 }
44 }
45 }
46 ```
47 </Tab>
48</Tabs>
49
50### Cohere
51
52See Cohere's documentation for rerankers [here](https://docs.cohere.com/docs/rerank-2).
53
54<Tabs>
55 {/* HUB_TODO block doesn't exist */}
56 {/* <Tab title="Hub">
57 [Cohere Reranker English v3](https://hub.continue.dev/)
58 </Tab> */}
59 <Tab title="YAML">
60 ```yaml title="config.yaml"
61 models:
62 - name: Cohere Reranker
63 provider: cohere
64 model: rerank-english-v3.0
65 apiKey: <YOUR_COHERE_API_KEY>
66 roles:
67 - rerank
68 ```
69 </Tab>
70 <Tab title="JSON">
71 ```json title="config.json"
72 {
73 "reranker": {
74 "name": "cohere",
75 "params": {
76 "model": "rerank-english-v3.0",
77 "apiKey": "<YOUR_COHERE_API_KEY>"
78 }
79 }
80 }
81 ```
82 </Tab>
83</Tabs>
84
85### LLM
86
87If you only have access to a single LLM, then you can use it as a reranker. This is discouraged unless truly necessary, because it will be much more expensive and still less accurate than any of the above models trained specifically for the task. Note that this will not work if you are using a local model, for example with Ollama, because too many parallel requests need to be made.
88
89<Tabs>
90 {/* HUB_TODO block doesn't exist */}
91 {/* <Tab title="Hub">
92 [GPT-4o LLM Reranker Block](https://hub.continue.dev/)
93 </Tab> */}
94 <Tab title="YAML">
95 ```yaml title="config.yaml"
96 models:
97 - name: LLM Reranker
98 provider: openai
99 model: gpt-4o
100 roles:
101 - rerank
102 ```
103 </Tab>
104 <Tab title="JSON">
105 ```json title="config.json"
106 {
107 "reranker": {
108 "name": "llm",
109 "params": {
110 "modelTitle": "My Model Title"
111 }
112 }
113 }
114 ```
115 </Tab>
116</Tabs>
117
118The `"modelTitle"` field must match one of the models in your "models" array in config.json.
119
120### Text Embeddings Inference
121
122[Hugging Face Text Embeddings Inference](https://huggingface.co/docs/text-embeddings-inference/en/index) enables you to host your own [reranker endpoint](https://huggingface.github.io/text-embeddings-inference/#/Text%20Embeddings%20Inference/rerank). You can configure your reranker as follows:
123
124<Tabs>
125 {/* HUB_TODO */}
126 {/* <Tab title="Hub">
127 [HuggingFace TEI Reranker block](https://hub.continue.dev/)
128 </Tab> */}
129 <Tab title="YAML">
130 ```yaml title="config.yaml"
131 models:
132 - name: Huggingface-tei Reranker
133 provider: huggingface-tei
134 apiBase: http://localhost:8080
135 apiKey: <YOUR_TEI_API_KEY>
136 roles:
137 - rerank
138 ```
139 </Tab>
140 <Tab title="JSON">
141 ```json title="config.json"
142 {
143 "reranker": {
144 "name": "huggingface-tei",
145 "params": {
146 "apiBase": "http://localhost:8080",
147 "apiKey": "<YOUR_TEI_API_KEY>"
148 }
149 }
150 }
151 ```
152 </Tab>
153</Tabs>