Overview
Postprocessors implement theBaseNodePostprocessor 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: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:jina-reranker-v1-base-en- English base modeljina-reranker-v1-turbo-en- Faster English model
MixedbreadAI Reranker
For Mixedbread AI reranking:Metadata Replacement
Replace node content with metadata values:Combining Postprocessors
Chain multiple postprocessors for sophisticated filtering:Custom Postprocessors
Implement custom logic by extendingBaseNodePostprocessor:
Metadata Filtering
While not technically postprocessors, metadata filters are applied at retrieval time:==- Equals!=- Not equals>- Greater than<- Less than>=- Greater than or equal<=- Less than or equalin- In arraynin- Not in array
Best Practices
Retrieval Strategy:- Retrieve more results than needed (e.g.,
similarityTopK: 20) - Apply similarity cutoff to remove poor matches
- Use reranker to select best results (e.g.,
topN: 3)
- Reranking adds latency but improves relevance
- Filter before reranking to reduce reranking costs
- Use metadata filters at retrieval time when possible
- 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