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.
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:
Every document must be re-embedded with the new model.
Query-time embedding must switch at exactly the moment the index does.
Until cutover, you must serve traffic from the old index.
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.
The steps:
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.
Dual-write new and changed documents to both indexes so B does not fall
behind while it is being built.
Backfill existing documents into B in batches, with checkpoints so a
failed job resumes instead of restarting.
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.
Cut over by switching the query router so query embedding and index
choice change together.
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:
Dimension
What to compare
Why it matters
Recall at your top-k
Old vs new on your questions
The only number tied to your product
Vector dimension
Storage and index size
Larger vectors cost more to store and search
Input length limit
Longest chunk the model accepts
May change your chunking
Language coverage
Queries in each language you serve
Weak languages fail silently
Embedding price
Per-token cost for the backfill and for each query
Query-time cost recurs forever
Latency
Time to embed a query
It 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:
Backfill embedding: total tokens in your corpus multiplied by the
provider's per-token price (check the current price page). Count tokens with
the new model's tokenizer; do not reuse the old count.
Temporary double storage: both indexes exist until cutover and for the
rollback window.
Engineering and compute time: rate limits on the embedding API often set
how long the backfill takes. Some providers offer a discounted batch mode
for non-urgent work, which suits a backfill; verify the terms for yours.
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?
Query and index out of sync. Embedding queries with the new model while
the router still points at A (or the reverse) returns plausible-looking but
wrong results. Store the model name and version as metadata on each index and
assert it matches at query time.
Documents updated mid-backfill. Without dual-writes, B contains stale
versions. Backfill by comparing a content hash or updated_at rather than
assuming order.
No rollback. Deleting A on cutover day removes your only safe exit.
Silent quality drift. Wire the evaluation set into CI so a later model
change is caught by a test, not a customer; see
LLM evals in CI.
How do you make the next migration cheaper?
You will do this again, so design for it now:
Record the embedding model name, version and dimension per index.
Keep the original text (or a pointer to it) next to every vector; never rely
on vectors as the only copy of your data.
Make ingestion idempotent and resumable.
Put the model choice behind one configuration value, with the index name
derived from it.
Keep the evaluation set versioned alongside the code.
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
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.
A RAG index goes stale the day after launch. How to detect changed and deleted documents, sync incrementally with content hashes, and stop retired policies from being quoted as current.
How to pick a RAG chunking strategy: fixed-size vs structure-aware splitting, chunk size and overlap trade-offs, and how to test the choice on your own documents.
Should your AI product use pgvector or a dedicated vector database? The real decision points: scale, filtering, operations and migration cost, with limits taken from the pgvector docs.