Documentation Index
Fetch the complete documentation index at: https://docs.mem0.ai/llms.txt
Use this file to discover all available pages before exploring further.
Zero Entropy provides neural reranking models that significantly improve search relevance with fast performance.
Models
Zero Entropy offers two reranking models:
zerank-1: Flagship state-of-the-art reranker (non-commercial license)
zerank-1-small: Open-source model (Apache 2.0 license)
Installation
Configuration
from mem0 import Memory
config = {
"vector_store": {
"provider": "chroma",
"config": {
"collection_name": "my_memories",
"path": "./chroma_db"
}
},
"llm": {
"provider": "openai",
"config": {
"model": "gpt-4o-mini"
}
},
"rerank": {
"provider": "zero_entropy",
"config": {
"model": "zerank-1", # or "zerank-1-small"
"api_key": "your-zero-entropy-api-key", # or set ZERO_ENTROPY_API_KEY
"top_k": 5
}
}
}
memory = Memory.from_config(config)
Environment Variables
Set your API key as an environment variable:
export ZERO_ENTROPY_API_KEY="your-api-key"
Usage Example
import os
from mem0 import Memory
# Set API key
os.environ["ZERO_ENTROPY_API_KEY"] = "your-api-key"
# Initialize memory with Zero Entropy reranker
config = {
"vector_store": {"provider": "chroma"},
"llm": {"provider": "openai", "config": {"model": "gpt-4o-mini"}},
"rerank": {"provider": "zero_entropy", "config": {"model": "zerank-1"}}
}
memory = Memory.from_config(config)
# Add memories
messages = [
{"role": "user", "content": "I love Italian pasta, especially carbonara"},
{"role": "user", "content": "Japanese sushi is also amazing"},
{"role": "user", "content": "I enjoy cooking Mediterranean dishes"}
]
memory.add(messages, user_id="alice")
# Search with reranking
results = memory.search("What Italian food does the user like?", filters={"user_id": "alice"})
for result in results['results']:
print(f"Memory: {result['memory']}")
print(f"Vector Score: {result['score']:.3f}")
print(f"Rerank Score: {result['rerank_score']:.3f}")
print()
Configuration Parameters
| Parameter | Description | Type | Default |
|---|
model | Model to use: "zerank-1" or "zerank-1-small" | str | "zerank-1" |
api_key | Zero Entropy API key | str | None |
top_k | Maximum documents to return after reranking | int | None |
- Fast: Optimized neural architecture for low latency
- Accurate: State-of-the-art relevance scoring
- Cost-effective: ~$0.025/1M tokens processed
Best Practices
- Model Selection: Use
zerank-1 for best quality, zerank-1-small for faster processing
- Batch Size: Process multiple queries together when possible
- Top-k Limiting: Set reasonable
top_k values (5-20) for best performance
- API Key Management: Use environment variables for secure key storage