Reranking
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:
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 thantop_n
.rerank
:enabled
: Set totrue
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 bysimilarity_top_k
.
Example configuration snippet: