Elffuss BraidHub

kikocis/continue public

169e4d970312 · 4.4 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) in order to select the most relevant code snippets after vector search.
11
12## Recommended reranking models
13
14<Info>
15 For a comparison of all reranking models including open and closed options, see our [comprehensive model recommendations](/customization/models#recommended-models).
16</Info>
17
18If 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.
19
20### Voyage AI
21
22Voyage 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:
23
24<Tabs>
25 <Tab title="Hub">
26 [Voyage Rerank 2 Block](https://hub.continue.dev/voyageai/rerank-2)
27 </Tab>
28 <Tab title="YAML">
29 ```yaml title="config.yaml"
30 models:
31 - name: My Voyage Reranker
32 provider: voyage
33 apiKey: <YOUR_VOYAGE_API_KEY>
34 model: rerank-2
35 roles:
36 - rerank
37 ```
38 </Tab>
39 <Tab title="JSON">
40 ```json title="config.json"
41 {
42 "reranker": {
43 "name": "voyage",
44 "params": {
45 "model": "rerank-2",
46 "apiKey": "<YOUR_VOYAGE_API_KEY>"
47 }
48 }
49 }
50 ```
51 </Tab>
52</Tabs>
53
54### Cohere
55
56See Cohere's documentation for rerankers [here](https://docs.cohere.com/docs/rerank-2).
57
58<Tabs>
59 {/* HUB_TODO block doesn't exist */}
60 {/* <Tab title="Hub">
61 [Cohere Reranker English v3](https://hub.continue.dev/)
62 </Tab> */}
63 <Tab title="YAML">
64 ```yaml title="config.yaml"
65 models:
66 - name: Cohere Reranker
67 provider: cohere
68 model: rerank-english-v3.0
69 apiKey: <YOUR_COHERE_API_KEY>
70 roles:
71 - rerank
72 ```
73 </Tab>
74 <Tab title="JSON">
75 ```json title="config.json"
76 {
77 "reranker": {
78 "name": "cohere",
79 "params": {
80 "model": "rerank-english-v3.0",
81 "apiKey": "<YOUR_COHERE_API_KEY>"
82 }
83 }
84 }
85 ```
86 </Tab>
87</Tabs>
88
89### LLM
90
91If 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.
92
93<Tabs>
94 {/* HUB_TODO block doesn't exist */}
95 {/* <Tab title="Hub">
96 [GPT-4o LLM Reranker Block](https://hub.continue.dev/)
97 </Tab> */}
98 <Tab title="YAML">
99 ```yaml title="config.yaml"
100 models:
101 - name: LLM Reranker
102 provider: openai
103 model: gpt-4o
104 roles:
105 - rerank
106 ```
107 </Tab>
108 <Tab title="JSON">
109 ```json title="config.json"
110 {
111 "reranker": {
112 "name": "llm",
113 "params": {
114 "modelTitle": "My Model Title"
115 }
116 }
117 }
118 ```
119 </Tab>
120</Tabs>
121
122The `"modelTitle"` field must match one of the models in your "models" array in config.json.
123
124### Text Embeddings Inference
125
126[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:
127
128<Tabs>
129 {/* HUB_TODO */}
130 {/* <Tab title="Hub">
131 [HuggingFace TEI Reranker block](https://hub.continue.dev/)
132 </Tab> */}
133 <Tab title="YAML">
134 ```yaml title="config.yaml"
135 models:
136 - name: Huggingface-tei Reranker
137 provider: huggingface-tei
138 model: tei
139 apiBase: http://localhost:8080
140 apiKey: <YOUR_TEI_API_KEY>
141 roles:
142 - rerank
143 ```
144 </Tab>
145 <Tab title="JSON">
146 ```json title="config.json"
147 {
148 "reranker": {
149 "name": "huggingface-tei",
150 "params": {
151 "apiBase": "http://localhost:8080",
152 "apiKey": "<YOUR_TEI_API_KEY>"
153 }
154 }
155 }
156 ```
157 </Tab>
158</Tabs>