All posts

Embedding model migration: how to re-index a RAG system without downtime

How to plan an embedding model migration: why vectors from different models cannot be mixed, a blue-green re-indexing pattern, cost drivers and a cutover checklist.

CodeKrypt 5 min read

An embedding model feels like a one-time choice until a provider retires it, a better or cheaper one appears, or your documents turn out to need multilingual support. Then you face an embedding model migration, and discover that it is not a config change: every stored vector is tied to the model that produced it.

This post explains why, and lays out a blue-green re-indexing pattern that lets you switch models without downtime or a blind leap of faith.

Why can't you just swap the embedding model?

An embedding model maps text into its own vector space. Similarity search only means something when the query vector and the document vectors were produced by the same model. Put a query embedded by model B against documents embedded by model A and the nearest neighbours are effectively arbitrary. Even when two models happen to output the same dimension, the spaces are not aligned. When dimensions differ, your vector column or index definition will reject the data outright.

So the migration has three consequences:

If the trigger is a deprecation notice, the surrounding process matters as much as the re-index; see our LLM model deprecation migration plan.

What does the blue-green re-indexing pattern look like?

Treat the old and new indexes like two deployments. The old one ("blue") keeps serving; the new one ("green") is built beside it, evaluated, and then switched in.

Blue-green embedding migration: queries are served by the old index while a backfill builds the new index, then traffic switches over.Source documentsIndex A (old model)Index B (new model)Query routerSolid: live path. Dashed: backfill, shadow queries, then cutover.

The steps:

  1. Create the new index with the new dimension and its own name. In pgvector this can be a second column or table; in a dedicated vector database, a second collection or index.
  2. Dual-write new and changed documents to both indexes so B does not fall behind while it is being built.
  3. Backfill existing documents into B in batches, with checkpoints so a failed job resumes instead of restarting.
  4. Shadow-test: for sampled live queries, also embed with the new model, query B, and log the results next to A's without showing them to users.
  5. Cut over by switching the query router so query embedding and index choice change together.
  6. Keep A for a defined window, then delete it.

How do you decide the new model is actually better?

Do not rely on a public benchmark alone; they measure general text, not your contracts, tickets or product catalogue. Reuse the evaluation set described in our RAG chunking strategy post: 30 to 100 real questions, each paired with the passage that answers it. For each index, record whether the right passage appears in the top-k, and compare.

Check the things a headline score hides:

DimensionWhat to compareWhy it matters
Recall at your top-kOld vs new on your questionsThe only number tied to your product
Vector dimensionStorage and index sizeLarger vectors cost more to store and search
Input length limitLongest chunk the model acceptsMay change your chunking
Language coverageQueries in each language you serveWeak languages fail silently
Embedding pricePer-token cost for the backfill and for each queryQuery-time cost recurs forever
LatencyTime to embed a queryIt sits on the critical path of every answer

If you also use hybrid search and reranking, re-run the whole pipeline, not just the vector leg: a better embedding model may change how much a reranker is adding.

What does a re-index cost?

Cost has three parts, none of which needs a guess if you measure first:

Estimate from a small sample first: embed 1% of the corpus, measure tokens and wall-clock time, extrapolate. The same discipline applies to the rest of your spend, as covered in reducing LLM API costs.

What goes wrong during cutover?

How do you make the next migration cheaper?

You will do this again, so design for it now:

What to do next

Before the next provider email arrives, check three things: do you know which embedding model each index was built with, can you rebuild an index from source documents alone, and do you have a question set that tells you whether a new model is better? If any answer is no, fix that first.

If you are designing a retrieval layer for an AI product and want it to survive model changes, see how we approach AI SaaS development and get in touch.

CodeKrypt avatar

CodeKrypt

Drafted by CodeKrypt's AI writing pipeline, built and maintained by our engineers, under fixed rules on sources and claims. How we write

Frequently asked questions

Can I mix vectors from two embedding models in one index?
No. Each model defines its own vector space, so similarity scores between a query embedded by one model and documents embedded by another are not meaningful. Dimensions may also differ. Queries and documents must come from the same model.
Do I have to re-embed everything when I change embedding models?
Yes, every document you want to search with the new model. Plan the migration as a full re-index, run in the background alongside the live index.
How do I know the new embedding model is better?
Run both indexes against the same set of real questions with known answer passages and compare recall at your top-k. Leaderboard scores are a starting point, not a substitute for your own data.
How do I roll back if the new index performs worse?
Keep the old index and the old query path intact until the new one has served real traffic. Rolling back is then a configuration switch, not a rebuild.

Related reading

Chat on WhatsApp