Nothing threw an error. Latency was flat, the vector store reported healthy, and every query returned ten results with plausible similarity scores. But the answers had gotten worse, and nobody could say when. That is what embeddings drift looks like in production: a retrieval system that degrades without ever failing, because the failure is geometric, not exceptional.
This is a write-up of how we mixed vectors from two embedding model versions in a single RAG index, how we found out, and the reindex strategy we now use so it can't happen again. It's a mistake that's easy to make and hard to see, and the AI integration work we do touches it often enough that it's worth documenting plainly.
What actually went wrong with our embeddings
The setup was ordinary. Documents were chunked, embedded, and upserted into a single collection. Queries were embedded at request time and matched by cosine similarity. The embedding model was referenced by a floating alias in config, something like embedding-model-latest, rather than a pinned version string.
The provider shipped a new model version behind that alias. From that moment, two things were true at once:
- Every query was embedded with the new model.
- Roughly all existing documents were still embedded with the old one. New and re-ingested documents were embedded with the new one.
The index now held vectors from two different spaces. This is the core problem. Two embedding models, or two versions of the same model, do not share a coordinate system. Dimensions may even match, which is why the store accepted the writes without complaint. But dimension 17 in one version means nothing comparable to dimension 17 in the other. Cosine similarity between a new-space query and an old-space document is a number, and it is a perfectly valid number, but it is not a measure of semantic closeness.
The result was a skewed ranking. New-space queries scored higher against new-space documents simply because they shared a space, so freshly ingested content outranked older content that was actually more relevant. Old documents did not vanish; they just sank, unevenly, in ways that depended on how the two spaces happened to align for a given query.
Why nothing alerted
We had monitoring. It watched error rate, p95 latency, and index size. All three stayed green, because retrieval quality isn't any of them. A vector search has no concept of a wrong answer; it returns nearest neighbours by definition, and when the space is inconsistent it returns the nearest of the wrong things with the same confidence.
We caught it indirectly. A user-facing answer cited a recently added document where an older, authoritative one should have won. Pulling the thread, we ran a small fixed set of queries with known-correct source documents and checked where the right chunk landed. Recall at 10 on that set had visibly dropped compared to a snapshot from before the bump. We won't quote a figure here, because the honest summary is that it was a regression large enough to notice on a hand-built eval set and small enough to hide in aggregate user feedback for a while.
The lesson for anyone doing backend development around LLM features: retrieval needs its own regression test, separate from the generation step. If your only signal is whether the final answer reads well, you will attribute retrieval problems to the prompt and spend a week tuning the wrong layer.
The fix: versioned collections and a blue/green reindex
The rule we now follow is that a collection is bound to exactly one embedding model version, and that binding is part of its name and its metadata. Vectors from different versions never share a collection.
The shape of it
- Pin the model. Config holds an exact model identifier, never an alias. Upgrading is a deliberate commit, reviewed like a schema migration.
- Name collections by version. For example
docs__emb_v1anddocs__emb_v2. The version string comes from the same constant the embedding client uses, so the two can't disagree. - Stamp every record. Each stored chunk carries
embedding_modeland a content hash in its payload. This makes audits trivial: a single query tells you whether anything in a collection doesn't match its expected version. - Reindex into a new collection. A background job re-embeds the full corpus into
docs__emb_v2while production keeps reading fromv1. Dual-write new documents to both during the migration window. - Evaluate before cutover. Run the fixed query set against both collections and compare recall. Switching is a config flip of the read pointer, not a data operation.
- Keep the old collection for a rollback window, then delete it.
The query path embeds with the model version that the target collection declares, not with whatever the latest default is. That one rule closes the original hole: it is structurally impossible to compare a query vector against documents from a different space, because the collection tells the client which model to use.
Trade-offs we accepted
This costs real money and time: a full reindex means re-embedding the whole corpus, and for a large one that's a non-trivial API bill and a job that needs to be resumable. We checkpoint by content hash so a crashed run picks up where it stopped. Storage doubles briefly during migration. Dual-writing adds a code path that has to be removed afterward, and we track that cleanup explicitly so it doesn't become permanent technical debt.
We also considered in-place upgrade by re-embedding documents lazily as they're touched. We rejected it, because it leaves the index in precisely the mixed state that caused the problem, for an indefinite period.
A short checklist
- Pin embedding model versions; treat a bump as a migration.
- One collection, one model version. Encode it in the name.
- Store the model identifier on every record.
- Keep a small labelled retrieval eval and run it on every index change.
- Alert on retrieval quality, not just latency and errors.
At orithLabs, this is the kind of failure we look for when auditing existing AI features and the architecture around them: silent degradation, floating dependencies, and missing evals tend to travel together. If you're running a RAG system and aren't sure whether your index is internally consistent, a code audit of the ingestion and query paths is usually a short exercise, and you'd be talking directly to the engineers who do it.