A retriever that wraps a base retriever and compresses the results. It retrieves relevant documents based on a given query and then compresses these documents using a specified document compressor.

Example

const retriever = new ContextualCompressionRetriever({
baseCompressor: new LLMChainExtractor(),
baseRetriever: new HNSWLib().asRetriever(),
});
const retrievedDocs = await retriever.getRelevantDocuments(
"What did the speaker say about Justice Breyer?",
);

Hierarchy (view full)

  • Toolkit
    • ContextualCompressionRetriever

Constructors

Properties

baseCompressor: BaseDocumentCompressor
baseRetriever: BaseRetrieverInterface

Generated using TypeDoc