Scrivio Interview library
DebuggingIntermediate7 min read · updated 12 November 2026

Retrieval quality dropped after the team switched the embedding model to a newer one and re-ran ingestion only for new documents. Some queries now return unrelated chunks. Explain the cause and the migration plan you would use.

Vectors from different embedding models live in different spaces, so comparing a query embedded with the new model against chunks embedded with the old one gives meaningless scores, and if the dimensions differ it may not work at all. The fix is a migration: record the model and version with every index, re-embed all documents into a new index with the new model, evaluate retrieval on a labelled query set, switch reads atomically while keeping the old index for rollback, budget and rate-limit the re-embedding, and add a guard that refuses vectors from the wrong model.

Why this question is asked

This is one of the most confusing RAG incidents because nothing errors. Searches return results with normal-looking scores; they are just the wrong results for part of the corpus. Interviewers ask it to see whether we understand what an embedding really is and whether we can plan a migration that does not break production again. In this answer, we will reproduce the cause, see why scores across models mean nothing, record the model with the vectors, plan the migration step by step, budget it, and add a guard.

1A Quick Recap: What an Embedding Means

An embedding model maps text to a vector, and the model learns its own coordinate system while training. Position 17 in one model's vector might loosely relate to sentiment; in another model, position 17 means something completely different. Similar meanings are close within one model's space, but there is no shared map between two models' spaces. Comparing vectors from two models is like comparing GPS coordinates with street addresses: both describe places, but subtracting one from the other means nothing.

2Reproducing the Problem

The team switched the EmbeddingModel and re-ran ingestion only for new documents. The query is now embedded with the new model, and it is compared with a mix of old and new vectors.

Java
// Index content after the switch:
// 40,000 chunks embedded with model A (old)
// 3,000 chunks embedded with model B (new, documents added after the switch)
float[] q = newModel.embed("How do I rotate API keys?");
// cosine(q, chunk embedded by B about key rotation) 0.84 <- meaningful
// cosine(q, chunk embedded by A about key rotation) 0.21 <- meaningless: different spaces
// cosine(q, chunk embedded by A about holiday policy) 0.38 <- also meaningless, but higher
What the index held after the switch
ChunksEmbedded byQuery embedded byScore meaning
3,000 newmodel Bmodel Bmeaningful
40,000 oldmodel Amodel Bmeaningless

Notice the last two lines. The old chunk about key rotation scores lower than an old chunk about holidays, because the numbers are effectively random with respect to the new query. So for questions answered by old documents, retrieval returns unrelated chunks, exactly what users reported. New documents still work, which makes the problem look intermittent.

If the new model has a different vector length, say 1,024 instead of 1,536, the symptom is louder: inserts or searches fail with a dimension mismatch, or the team created a new column for the new size. Equal dimensions are the dangerous case, because nothing stops the mix.

3Record the Model With the Vectors

The root cause is that the index did not know which model produced each vector, so nothing could notice the mix. We fix that in two ways. Each chunk carries the embedding model name and version in its metadata, for example embedding_model = text-embed-v3. And, better, each index (a table in PgVectorStore, an index in Elasticsearch) belongs to exactly one model, with the model recorded in a small registry table or in the index name, such as docs_embed_v3. One index per model makes mixing impossible by design rather than by convention.

4The Migration Plan

We now migrate properly. First, we create a new index for the new model. Second, we re-embed every document into it with the new model, as a batch job. While that runs, the incremental ingestion pipeline writes changes to both indexes, the old one with the old model and the new one with the new model, so neither falls behind. Third, we evaluate: a labelled query set of a few hundred real questions, each with the chunks or documents that answer it, is run against both indexes and we compare recall at 5 (the share of questions whose correct document is in the top five) and answer quality. Fourth, if the new index is at least as good, we switch reads atomically, for example by changing one configuration value or a database view that points at the active index. Fifth, we keep the old index for a few weeks so that rollback is the same one-line switch, and only then drop it.

Step throughChanging the embedding model safely
  1. Create a new index for the new modeldocs_embed_v3
  2. Re-embed all documents in batchesrate-limited, resumable
  3. Dual-write incremental changesold and new index
  4. Evaluate both on labelled queriesrecall at 5, answer quality
  5. New index as good or better?
    YesSwitch reads atomicallyNoTune chunks or keep old model
  6. Keep old index for rollbackdrop after a few weeks

