Skip to main content
Postprocessors allow you to filter, rerank, and transform the results returned by retrievers before they’re sent to the LLM. They’re essential for improving the quality and relevance of your RAG responses.

Overview

Postprocessors implement the BaseNodePostprocessor interface and process NodeWithScore arrays returned from retrievers. They can:
  • Filter nodes based on similarity scores
  • Rerank results using external models
  • Replace node content with metadata
  • Apply custom transformations

Similarity Cutoff

Filter out nodes below a similarity threshold:
Nodes with a similarity score below 0.7 will be filtered out, even if they’re in the top K results.

Reranking

Rerankers use specialized models to reorder results based on relevance to the query.

JinaAI Reranker

Use Jina AI’s reranking models:
Environment Variables:
Available Models:
  • jina-reranker-v1-base-en - English base model
  • jina-reranker-v1-turbo-en - Faster English model

MixedbreadAI Reranker

For Mixedbread AI reranking:

Metadata Replacement

Replace node content with metadata values:
This is useful when you store window text or summaries in metadata and want to use those instead of the original node content.

Combining Postprocessors

Chain multiple postprocessors for sophisticated filtering:
Postprocessors are applied in order, so plan your chain strategically.

Custom Postprocessors

Implement custom logic by extending BaseNodePostprocessor:

Metadata Filtering

While not technically postprocessors, metadata filters are applied at retrieval time:
Filter Operators:
  • == - Equals
  • != - Not equals
  • > - Greater than
  • < - Less than
  • >= - Greater than or equal
  • <= - Less than or equal
  • in - In array
  • nin - Not in array

Best Practices

Retrieval Strategy:
  1. Retrieve more results than needed (e.g., similarityTopK: 20)
  2. Apply similarity cutoff to remove poor matches
  3. Use reranker to select best results (e.g., topN: 3)
Performance:
  • Reranking adds latency but improves relevance
  • Filter before reranking to reduce reranking costs
  • Use metadata filters at retrieval time when possible
Quality:
  • Tune similarity cutoffs based on your embedding model
  • Experiment with different reranking models
  • Monitor which postprocessors provide the most value

Next Steps

Response Synthesizers

Learn how to generate responses from retrieved nodes

Evaluation

Evaluate and improve your RAG pipeline