Skip to content

Contextual Compression Retriever

Contextual Compression Retriever takes another retriever’s results and refines them for the question: it drops the ones that do not answer, trims each one to the part that answers, or orders them again. The agent receives less, more relevant text.

A retriever receives a question and returns the document pieces that best answer it, so an agent or model can reply with your information.

When to use it

  • The retriever returns results unrelated to the question that confuse the agent.
  • Your documents are long and only part of each one answers.
  • You want to reduce the text that reaches the model.

Configuration

FieldWhat it does
Search QueryThe question.
CompressorHow results are refined. LLMChainFilter (default): a model reads each result and drops the ones that do not answer. LLMChainExtractor: a model keeps only the sentences of each result that answer. LLMListwiseRerank: a model orders the results and keeps the best. EmbeddingsFilter: drops the results whose meaning is far from the question, without a language model.
Base RetrieverThe retriever whose results are refined, for example the Retriever output of a vector database with 10 results.
LLMThe model the first three compressors use. It only shows with them.
EmbeddingThe embeddings model EmbeddingsFilter compares with. It only shows with that compressor.

Advanced options

FieldWhat it does
Similarity ThresholdWith EmbeddingsFilter: results less similar to the question than this value (0 to 1) are dropped. Default: 0.4.
Number of ResultsHow many results to keep at most. 0 (default): all the compressor lets through; LLMListwiseRerank then keeps 3.

Output

  • Retriever: the search engine, to connect to components that ask for one, such as another in this family or a question-answering component.
  • Search Results: the refined results for Search Query, which you can pass to a prompt or an agent. Each run’s log says how many results the base retriever found and how many were kept.

Use as an agent tool

Connect Contextual Compression Retriever to the Tools input of an Agent and the agent searches on its own: it writes Search Query with the question. In the Tool tab, Tool Name and Tool Description are the name and explanation the agent uses to recognise the tool. It is called refined_search by default; change the description to say what your documents contain.

Example

A law firm wants the agent to receive only the clauses that matter.

  1. Connect the Retriever output of its contract database, with Number of Results 10, to Base Retriever.
  2. Leave LLMChainFilter in Compressor and connect a fast model to LLM.
  3. Connect the component to the agent’s Tools.

Measured figures

Measured on 17 October 2026 on a test knowledge base (9 documents of a fictional repair service; 16 questions phrased in other words or whose chunk does not say what it is about; base retriever with 10 results; DeepSeek as the model). It is a single synthetic set: it shows how the technique behaves, not a promise for your data.

CompressorRight answer firstIn the top 5Results kept (of 10)Time per question
None (the 10 results)75 %100 %100.01 s
LLMChainFilter88 %100 %2.51.0 s
LLMListwiseRerank (keeps 5)88 %100 %51.0 to 1.2 s
LLMChainExtractor94 %100 %the useful sentences8.8 s
EmbeddingsFilter 0.375 %100 %8.90.6 s
EmbeddingsFilter 0.469 %94 %5.90.6 to 1.1 s
EmbeddingsFilter 0.550 %69 %2.90.6 to 1.3 s
  • LLMChainFilter is the best balance: it never dropped the right answer and the agent receives a quarter of the text.
  • LLMChainExtractor orders a little better but takes eight times longer, because the model rewrites each result.
  • The right Similarity Threshold depends on the embeddings model: with 0.4 one question was left with no result at all, and with 0.5 five were. Try it with your own questions before raising it.

Video

This video shows how Multi Query Retriever finds an answer that plain search misses when the question uses other words, and how compression keeps only the useful results.

What you see in the video:

  1. A question phrased in other words, along the lines of “if a repair breaks again a few months later, do you charge me again?”. Plain search does not bring back the repair warranty section.
  2. Multi Query Retriever writes 3 versions of the question and also searches with the original one: now it finds that section.
  3. The run’s log shows the questions it searched with.
  4. Contextual Compression Retriever, with a model that reviews 10 results and drops the ones that do not answer, keeps only a few: the log says how many it found and how many it kept.
  • Local Rerank: reorders results with a reranking model that runs inside the platform, without a language model.
  • Chroma DB: a vector database these retrievers can start from.

To see how search techniques combine, see Search techniques in the RAG guide.