6 steps in order. Play them, or step through them one at a time.

The immediate fix for the incident is simpler: switch the query embedding back to the old model, which makes the 40,000 old chunks searchable again, and accept that the 3,000 new ones are searched poorly until they are re-embedded with the old model too or the migration finishes.

5Budgeting the Re-Embedding

Re-embedding costs money and time, so we estimate it before starting. With 43,000 chunks of about 400 tokens, that is 17.2 million tokens. At an illustrative price of 0.02 dollars per million tokens, the bill is under one dollar; at larger scales, say 50 million chunks, it becomes real money and days of work. The tighter limit is usually the provider's rate limit, for example tokens per minute. So the job sends batches of a few hundred chunks, waits according to the rate limit, records progress so it can resume after a failure, and runs at off-peak times so it does not steal quota from live queries.

6A Guard That Refuses the Wrong Model

Finally, we make the mistake impossible to repeat. At startup, the application compares the configured embedding model with the model recorded for the index it reads and writes. If they differ, it fails to start with a clear message. The ingestion job does the same check before writing.

Java
@Component
class EmbeddingModelGuard implements ApplicationRunner {
private final IndexRegistry registry;
private final EmbeddingProperties props;
EmbeddingModelGuard(IndexRegistry registry, EmbeddingProperties props) { this.registry = registry; this.props = props; }
@Override public void run(ApplicationArguments args) {
String indexModel = registry.modelFor(props.indexName()); // "text-embed-v2"
if (!indexModel.equals(props.model())) { // configured "text-embed-v3"
throw new IllegalStateException("Index " + props.indexName() + " holds vectors from "
+ indexModel + " but the configured embedding model is " + props.model());
}
}
}
// startup fails: Index docs holds vectors from text-embed-v2 but the configured embedding model is text-embed-v3

A failed startup in a test environment is far cheaper than weeks of quietly wrong answers in production.

7Follow-up questions

How would you measure retrieval quality before and after?

Build a labelled set of real queries, each with the document or chunk ids that answer it, ideally a few hundred covering common and rare topics. For each index, run every query and compute recall at k (is a correct chunk in the top k), and mean reciprocal rank (how high the first correct chunk appears). Add an end-to-end check on a sample of generated answers, graded by people or a rubric. Run the same set before and after every change to models, chunking or index settings, and keep it in CI.

Can we convert old vectors to the new model's space?

Not reliably. Research on mapping between embedding spaces exists, but the result is approximate, and re-embedding from the source text is simpler and exact. This is one reason to always keep the source text.

What if the new model is better only for some queries?

The evaluation will show it. We can tune chunking, adjust the threshold, which is model-specific, or keep the old model until a better candidate arrives.

8Conclusion

In this answer, we saw that vectors from different embedding models live in different spaces, so mixing them in one index makes similarity scores meaningless even when dimensions match. We recorded the model with every index, planned a migration that re-embeds all documents into a new index, dual-writes changes, evaluates on labelled queries and switches reads atomically with the old index kept for rollback, budgeted the re-embedding with rate limits, and added a guard that refuses a mismatched model.

What to say in the interviewAbout 80 seconds aloud

Open with

The cause is that embeddings from different models live in different vector spaces. After the switch, queries are embedded with the new model, but most chunks still have vectors from the old one, so the similarity scores against those chunks are essentially random, and unrelated chunks can score higher than the right ones.

Then, if they want more

New documents work, which makes it look intermittent. If the dimensions had differed, it would have failed loudly; equal dimensions let the mix happen silently. As an immediate fix I would point query embedding back to the old model.

Then I would migrate properly: record the embedding model and version for every index, ideally one table or index per model, create a new index, re-embed all documents into it as a rate-limited, resumable batch, and dual-write incremental changes to both indexes meanwhile.

I evaluate both indexes on a labelled query set, with recall at five and answer quality, switch reads atomically if the new one is at least as good, and keep the old index for rollback for a few weeks.

I would budget tokens and time beforehand, and add a startup and ingestion guard that refuses to run if the configured model differs from the index's model.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring AI reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Retrieval quality dropped after the team switched the embedding model to a newer one and...": https://scrivio-interview-library.netlify.app/spring-boot/spring-ai/a1d6ea84ab/