
Node Details
- Name: llmFilterRetriever
- Type: LLMFilterRetriever
- Version: 1.0
- Category: Retrievers
- Base Classes: LLMFilterRetriever, BaseRetriever
Input Parameters
-
Vector Store Retriever
- Name: baseRetriever
- Type: VectorStoreRetriever
- Description: The underlying retriever used to fetch initial documents.
-
Language Model
- Name: model
- Type: BaseLanguageModel
- Description: The language model used for filtering and extracting relevant content.
-
Query (Optional)
- Name: query
- Type: string
- Description: Query to retrieve documents from the retriever. If not specified, the user’s question will be used.
- Accepts variables: Yes
Outputs
-
LLM Filter Retriever
- Name: retriever
- Type: LLMFilterRetriever, BaseRetriever
- Description: The configured LLM Filter Retriever object.
-
Document
- Name: document
- Type: Document, json
- Description: Array of document objects containing metadata and pageContent.
-
Text
- Name: text
- Type: string, json
- Description: Concatenated string from pageContent of filtered documents.
Functionality
The LLM Filter Retriever uses a ContextualCompressionRetriever with an LLMChainExtractor. It works as follows:- The base retriever (e.g., a vector store retriever) fetches initial documents.
- The language model (LLM) is used to create an LLMChainExtractor, which serves as the base compressor.
- The ContextualCompressionRetriever combines the base retriever and the LLM-based compressor.
- When retrieving documents, the compressor filters and extracts only the relevant content from each document based on the query.
Usage
This node is particularly useful in workflows where:- The initial document retrieval might return lengthy or partially relevant documents.
- You need to extract specific, query-relevant information from a larger context.
- You want to improve the quality and relevance of retrieved information before passing it to subsequent processing steps or presenting it to the user.