What does a LlamaIndex NodePostprocessor sit between, and what does it typically do?
NodePostprocessor sits between the Retriever and the ResponseSynthesizer in a QueryEngine. It transforms or filters the retrieved Nodes (rerank, threshold, recency, context-window swap) before synthesis sees them.
Think of a library search. The retriever is the catalog: it finds 50 books that mention your topic. The synthesizer is the friend who writes you a summary. The postprocessor is the librarian in the middle. The librarian throws out the irrelevant ones, reorders by usefulness, and swaps a short excerpt for the full chapter when more context helps. Without the librarian, your friend gets all 50 books in random order and writes a worse summary. With the librarian, the friend gets the 5 best in the right order and the summary is clean.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
LlamaIndex's QueryEngine is a three-stage pipeline: Retriever, NodePostprocessor(s), ResponseSynthesizer. The retriever owns recall, the synthesizer owns answer composition, and the postprocessor slot in the middle is where most production RAG quality fixes go.
Each implementation addresses a real failure mode in first-stage retrieval.
The retriever is recall-oriented (pull a broad candidate set), the postprocessor is precision-oriented (clean the candidate set), and the synthesizer is composition-oriented (turn the cleaned set into an answer).
Where it sits and what contract it honors
Pipeline position
A QueryEngine orchestrates three stages:
- Retriever runs the index (vector, BM25, hybrid) and returns
List[NodeWithScore]. - NodePostprocessor transforms that list. Multiple postprocessors chain in declaration order, each one's output feeding the next.
- ResponseSynthesizer takes the final Node list, formats a prompt, and calls the LLM.
The contract
A NodePostprocessor implements _postprocess_nodes(nodes, query_bundle) -> nodes. It accepts the retriever's output and returns a new Node list. It can drop, reorder, rewrite, or annotate nodes. It cannot re-query the retriever. Postprocessors are pure transforms of the current retrieval.
That contract is why postprocessors compose freely. Filter, then rerank, then reorder is three transforms in a list. Each is independently testable and each can be added or removed without touching the retriever or the synthesizer.
Why this design
LlamaIndex chose a stateless transform slot rather than baking rerank or filtering into the retriever. The benefit is composition. You can run hybrid retrieval and stack three postprocessors without rewriting the retriever. You can swap CohereRerank for a local cross-encoder by changing one line. The cost is that anything cross-query or stateful does not belong here, and that limit is intended.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Cohere's documented LlamaIndex integration uses CohereRerank as the canonical postprocessor for cross-encoder reranking.
- Anthropic's Contextual Retrieval write-up (2024) combines contextual embeddings, BM25 and a reranking step. In LlamaIndex that maps to a hybrid retriever plus a rerank postprocessor.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you decide between CohereRerank, SentenceTransformerRerank, and BGE-reranker-v2-m3?
CohereRerank is the easiest production default if you can afford an API call (Cohere rerank-3.5, English plus multilingual). SentenceTransformerRerank is the local CPU or GPU option for cost or privacy reasons, with lower throughput. BGE-reranker-v2-m3 is the strongest open-weight option. It runs on commodity GPUs and sits at the top of the open-source leaderboards. Pick API for ease, BGE for self-hosted quality, SentenceTransformer for cheap or air-gapped.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Treating the postprocessor as optional decoration. In real RAG, dropping the rerank or threshold step costs you 5 to 15 percent NDCG at the top of the candidate list.
60 second bullets to scan on the way to the call.
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.