-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ajosh0504
committed
Jul 17, 2024
1 parent
b8beaea
commit f9bbd5a
Showing
3 changed files
with
41 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 🦹 Re-rank retrieved results | ||
|
||
Re-rankers are specialized models that are trained to calculate the relevance between query-document pairs. Without re-ranking the order of retrieved results is governed by the embedding model, which isn't optimized for relevance and can lead to poor LLM recall in RAG applications. | ||
|
||
Fill in any `<CODE_BLOCK_N>` placeholders and run the cells under the **🦹♀️ Re-rank retrieved results** section in the notebook to add a re-ranking stage to the RAG application. | ||
|
||
The answers for code blocks in this section are as follows: | ||
|
||
**CODE_BLOCK_25** | ||
|
||
<details> | ||
<summary>Answer</summary> | ||
<div> | ||
```python | ||
rerank_model.rank( | ||
user_query, documents, return_documents=True, top_k=5 | ||
) | ||
``` | ||
</div> | ||
</details> | ||
|
||
**CODE_BLOCK_26** | ||
|
||
<details> | ||
<summary>Answer</summary> | ||
<div> | ||
```python | ||
"\n\n".join([d.get("text", "") for d in reranked_documents]) | ||
``` | ||
</div> | ||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters