From Mem0 to Knol: A Migration Guide
Step-by-step guide for teams migrating from Mem0 or Zep to Knol. Same API patterns, better performance, no vendor lock-in.
Why Teams Migrate to Knol
Knol was designed with migration in mind. The API patterns are familiar to Mem0 and Zep users, but the performance, flexibility, and costs are dramatically better.
**Performance**: Sub-5ms retrieval latency vs 50-200ms **Cost**: 75% reduction in LLM invocation costs **Flexibility**: Single PostgreSQL database vs multiple vendor systems **Ownership**: Open-source self-hosting vs vendor lock-in
Step 1: Export Existing Data
Both Mem0 and Zep provide export functionality. Data formats differ slightly, but both can be converted to Knol's import schema.
# Export from Mem0
mem0 export --format=jsonl > mem0_export.jsonl# Export from Zep zep export --format=jsonl > zep_export.jsonl
# Convert to Knol schema knol convert --source=mem0 mem0_export.jsonl > knol_import.jsonl ```
Step 2: Set Up Knol Infrastructure
Knol's infrastructure is minimal: one PostgreSQL instance with pgvector.
# Using Knol's Helm chart
helm repo add knol https://charts.aiknol.com
helm install knol knol/knol --namespace knol --create-namespace# Or Docker Compose for development docker-compose up -d ```
Step 3: Migrate API Calls
The migration is straightforward because Knol maintains API compatibility:
# Before (Mem0)
from mem0 import Memory
memory = Memory.from_config(config={"llm": {...}})
memory.add("User details", user_id="user_1")# After (Knol) - minimal changes from knol import KnolClient client = KnolClient(api_key="your_key") client.episodic.add("User details", user_id="user_1")
# If using LangChain, just swap the import from knol.langchain import KnolMemory memory = KnolMemory(client=client) ```
Step 4: Import Historical Data
Knol provides bulk import tools optimized for large data sets:
knol import --source=knol_import.jsonl --batch-size=1000Import happens asynchronously. You can monitor progress:
knol import status --job-id=job_123Step 5: Run Dual Writes (Optional)
For zero-downtime migration, run dual writes for a period:
# Write to both systems during migration window
client.episodic.add(text, user_id=user_id)
mem0_client.add(text, user_id=user_id) # temporary# Query from Knol, fallback to Mem0 if needed try: result = knol_client.retrieve(query, user_id=user_id) except Exception: result = mem0_client.search(query, user_id=user_id) ```
Step 6: Update LLM Extraction Pipelines
If you have custom extraction prompts, they should work unchanged in Knol. But you might want to take advantage of Knol's structured extraction:
# Knol provides extraction types for common patterns
result = client.semantic.extract(
conversation_turn=turn,
extraction_type="preferences", # Knol knows what facts to extract
user_id=user_id
)Rollback Plan
If issues arise, you have a complete snapshot of the old system. Knol's import is non-destructive — your original data still exists. You can:
1. Keep both systems running during a transition period 2. Query Knol as primary, fall back to Mem0 if needed 3. Compare retrieval results between systems 4. Gradually route 100% of traffic to Knol
Common Issues and Solutions
**Query results differ slightly**: Knol's hybrid retrieval returns different results than Mem0's pure vector approach. This is usually better, but you can adjust weights in configuration.
**LLM costs increased during import**: Bulk extraction to populate semantic memory is expensive. But day-to-day operations will be 75% cheaper.
**Authentication changes**: If you're self-hosting, you control authentication entirely. Configure your preferred auth system (OAuth, SAML, API keys) directly.
Timeline
Typical migration timeline:
- **Week 1**: Export and evaluation - **Week 2**: Infrastructure setup and small-scale testing - **Week 3**: Data import and validation - **Week 4**: Dual write and monitoring - **Week 5**: Full cutover
The process is straightforward, and our team can assist at any stage.