-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(RAG): Introduce SentenceTransformer Reranker (#1810)
- Loading branch information
1 parent
f83abff
commit 83adc12
Showing
7 changed files
with
198 additions
and
8 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
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,36 @@ | ||
## Enhancing Response Quality with Reranking | ||
|
||
PrivateGPT offers a reranking feature aimed at optimizing response generation by filtering out irrelevant documents, potentially leading to faster response times and enhanced relevance of answers generated by the LLM. | ||
|
||
### Enabling Reranking | ||
|
||
Document reranking can significantly improve the efficiency and quality of the responses by pre-selecting the most relevant documents before generating an answer. To leverage this feature, ensure that it is enabled in the RAG settings and consider adjusting the parameters to best fit your use case. | ||
|
||
#### Additional Requirements | ||
|
||
Before enabling reranking, you must install additional dependencies: | ||
|
||
```bash | ||
poetry install --extras rerank-sentence-transformers | ||
``` | ||
|
||
This command installs dependencies for the cross-encoder reranker from sentence-transformers, which is currently the only supported method by PrivateGPT for document reranking. | ||
|
||
#### Configuration | ||
|
||
To enable and configure reranking, adjust the `rag` section within the `settings.yaml` file. Here are the key settings to consider: | ||
|
||
- `similarity_top_k`: Determines the number of documents to initially retrieve and consider for reranking. This value should be larger than `top_n`. | ||
- `rerank`: | ||
- `enabled`: Set to `true` to activate the reranking feature. | ||
- `top_n`: Specifies the number of documents to use in the final answer generation process, chosen from the top-ranked documents provided by `similarity_top_k`. | ||
|
||
Example configuration snippet: | ||
|
||
```yaml | ||
rag: | ||
similarity_top_k: 10 # Number of documents to retrieve and consider for reranking | ||
rerank: | ||
enabled: true | ||
top_n: 3 # Number of top-ranked documents to use for generating the answer | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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