An embedding model swap is an index rebuild while customers search
Mixing vectors from two models sends results to the wrong region, so this six-step laptop rehearsal ends with a rollback command that has actually been tested.
In brief
- Vectors from two models cannot be mixed, so the whole corpus must be re-embedded into a separate index.
- Dual writes keep the new index current, and an insert-only backfill never overwrites a newer record.
- Measure recall per query group before and during the alias swap, because a query embedded with the wrong model raises no error.
Mix vectors from two embedding models in one ANN index and, Zilliz warns, part of what the search returns lands in entirely the wrong region. The practical fix is to re-embed into a separate column or collection.
Switching models looks like a one-line config change. In practice, the whole index is being rebuilt while the client’s users keep typing queries into it.
Say the client wants to move to a new model but cannot switch search off while you work. By the end of the rehearsal below, you will have a process you can take to that client, along with a rollback command you have actually tested.
What you will build on a laptop
A small rehearsal on the public BEIR SciFact dataset, with 300 queries and about 5K documents. Alongside it run two scripts that never stop: one sends queries, the other edits and deletes documents, to mimic a system with live users.
Get the download link for scifact.zip from the BEIR wiki, then set up the environment:
unzip scifact.zip
pip install qdrant-client sentence-transformers
docker run -p 6333:6333 qdrant/qdrant
Check: compare the md5 of the downloaded file with the value on the wiki. The original SciFact data is licensed CC BY-NC, which is fine for a rehearsal, but check the license if you plan any commercial use.
Use all-MiniLM-L6-v2 as the old model and BAAI/bge-small-en-v1.5 as the new one, wrapped in two functions of your own, embed_old and embed_new, that return a list of numbers. This choice is for the rehearsal only, and do not assume either model is better: step 4 answers that question.
Also prepare a golden set: questions paired with their correct documents, split into groups of at least 40 questions each. Start from SciFact’s 300 queries, check the labels in the download, then set your own rule for splitting, for example queries that contain a number and everything else.
The reason for 40 is arithmetic. In a group of 10 questions, one miss drags recall down 10 percentage points; in a group of 40, only 2.5. This is a working threshold for the rehearsal, not a statistical standard.
The two riskiest operations, the conditional insert and the alias swap, are written as qdrant-client calls; check them against the documentation for the version you install. Blocks marked “pseudocode” are abbreviated, and their function names only show intent.
Step 1: Have the application call a stable name
An alias is a fixed name the application calls, while the collection behind it can change. If the application calls a collection name directly, change that and deploy it before you touch the model.
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333")
client.update_collection_aliases(change_aliases_operations=[
models.CreateAliasOperation(create_alias=models.CreateAlias(
collection_name="kb_v1", alias_name="kb_search"))
])
Check: the query script, now calling kb_search, still runs and returns the same results as before the alias.
Step 2: Create kb_v2 and turn on dual writes
Zilliz recommends dual-writing new data, keeping old and new side by side, and moving queries to the new index only once it has proved itself. Qdrant’s guide calls this dual-write mode: every change is written to both the old and the new collection.
This step comes before the backfill because, without dual writes, the new collection goes stale while the backfill is still running. Deletes must run against both collections too.
client.create_collection("kb_v2", vectors_config=models.VectorParams(
size=len(embed_new("x")), distance=models.Distance.COSINE))
# Pseudocode
def save_document(doc):
write(kb_v1, doc.id, embed_old(doc.text), doc.meta)
write(kb_v2, doc.id, embed_new(doc.text), doc.meta)
def delete_document(doc_id):
delete(kb_v1, doc_id)
delete(kb_v2, doc_id)
Check: edit a document, then read the record back by ID from both collections. The metadata must match, and each vector must come from the right model for its collection.
Step 3: The backfill may insert, never overwrite
A backfill walks the corpus in batches, re-embeds each record with the new model and loads it into the new index. “Upsert” is a trap at this stage, so insert only when no record with that ID exists yet.
Consider the sequence. At 10:00 the backfill reads document A, version 1. At 10:01 the client edits A and the dual write puts version 2 into kb_v2. At 10:02 an ordinary upsert writes version 1 over it, and kb_v2 silently slips back to stale data.
def insert_if_absent(collection, docs, vectors):
ids = [d.id for d in docs] # integer or UUID
found = {p.id for p in client.retrieve(
collection, ids=ids, with_payload=False)}
points = [models.PointStruct(id=d.id, vector=v, payload=d.meta)
for d, v in zip(docs, vectors) if d.id not in found]
if points:
client.upsert(collection, points=points)
# Pseudocode
for batch in scroll_corpus(batch_size=BATCH):
insert_if_absent("kb_v2", batch, [embed_new(d.text) for d in batch])
This function checks and then writes, so a small gap remains between the two calls. That is acceptable for a rehearsal; in production, find out whether your Qdrant version supports a conditional insert on the server side.
Insert-only does not save you in the opposite case. If A is deleted at 10:01, the insert at 10:02 brings A back to life, because the ID is no longer in kb_v2. So after the backfill, reconcile the ID sets of both collections against the source data.
Check: the ID sets match, and a document edited during the backfill carries its latest version.
Step 4: Measure retrieval, not the answers
Qdrant’s guide warns that a new model is not automatically better on your data, so measure before shifting traffic. The metric to watch, according to the tianpan.co blog, is recall@k. Query kb_v2 directly with embed_new while the alias still points to kb_v1, so users are unaffected.
Here is a hypothetical client with 200 questions, each with one correct document. The old model finds the right document in the top 5 for 168 questions, a recall@5 of 84%. The new model gets 176, or 88%, so at a glance the new model wins.
Now split by group. Of the 40 questions containing product codes, the old model gets 34 right and the new one only 28, a fall from 85% to 70%. The overall gain comes from the other 160 questions, which rise from 134 to 148 correct.
If product-code lookups are what the client’s support team does all day, 88% is a misleading number. Always report by group, and agree with the client beforehand on the threshold that allows the switch.
Check: you have a per-group recall@k table for both models that a single command can reproduce.
Step 5: Swap the alias and the query model together
In Qdrant, deleting and recreating an alias in the same request makes the swap atomic. But OneUptime notes that this only changes the target in the database; it does not deploy the application’s model.
def swap_alias(alias, target):
client.update_collection_aliases(change_aliases_operations=[
models.DeleteAliasOperation(
delete_alias=models.DeleteAlias(alias_name=alias)),
models.CreateAliasOperation(create_alias=models.CreateAlias(
collection_name=target, alias_name=alias)),
])
swap_alias("kb_search", "kb_v2")
set_query_model("new") # pseudocode: application config flag
In the gap between those last two lines, queries embedded with the old model can reach the new index. Your script will see no error: the tianpan.co blog observes that cosine scores are still computed, they are just meaningless, and Voyage AI’s documentation on MongoDB likewise warns that retrieval quality degrades when comparing across two different models.
Print len(embed_old("x")) and len(embed_new("x")). If the two numbers are equal, the database has no reason to reject a query from the wrong model, and only recall will expose the problem.
# Pseudocode: runs throughout the swap, sampling the golden set each round
while swapping:
hits = [g.doc_id in search("kb_search", embed_current(g.q), k=5)
for g in sample(golden, 20)]
log(now(), current_model(), sum(hits) / len(hits))
On the laptop, deliberately insert a 30-second wait between the two swap lines and watch how recall drops. In production, a drop like that is the signal you need to catch. When doing it for real, pick a low-traffic window and warn the client in advance.
Check: the query script shows no errors, and the logged recall after the swap returns to kb_v2’s level from step 4. The absence of errors on its own proves nothing.
When does the way back disappear?
The alias swap is not the point of no return. As long as kb_v1 still receives dual writes, rolling back is just flipping the alias and reverting the query model, and Weaviate’s documentation also treats pointing an alias back to the previous collection as a simple operation.
The hard moment is when dual writes stop. Qdrant notes that rolling back after that point means losing every later change, because the old collection no longer receives updates. Once kb_v1 is deleted, there is no old index to return to.
Step 6: Rehearse the rollback, then clean up
According to OneUptime, a rollback has two parts and should be rehearsed before production. On the laptop, roll back once while both scripts keep running, then switch to kb_v2 again.
# Skip either line and the models are mismatched
swap_alias("kb_search", "kb_v1")
set_query_model("old") # pseudocode
After the final switch, the tianpan.co blog recommends keeping the old index for a fallback period, and dual writes should run throughout that period too. Voyage AI’s documentation likewise advises keeping the old field and index until the migration is complete.
Check: edit a document after the switch, roll back, and find that new version in kb_v1. The logged recall should return to the old model’s level from step 4.
The costliest mistakes look harmless
The first is treating dual writes as a side job: one side fails silently and the two indexes drift apart without anyone noticing. Send failed writes to a retry queue, and reconcile IDs again before swapping the alias.
The second is rolling back only one of the pair, the query model or the alias. The third is judging a model by a few polished LLM answers in a demo.
What to ask the client before re-embedding
Ask whether the application calls through an alias, who owns the data write path, and who can label real questions. Dual writes change the write path itself, so if another team owns it, bring them in from the start.
If the client cannot accept even the brief mismatch window in step 5, consider having each request read a single config record holding both the collection and the model. That record then becomes the only switch, replacing the alias.
Next, settle three things in writing: the recall threshold for each group, how long the old index is kept, and who has authority to order a rollback. These decisions belong to the client; your job is to raise them before anything goes wrong.
For your career, this makes a sharp line on a CV if you have real numbers: how many documents were migrated, how per-group recall changed, whether the service was interrupted, and whether the rollback was rehearsed.
When a job description mentions RAG, ask the interviewer how their last model change went; the answer will tell you whether the team runs production or has stopped at the demo.
If every step goes well, the client’s users will not notice the model has changed. What the client keeps is the recall table and a rollback command that has been tested for real, and with those, the next model change is no longer a tense negotiation.
Was this article useful?
Thanks for the feedback!
7 sources
- How do you change your embedding model without re-indexing everything? · 2026-06-26
- Migrate to a New Embedding Model with Zero Downtime in Qdrant
- Retiring an Embedding Model: Re-indexing Millions of Vectors Without Taking Search Down · 2026-07-05
- Zero-downtime collection migration with aliases | Weaviate Documentation
- How to Change a Qdrant Embedding Dimension with a New Collection and Alias Swap · 2026-08-28
- Migrate to a New Embedding Model - Voyage AI by MongoDB - MongoDB Docs
- Datasets available (BEIR wiki)