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

  • BaseRetriever
    • ContextualCompressionRetriever

Constructors

Properties

Constructors

Properties

baseCompressor: BaseDocumentCompressor
baseRetriever: BaseRetriever

Generated using TypeDoc