Chroma Vector Database - Hybrid Semantic Search
Overview
Claude-Mem v5.0.0 introduced Chroma, a vector database that enables semantic search across your memory stream. Combined with SQLite’s FTS5 keyword search, this creates a powerful hybrid search architecture that finds contextually relevant observations using both meaning and keywords. Key Benefits:- 🧠 Semantic Search - Find observations by meaning, not just keywords
- 🔍 Hybrid Architecture - Combines semantic similarity with keyword matching
- ⏱️ Recency Filtering - Focus on recent 90 days for relevant context
- ⚡ Fast Performance - Semantic search under 200ms with 8,000+ documents
- 🔄 Auto-Sync - ChromaSync service keeps vectors updated automatically
What is Chroma?
ChromaDB is an open-source vector database designed for AI applications. It stores text as vector embeddings - mathematical representations that capture semantic meaning. Example:Architecture
Hybrid Search Flow
ChromaSync Service
The ChromaSync service (src/services/sync/ChromaSync.ts) automatically synchronizes observations to Chroma:
When Observations Are Synced:
- Session Summary - After each session completes, all new observations synced
- Worker Startup - On initialization, checks for unsynced observations
- Manual Trigger - Can force sync via internal API (development only)
- Observation ID (unique identifier)
- Title (compressed learning statement)
- Narrative (detailed explanation)
- Project path (for project-specific filtering)
- Timestamp (for recency filtering)
- Concepts (semantic tags)
- File references (associated code files)
- Currently using Chroma’s default embedding function
- Future: Configurable embedding models (e.g., OpenAI, sentence-transformers)
Data Structure
SQLite (Source of Truth):How Semantic Search Works
Vector Embeddings
Text converted to high-dimensional vectors that capture meaning:Similarity Search
Chroma uses cosine similarity to find nearest neighbors:- Higher cosine similarity = more semantically similar
- Filtered by 90-day recency window
- Combined with keyword matches from FTS5
90-Day Recency Filtering
Why 90 days? Rationale:- Recent context more likely relevant to current work
- Prevents very old observations from diluting results
- Balances completeness with relevance
- Reduces vector search space for faster queries
- Not currently user-configurable
- Hard-coded in
src/servers/search-server.ts - Future: Add
CLAUDE_MEM_RECENCY_DAYSenvironment variable
MCP Tool Integration
All 9 MCP search tools benefit from hybrid search:search_observations (Hybrid)
get_timeline_by_query (Semantic-First)
Benefits Across All Tools
- find_by_concept: Semantic similarity finds related concepts
- find_by_file: Finds semantically similar code changes
- find_by_type: Better relevance ranking within type
- get_recent_context: Prioritizes semantically relevant recent context
Performance
Benchmarks (8,279 vector documents)
| Operation | Time | Notes |
|---|---|---|
| Semantic Query | 150-200ms | 90-day window, top 10 results |
| Keyword Query (FTS5) | 5-10ms | Full-text search |
| Hybrid Query | 160-220ms | Combined semantic + keyword |
| Initial Sync | 2-5 min | First-time embedding of all observations |
| Incremental Sync | 100-500ms | 1-10 new observations per session |
Memory Usage
- Chroma DB Size: ~50MB for 8,000 observations
- Embeddings: 384 dimensions × 4 bytes = 1.5KB per observation
- Metadata: ~500 bytes per observation (project, type, timestamp)
- Total: ~2KB per observation in Chroma
Optimization Tips
- Reduce vector dimensions: Use smaller embedding models (future)
- Adjust recency window: Narrow to 30/60 days for faster queries
- Limit result count: Request fewer results (n_results=5 vs 10)
- Project filtering: Add project filter to metadata query
Installation & Dependencies
Python Requirement
Chroma requires Python 3.7+ installed: Check Python:- macOS:
brew install python3 - Windows: Download from python.org
- Linux:
apt-get install python3oryum install python3
ChromaDB Installation
Chroma installed automatically as npm dependency:Troubleshooting Installation
Error: “Python not found”Configuration
Environment Variables
Currently no user-configurable settings. Future options:Disabling Chroma (Future)
To disable semantic search and use keyword-only:Database Maintenance
Location
Backup
Reset Chroma (Force Resync)
Disk Space Management
Chroma grows with observations:- 1,000 observations ≈ 5MB
- 10,000 observations ≈ 50MB
- 100,000 observations ≈ 500MB
Advanced Usage
Direct Chroma Queries (Development)
For debugging or custom queries:Custom Embedding Models (Future)
Chroma supports multiple embedding models:Metadata Filtering
Chroma supports advanced metadata queries:Comparison: Semantic vs Keyword Search
| Aspect | Semantic (Chroma) | Keyword (FTS5) |
|---|---|---|
| Speed | 150-200ms | 5-10ms |
| Accuracy | High (meaning-based) | Medium (exact match) |
| Storage | ~2KB per observation | ~500 bytes per observation |
| Conceptual Matching | ✅ Yes | ❌ No |
| Exact Match | ❌ Not guaranteed | ✅ Always |
| Typo Tolerance | ✅ High | ⚠️ Limited (fuzzy) |
| Dependencies | Python + chromadb | None (SQLite built-in) |
| Recency Bias | ✅ Built-in (90 days) | Manual filtering |
Troubleshooting
”Chroma not found” Error
Symptom: Worker logs show “Chroma not available, using keyword-only search” Solution:Slow Query Performance
Symptom: Searches taking >1 second Solutions:- Reduce recency window (edit
src/servers/search-server.ts) - Limit result count (
nResults: 5instead of 10) - Add project filter to narrow search space
- Check Chroma index size (may need rebuild)
Out of Memory Errors
Symptom: Worker crashes with “JavaScript heap out of memory” Solution:Sync Taking Too Long
Symptom: Initial Chroma sync takes >10 minutes Possible Causes:- Large number of observations (>10,000)
- Slow embedding model
- Limited CPU resources
- Let it complete (one-time cost)
- Delete very old observations to reduce count
- Close resource-intensive apps during sync
Future Enhancements
Potential improvements for future versions:- Configurable Recency: User-defined recency window (30/60/90/365 days)
- Custom Embeddings: Choose embedding model (quality vs speed trade-off)
- Incremental Updates: Update existing vectors instead of full resync
- Semantic Filters: Search by semantic concept (“all architectural decisions”)
- Multi-Language Support: Embeddings optimized for non-English code/docs
- Clustering: Auto-cluster related observations for discovery
- Visualization: 2D/3D visualization of vector space (similar observations near each other)
Resources
- ChromaDB Documentation: https://docs.trychroma.com/
- Source Code:
src/services/sync/ChromaSync.ts - Search Server:
src/servers/search-server.ts - Python Package: https://pypi.org/project/chromadb/
Powered by ChromaDB | Hybrid Semantic + Keyword Search | 90-Day Recency Window

