Post-retrieval Optimization

By Ludovico Bessi, Senior ML Engineer at Google · Updated

Post-retrieval optimization turns a large, high-recall candidate set into a small, precise context for the LLM. Its main tools are cross-encoder reranking, rank fusion, deduplication and ordering, context compression, iterative retrieval for multi-hop questions, and newer patterns such as AstuteRAG, ChunkRAG and StructRAG.

Between Retrieval and Generation

First-stage retrieval optimizes recall: get the relevant evidence somewhere in the top 50–200. The LLM needs precision: the few most useful passages, in a good order, without noise. Post-retrieval optimization closes that gap, and it often gives the largest quality gain per engineering hour after fixing data preparation.

Reranking With Cross-Encoders

A cross-encoder takes the query and one passage together as input and outputs a relevance score. Because every query token attends to every passage token, it captures interactions that bi-encoders (which embed each side separately) cannot. It is too slow to score millions of documents, but scoring 50–200 candidates is affordable.

hybrid retrieval → top 100 → cross-encoder rerank → top 5–10 → LLM

Options:

  • Open rerankers (BGE-reranker, mxbai-rerank, ms-marco cross-encoders) and hosted APIs (Cohere Rerank, Voyage, Jina).
  • LLM rerankers: prompt an LLM to score passages (pointwise) or sort a list (listwise, e.g. RankGPT). Strong but slower and costlier.
  • Late-interaction rerankers (ColBERT) as a cheaper middle ground.
  • Fine-tuned rerankers on your own relevance labels, which can be produced by an LLM judge and distilled into a small cross-encoder.

Latency is the main cost: a base-size cross-encoder over 100 passages on a GPU takes tens of milliseconds; budget for it, and cap passage length. Reranking also gives a calibrated-ish relevance score you can threshold: if no passage clears it, answer "I couldn't find this" rather than generating from weak evidence.

Fusion

When several retrievers or query variants produce ranked lists (hybrid search, multi-query RAG Fusion, multiple indexes), merge them before reranking. Reciprocal Rank Fusion (Cormack, Clarke and Büttcher, 2009),

RRF(d) = Σ_lists 1 / (k + rank(d)),   k = 60

is the standard: rank-based, parameter-light and robust to incomparable scores. Weighted RRF or normalized score fusion can do better when tuned on an evaluation set. Fusion then feeds a reranker, which makes the final ordering decision.

Context Selection and Ordering

  • Deduplicate and diversify. Remove near-duplicate passages; prefer covering different aspects (MMR — maximal marginal relevance — trades relevance against redundancy).
  • Merge adjacent chunks from the same document into continuous passages.
  • Order deliberately. Models attend best to the beginning and end of the context ("lost in the middle"); put the strongest evidence first (or first and last).
  • Format for citation. Give each passage an ID, title, source and date so the model can cite and weigh recency.

Summarization and Context Compression

Long contexts cost money and latency, and irrelevant text distracts the model. Compression options:

  • Extractive: keep only the sentences relevant to the query (scored by a small model or embedding similarity).
  • Abstractive: a small LLM summarizes each passage with respect to the query.
  • Token-level pruning: LLMLingua-style methods drop low-information tokens using a small language model's perplexity, achieving large compression ratios with modest quality loss.
  • Learned compressors: RECOMP (Xu et al., 2023) trains extractive and abstractive compressors specifically for RAG.

Compression adds its own latency and risk (a summarizer can drop the crucial detail). Use it when contexts are long and evaluation shows the full context is hurting or too expensive.

Iterative and Recursive Retrieval

Single-shot retrieval cannot answer multi-hop questions where the second search depends on the first answer. Iterative patterns:

  • Retrieve–read–retrieve. Generate a partial answer or follow-up query, retrieve again, repeat until done.
  • IRCoT (Trivedi et al., 2022) interleaves chain-of-thought steps with retrieval: each reasoning sentence becomes the next query.
  • FLARE (Jiang et al., 2023) retrieves actively when the model is about to generate low-confidence tokens.
  • Self-RAG (Asai et al., 2023) trains the model to emit reflection tokens deciding whether to retrieve and critiquing the relevance and support of passages.
  • Corrective RAG (CRAG) (Yan et al., 2024) uses a lightweight evaluator to judge retrieval quality and triggers query rewriting or web search when retrieved documents look wrong.
  • Recursive retrieval follows structure: retrieve a summary node, then descend into its chunks, or follow references from a retrieved document to linked documents.

These improve multi-hop accuracy but multiply latency and cost; they are the bridge to agentic RAG. Always set a maximum number of iterations.

Advanced Post-Retrieval Patterns

AstuteRAG: resolving knowledge conflicts

Retrieval is imperfect: some passages are irrelevant, outdated or wrong, and they may conflict with what the model already knows. Astute RAG (Wang et al., 2024) makes the conflict explicit. The LLM first generates passages from its internal knowledge, then consolidates internal and retrieved passages with source awareness — grouping consistent information, flagging conflicts — and finally answers based on the most reliable, consistent evidence. The paper reports that it is robust in the worst case where retrieval is mostly unhelpful, where standard RAG can be worse than no retrieval at all.

ChunkRAG: filtering at the chunk level

Retrieved documents often contain only a few relevant passages among irrelevant ones. ChunkRAG (Singh et al., 2024) uses semantic chunking and then has an LLM score each chunk's relevance to the query, filtering out low-relevance chunks before generation (with self-reflection and a critic to refine scores). Fine-grained filtering reduces distraction and hallucination, especially on fact-heavy questions. The practical lesson: filter by a relevance threshold, not just by top-k.

StructRAG: restructuring knowledge for the task

Some questions require reasoning over scattered information: comparisons across many documents, aggregations, timelines. StructRAG (Li et al., 2024), inspired by cognitive fit theory, uses a hybrid structure router to pick the best structure for the task — table, graph, algorithm, catalogue or plain chunks — a structurizer to convert retrieved documents into that structure, and a utilizer to decompose the question and answer over the structured knowledge. It performs especially well on complex, knowledge-intensive reasoning tasks where information is dispersed.

These patterns share a theme: don't pass raw retrieval output straight to the generator. Filter it, reconcile it and shape it for the question.

Key Takeaways

  1. Post-retrieval turns high-recall candidates into a small, precise, well-ordered context.
  2. Cross-encoder reranking is the highest-impact step; use its score to abstain when evidence is weak.
  3. RRF fuses lists from multiple retrievers or query variants robustly.
  4. Compress and order context deliberately; iterative retrieval (IRCoT, FLARE, Self-RAG, CRAG) handles multi-hop questions at extra cost.
  5. AstuteRAG reconciles conflicts, ChunkRAG filters chunks by relevance, and StructRAG restructures evidence for reasoning.