Skip to main content

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

pip install zeroentropy

Configuration

Python
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

Python
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

ParameterDescriptionTypeDefault
modelModel to use: "zerank-1" or "zerank-1-small"str"zerank-1"
api_keyZero Entropy API keystrNone
top_kMaximum documents to return after rerankingintNone

Performance

  • Fast: Optimized neural architecture for low latency
  • Accurate: State-of-the-art relevance scoring
  • Cost-effective: ~$0.025/1M tokens processed

Best Practices

  1. Model Selection: Use zerank-1 for best quality, zerank-1-small for faster processing
  2. Batch Size: Process multiple queries together when possible
  3. Top-k Limiting: Set reasonable top_k values (5-20) for best performance
  4. API Key Management: Use environment variables for secure key storage