Mem0 1.0.0 (#3545)
This commit is contained in:
@@ -1,52 +1,70 @@
|
||||
---
|
||||
title: Overview
|
||||
icon: "info"
|
||||
icon: "arrow-up-arrow-down"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
Rerankers enhance the quality of search results by re-ordering the initial retrieval results using more sophisticated scoring mechanisms. They act as a secondary ranking layer that can significantly improve the relevance of retrieved memories.
|
||||
|
||||
## How Rerankers Work
|
||||
|
||||
1. **Initial Retrieval**: Vector search returns candidate memories based on semantic similarity
|
||||
2. **Reranking**: The reranker evaluates and re-scores these candidates using more complex criteria
|
||||
3. **Final Results**: Returns the top-k memories with improved relevance ordering
|
||||
|
||||
## Benefits
|
||||
|
||||
- **Improved Precision**: Better ranking of relevant memories
|
||||
- **Context Awareness**: More sophisticated understanding of query-memory relationships
|
||||
- **Performance**: Can improve results without changing the underlying vector store
|
||||
|
||||
## Supported Rerankers
|
||||
|
||||
Mem0 supports several reranker models:
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Cohere" href="/components/rerankers/models/cohere" />
|
||||
<Card title="Sentence Transformer" href="/components/rerankers/models/sentence_transformer" />
|
||||
<Card title="Hugging Face" href="/components/rerankers/models/huggingface" />
|
||||
<Card title="LLM Reranker" href="/components/rerankers/models/llm_reranker" />
|
||||
</CardGroup>
|
||||
Mem0 includes built-in support for various reranking providers to improve the relevance of memory search results. Rerankers post-process initial vector search results by re-scoring and re-ordering them using more sophisticated relevance models.
|
||||
|
||||
## Usage
|
||||
|
||||
Rerankers are configured as part of the memory configuration:
|
||||
To use a reranker:
|
||||
|
||||
1. **Configure**: Add a `rerank` configuration section in your memory config
|
||||
2. **Search**: Reranking is automatically enabled for all searches (default: `rerank=True`)
|
||||
|
||||
If no reranker is configured, search results will rely on vector similarity scoring alone.
|
||||
|
||||
For comprehensive configuration parameters for each reranker, please refer to [Config](./config).
|
||||
|
||||
### Controlling Reranking Per Search
|
||||
|
||||
Once configured, reranking is enabled by default. You can control it per-search:
|
||||
|
||||
```python
|
||||
from mem0 import Memory
|
||||
# Reranking enabled (default)
|
||||
results = memory.search("query", user_id="user1")
|
||||
|
||||
config = {
|
||||
"reranker": {
|
||||
"provider": "cohere",
|
||||
"config": {
|
||||
"api_key": "your-api-key",
|
||||
"top_n": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
# Explicitly enable reranking
|
||||
results = memory.search("query", user_id="user1", rerank=True)
|
||||
|
||||
memory = Memory.from_config(config)
|
||||
# Disable reranking for this specific search
|
||||
results = memory.search("query", user_id="user1", rerank=False)
|
||||
```
|
||||
|
||||
For detailed configuration options, see the [Config](./config) page.
|
||||
## How Reranking Works
|
||||
|
||||
1. **Initial Search**: Vector similarity search retrieves candidate memories
|
||||
2. **Reranking** (if enabled): Selected reranker re-scores candidates using advanced models
|
||||
3. **Final Results**: Re-ordered results with both vector and rerank scores
|
||||
|
||||
<Note>
|
||||
Reranking operates as a post-processing step and can significantly improve search relevance at the cost of additional latency and API calls.
|
||||
</Note>
|
||||
|
||||
## Supported Rerankers
|
||||
|
||||
See the list of supported rerankers below.
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Zero Entropy" href="/components/rerankers/models/zero_entropy" />
|
||||
<Card title="Cohere" href="/components/rerankers/models/cohere" />
|
||||
<Card title="Sentence Transformer" href="/components/rerankers/models/sentence_transformer" />
|
||||
<Card title="Hugging Face" href="/components/rerankers/models/huggingface" />
|
||||
<Card title="LLM-based" href="/components/rerankers/models/llm" />
|
||||
<Card title="LLM Reranker" href="/components/rerankers/models/llm_reranker" />
|
||||
</CardGroup>
|
||||
|
||||
## When to Use Reranking
|
||||
|
||||
- **Improved Relevance**: When vector search alone doesn't provide sufficiently relevant results
|
||||
- **Domain-Specific Queries**: For specialized terminology or context that benefits from advanced models
|
||||
- **Quality vs Speed Trade-off**: When you can accept higher latency for better search quality
|
||||
- **Production Systems**: Where search quality directly impacts user experience
|
||||
|
||||
Choose the reranker that best fits your use case:
|
||||
- **Zero Entropy**: Best balance of speed and quality for general use
|
||||
- **Cohere**: Enterprise-grade with excellent multilingual support
|
||||
- **Sentence Transformer**: Local deployment for privacy-sensitive applications
|
||||
- **Hugging Face**: Wide variety of pre-trained models for specialized use cases
|
||||
- **LLM-based**: Maximum customization with custom prompts and logic
|
||||
|
||||
Reference in New Issue
Block a user