Overview
Reranking is an advanced feature that improves the relevance of memory search results by re-ordering them based on more sophisticated relevance scoring. After initial vector similarity search, rerankers use specialized models to provide more accurate relevance scores.Reranking operates as a post-processing step after the initial vector search. It takes the top results from vector similarity search and re-scores them using more advanced models or custom logic.
How It Works
- Vector Search: Initial semantic similarity search retrieves candidate memories
- Reranking: Selected reranker re-scores candidates using advanced models
- Final Results: Re-ordered results with both vector and rerank scores
Quick Start
Enable reranking by adding arerank section to your memory configuration:
Python
Supported Providers
Mem0 supports multiple reranking providers:- Zero Entropy: State-of-the-art neural reranking
- Cohere: Enterprise-grade with multilingual support
- Sentence Transformer: Local HuggingFace models
- LLM-based: Custom scoring using any LLM
When to Use Reranking
Reranking is particularly effective for:- Improved Relevance: When vector search alone doesn’t provide sufficiently relevant results
- Domain-Specific Queries: Specialized terminology or context that benefits from advanced models
- Customer Support: Finding the most relevant help articles and documentation
- Knowledge Management: Better search results in internal knowledge bases
- Personal AI Assistants: More accurate memory recall for user queries
Configuration Options
Each reranker has specific configuration options. See the Rerankers Documentation for detailed configuration parameters.Basic Configuration
Python
Controlling Reranking
You can enable or disable reranking per search:Python
Performance Considerations
- Latency: Reranking adds processing time but significantly improves relevance
- Cost: API-based rerankers (Zero Entropy, Cohere, LLM) have per-request costs
- Local Options: Sentence Transformer reranker runs locally with no API costs
- Quality vs Speed: Balance based on your application’s requirements
Next Steps
- Explore specific reranker providers and their capabilities
- Learn about configuration options for fine-tuning
- Check out Vector Stores for different storage backends
- See Async Memory for non-blocking reranking operations