Migration
Don't migrate blind. RAGForge shadow-indexes a new embedding model, validates quality overlap against the old one on your real chunks, backs up the old index, and only then cuts over. Source: migrator.py.
Step by step
- Load existing KB — read chunks from
~/.ragforge/knowledge_bases/<name>/vectors.json. - Re-embed with the new model —
new_embedder.encode(texts)on every chunk. - Build shadow index — new
InMemoryStorewith the new vectors. Old store untouched. - Validate (if
validate=True) — pick the first chunk's text as a probe, embed with both old and new model, compare top-3 results for overlap.quality_after = overlap_ratio. - Backup old store — copy
vectors.jsontovectors_backup.json. - Atomic cutover — save the new store over
vectors.json. - Update metadata — write
embedder_name,migrated_from, andembedder_dimtometa.json.
Python
python
from ragforge.migration import migrate_knowledge_base
result = migrate_knowledge_base(
knowledge="my-kb",
from_model="default",
to_model="openai",
validate=True,
)
print(result)
# {'knowledge': 'my-kb', 'from_model': 'default', 'to_model': 'openai',
# 'status': 'migrated', 'quality_before': 1.0, 'quality_after': 0.9667,
# 'num_chunks_migrated': 87}HTTP API
bash
curl -X POST http://localhost:8000/migrate \
-H "Content-Type: application/json" \
-d '{
"knowledge": "my-kb",
"from_model": "default",
"to_model": "openai",
"run_validation": true
}'The response includes quality_before, quality_after, and num_chunks_migrated. The previous index stays on disk as vectors_backup.json so you can roll back manually if needed.