swap-embeddings
Change the embedding model used to index and search documents (OpenAI, Cohere, Voyage, a local server). Use when the user decides on a different or cheaper embedding model, or asks about vector dimens
SKILL.md.claude/skills/swap-embeddings/SKILL.md
GitHubSwap the embedding model
- Interface:
Embedder(name,min_score,embed(texts)) inapps/ai/app/embeddings.py. - Today:
HashingEmbedderlocally (lexical, no model; refused in production) andProviderEmbedderfor any Pydantic AI embedding model, asked forEMBEDDING_DIMENSIONS(1536,apps/ai/app/db/models.py).create_embedderpicks one. - Env:
AI_EMBEDDINGS(hashingor a model name such asopenai:text-embedding-3-small),AI_MIN_RELEVANCE(cosine floor), and the provider's key (e.g.OPENAI_API_KEY).
Swap
- Same dimension (1536): set
AI_EMBEDDINGSand the key, then re-index every document (vectors from different models aren't comparable; documents keep their text). - A different dimension: a migration changing
ai.chunk's vector column and its HNSW index (db-change skill),EMBEDDING_DIMENSIONSinapps/ai/app/db/models.py, and a re-index. - A model Pydantic AI can't reach: a class with the
Embeddershape, chosen increate_embedder. - Calibrate
AI_MIN_RELEVANCEfor the new model withbun run --cwd apps/ai evals.
Tests
apps/ai/tests/test_units.py (embedders), apps/ai/tests/test_service.py (indexing and
retrieval against Postgres), apps/ai/tests/test_models_match_db.py after a migration.
Finish
- The verify skill.
- Ask the
revieweragent to review the change, and thesecurity-revieweragent: a new implementation brings its own credentials and sends data somewhere new. If you wrote a migration, themigration-revieweragent too. The change is in apps/ai, so thepython-revieweragent as well. - Update the seam's row in the README's "Scaling path" table if what's "Now" changed.