repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | --- |
| #2 | title: Zero Entropy |
| #3 | description: 'Neural reranking with Zero Entropy' |
| #4 | --- |
| #5 | |
| #6 | [Zero Entropy](https://www.zeroentropy.dev) provides neural reranking models that significantly improve search relevance with fast performance. |
| #7 | |
| #8 | ## Models |
| #9 | |
| #10 | Zero Entropy offers two reranking models: |
| #11 | |
| #12 | - **`zerank-1`**: Flagship state-of-the-art reranker (non-commercial license) |
| #13 | - **`zerank-1-small`**: Open-source model (Apache 2.0 license) |
| #14 | |
| #15 | ## Installation |
| #16 | |
| #17 | ```bash |
| #18 | pip install zeroentropy |
| #19 | ``` |
| #20 | |
| #21 | ## Configuration |
| #22 | |
| #23 | ```python Python |
| #24 | from mem0 import Memory |
| #25 | |
| #26 | config = { |
| #27 | "vector_store": { |
| #28 | "provider": "chroma", |
| #29 | "config": { |
| #30 | "collection_name": "my_memories", |
| #31 | "path": "./chroma_db" |
| #32 | } |
| #33 | }, |
| #34 | "llm": { |
| #35 | "provider": "openai", |
| #36 | "config": { |
| #37 | "model": "gpt-4o-mini" |
| #38 | } |
| #39 | }, |
| #40 | "rerank": { |
| #41 | "provider": "zero_entropy", |
| #42 | "config": { |
| #43 | "model": "zerank-1", # or "zerank-1-small" |
| #44 | "api_key": "your-zero-entropy-api-key", # or set ZERO_ENTROPY_API_KEY |
| #45 | "top_k": 5 |
| #46 | } |
| #47 | } |
| #48 | } |
| #49 | |
| #50 | memory = Memory.from_config(config) |
| #51 | ``` |
| #52 | |
| #53 | ## Environment Variables |
| #54 | |
| #55 | Set your API key as an environment variable: |
| #56 | |
| #57 | ```bash |
| #58 | export ZERO_ENTROPY_API_KEY="your-api-key" |
| #59 | ``` |
| #60 | |
| #61 | ## Usage Example |
| #62 | |
| #63 | ```python Python |
| #64 | import os |
| #65 | from mem0 import Memory |
| #66 | |
| #67 | # Set API key |
| #68 | os.environ["ZERO_ENTROPY_API_KEY"] = "your-api-key" |
| #69 | |
| #70 | # Initialize memory with Zero Entropy reranker |
| #71 | config = { |
| #72 | "vector_store": {"provider": "chroma"}, |
| #73 | "llm": {"provider": "openai", "config": {"model": "gpt-4o-mini"}}, |
| #74 | "rerank": {"provider": "zero_entropy", "config": {"model": "zerank-1"}} |
| #75 | } |
| #76 | |
| #77 | memory = Memory.from_config(config) |
| #78 | |
| #79 | # Add memories |
| #80 | messages = [ |
| #81 | {"role": "user", "content": "I love Italian pasta, especially carbonara"}, |
| #82 | {"role": "user", "content": "Japanese sushi is also amazing"}, |
| #83 | {"role": "user", "content": "I enjoy cooking Mediterranean dishes"} |
| #84 | ] |
| #85 | |
| #86 | memory.add(messages, user_id="alice") |
| #87 | |
| #88 | # Search with reranking |
| #89 | results = memory.search("What Italian food does the user like?", user_id="alice") |
| #90 | |
| #91 | for result in results['results']: |
| #92 | print(f"Memory: {result['memory']}") |
| #93 | print(f"Vector Score: {result['score']:.3f}") |
| #94 | print(f"Rerank Score: {result['rerank_score']:.3f}") |
| #95 | print() |
| #96 | ``` |
| #97 | |
| #98 | ## Configuration Parameters |
| #99 | |
| #100 | | Parameter | Description | Type | Default | |
| #101 | |-----------|-------------|------|---------| |
| #102 | | `model` | Model to use: `"zerank-1"` or `"zerank-1-small"` | `str` | `"zerank-1"` | |
| #103 | | `api_key` | Zero Entropy API key | `str` | `None` | |
| #104 | | `top_k` | Maximum documents to return after reranking | `int` | `None` | |
| #105 | |
| #106 | ## Performance |
| #107 | |
| #108 | - **Fast**: Optimized neural architecture for low latency |
| #109 | - **Accurate**: State-of-the-art relevance scoring |
| #110 | - **Cost-effective**: ~$0.025/1M tokens processed |
| #111 | |
| #112 | ## Best Practices |
| #113 | |
| #114 | 1. **Model Selection**: Use `zerank-1` for best quality, `zerank-1-small` for faster processing |
| #115 | 2. **Batch Size**: Process multiple queries together when possible |
| #116 | 3. **Top-k Limiting**: Set reasonable `top_k` values (5-20) for best performance |
| #117 | 4. **API Key Management**: Use environment variables for secure key storage |