Reciprocal Rank Fusion Retriever
The Reciprocal Rank Fusion (RRF) Retriever is a specialized retriever that uses the Reciprocal Rank Fusion algorithm to re-rank search results obtained from multiple query generations. This node enhances the retrieval process by generating synthetic queries and combining their results for improved relevance.
Node Details
-
Name: RRFRetriever
-
Type: RRFRetriever
-
Category: Retrievers
-
Version: 1.0
-
Base Classes: RRFRetriever, BaseRetriever
Input Parameters
-
Vector Store Retriever (required)
-
Type: VectorStoreRetriever
-
Description: The base retriever used for initial document retrieval.
-
-
Language Model (required)
-
Type: BaseLanguageModel
-
Description: The language model used for generating synthetic queries.
-
-
Query (optional)
-
Type: string
-
Description: Custom query to retrieve documents. If not specified, the user’s question will be used.
-
-
Query Count (optional)
-
Type: number
-
Default: 4
-
Description: Number of synthetic queries to generate.
-
-
Top K (optional)
-
Type: number
-
Description: Number of top results to fetch. Defaults to the TopK of the Base Retriever.
-
-
Constant (optional)
-
Type: number
-
Default: 60
-
Description: A constant added to the rank, controlling the balance between high-ranked and lower-ranked items.
-
Outputs
-
Reciprocal Rank Fusion Retriever
-
Type: RRFRetriever, BaseRetriever
-
Description: The initialized RRF retriever object.
-
-
Document
-
Type: Document, json
-
Description: Array of document objects containing metadata and pageContent.
-
-
Text
-
Type: string, json
-
Description: Concatenated string from pageContent of retrieved documents.
-
How It Works
-
The node initializes a ReciprocalRankFusion object using the provided language model, base retriever, and configuration parameters.
-
It then wraps this object in a ContextualCompressionRetriever for additional processing.
-
Depending on the selected output, the node can return:
-
The retriever object itself
-
An array of relevant documents
-
A concatenated text of the retrieved documents’ content
-
Use Cases
-
Improving search relevance in document retrieval systems
-
Enhancing question-answering systems with more diverse and relevant context
-
Boosting the performance of RAG (Retrieval-Augmented Generation) applications
Notes
-
The node uses escape character handling for text output to ensure proper formatting.
-
The synthetic query generation and re-ranking process happens internally within the ReciprocalRankFusion class.
Was this page helpful?