You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Reranking](https://github.com/amikos-tech/chromadbx/blob/main/docs/reranking.md) - rerank documents and query results using Cohere, OpenAI, or custom reranking functions.
23
+
-[Cohere](https://github.com/amikos-tech/chromadbx/blob/main/docs/reranking.md#cohere) - rerank documents and query results using Cohere.
Reranking is a process of reordering a list of items based on their relevance to a query. This project supports reranking of documents and query results.
4
+
5
+
```python
6
+
from chromadbx.reranking.some_reranker import SomeReranker
7
+
import chromadb
8
+
some_reranker = SomeReranker()
9
+
10
+
client = chromadb.Client()
11
+
12
+
collection = client.get_collection("documents")
13
+
14
+
results = collection.query(
15
+
query_texts=["What is the capital of the United States?"],
> It is our intent that all officially supported reranking functions shall return distances instead of scores to be consistent with the core Chroma project. However, this is not a hard requirement and you should check the documentation for each reranking function you plan to use.
Cohere reranking function offers a convinient wrapper around the Cohere API to rerank documents and query results. For more information on Cohere reranking, visit the official [docs](https://docs.cohere.com/docs/rerank-2) or [API docs](https://docs.cohere.com/reference/rerank).
38
+
39
+
You need to install the `cohere` package to use this reranking function.
40
+
41
+
42
+
```bash
43
+
pip install cohere # or poetry add cohere
44
+
```
45
+
46
+
Before using the reranking function, you need to obtain [Cohere API](https://dashboard.cohere.com/api-keys) key and set the `COHERE_API_KEY` environment variable.
47
+
48
+
> [!TIP]
49
+
> By default, the reranking function will return distances. If you need to get the raw scores, set the `raw_scores` parameter to `True`.
0 commit comments