Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more reranker into Rerank MD #11508

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/examples/node_postprocessor/JinaRerank.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<a href=\"https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/examples/node_postprocessor/CohereRerank.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
"<a href=\"https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/examples/node_postprocessor/JinaRerank.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,48 @@ postprocessor = RankGPTRerank(top_n=3, llm=OpenAI(model="gpt-3.5-turbo-16k"))
postprocessor.postprocess_nodes(nodes)
```

Full notebook guide is available [her for Van Gogh](/examples/node_postprocessor/rankGPT.ipynb).
Full notebook guide is available [here](/examples/node_postprocessor/rankGPT.ipynb).

## Colbert Reranker

Uses Colbert V2 model as a reranker to rerank documents according to the fine-grained similarity between query tokens and passage tokens. Returns the top N ranked nodes.

```python
from llama_index.postprocessor.colbert_rerank import ColbertRerank

colbert_reranker = ColbertRerank(
top_n=5,
model="colbert-ir/colbertv2.0",
tokenizer="colbert-ir/colbertv2.0",
keep_retrieval_score=True,
)

query_engine = index.as_query_engine(
similarity_top_k=10,
node_postprocessors=[colbert_reranker],
)
response = query_engine.query(
query_str,
)
```

Full notebook guide is available [here](/examples/node_postprocessor/ColbertRerank.ipynb).

## Jina Reranker

Uses models from [jina](https://jina.ai/) to rerank documents. Returns the top N ranked nodes.

```python
from llama_index.postprocessor.jinaai_rerank import JinaRerank

jina_rerank = JinaRerank(api_key=api_key, top_n=2)

query_engine = index.as_query_engine(
similarity_top_k=10, node_postprocessors=[jina_rerank]
)
```

Full notebook guide is available [here](/examples/node_postprocessor/JinaRerank.ipynb).

## All Notebooks

Expand All @@ -273,4 +314,6 @@ maxdepth: 1
/examples/node_postprocessor/MetadataReplacementDemo.ipynb
/examples/node_postprocessor/LongContextReorder.ipynb
/examples/node_postprocessor/rankGPT.ipynb
/examples/node_postprocessor/ColbertRerank.ipynb
/examples/node_postprocessor/JinaRerank.ipynb
```
Loading