Elffuss BraidHub

kikocis/continue public

main · 3.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 awareness](/guides/codebase-documentation-awareness) 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 ```yaml title="config.yaml"
27 models:
28 - uses: voyageai/rerank-2
29 ```
30 </Tab>
31 <Tab title="YAML">
32 ```yaml title="config.yaml"
33 models:
34 - name: My Voyage Reranker
35 provider: voyage
36 apiKey: <YOUR_VOYAGE_API_KEY>
37 model: rerank-2
38 roles:
39 - rerank
40 ```
41 </Tab>
42</Tabs>
43
44### Cohere
45
46See Cohere's documentation for rerankers [here](https://docs.cohere.com/docs/rerank-2).
47
48<Tabs>
49 {/* HUB_TODO block doesn't exist */}
50 {/* <Tab title="Hub">
51 [Cohere Reranker English v3](https://hub.continue.dev/)
52 </Tab> */}
53 <Tab title="YAML">
54 ```yaml title="config.yaml"
55 models:
56 - name: Cohere Reranker
57 provider: cohere
58 model: rerank-english-v3.0
59 apiKey: <YOUR_COHERE_API_KEY>
60 roles:
61 - rerank
62 ```
63 </Tab>
64</Tabs>
65
66### LLM
67
68If 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.
69
70<Tabs>
71 {/* HUB_TODO block doesn't exist */}
72 {/* <Tab title="Hub">
73 [GPT-4o LLM Reranker Block](https://hub.continue.dev/)
74 </Tab> */}
75 <Tab title="YAML">
76 ```yaml title="config.yaml"
77 models:
78 - name: LLM Reranker
79 provider: openai
80 model: gpt-4o
81 roles:
82 - rerank
83 ```
84 </Tab>
85</Tabs>
86
87
88
89### Text Embeddings Inference
90
91[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:
92
93<Tabs>
94 {/* HUB_TODO */}
95 {/* <Tab title="Hub">
96 [HuggingFace TEI Reranker block](https://hub.continue.dev/)
97 </Tab> */}
98 <Tab title="YAML">
99 ```yaml title="config.yaml"
100 models:
101 - name: Huggingface-tei Reranker
102 provider: huggingface-tei
103 model: tei
104 apiBase: http://localhost:8080
105 apiKey: <YOUR_TEI_API_KEY>
106 roles:
107 - rerank
108 ```
109 </Tab>
110</Tabs>