What does a LlamaIndex NodePostprocessor sit between, and what does it typically do?
NodePostprocessor sits between the Retriever and the ResponseSynthesizer in a QueryEngine, transforming or filtering 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 who 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 land.
The flashcard asks two things: where it sits in the pipeline, and what real implementations populate the slot. The pipeline position is one sentence; the implementation list is the longer answer because each entry corresponds to a real failure mode in first-stage retrieval.
Mental model: 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 just 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 exactly 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 is a feature, not a bug.
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 cookbook adds BM25 plus vector retrieval with a Voyage rerank-2.5 postprocessor in LlamaIndex.
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 in 2026?
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, lower throughput. BGE-reranker-v2-m3 is the strongest open-weight option, runs on commodity GPUs, 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.