RAG Versioning — How to Track Documents, Embeddings and Prompts

RAG Versioning — How to Track Documents, Embeddings and Prompts

RAG versioning is the practice of recording the exact version of every component that produced an answer — the documents, the chunks, the embeddings, the retrieval settings, the model and the prompt — so that any past answer can be reproduced and explained. A RAG system changes constantly: documents are updated, models are swapped, prompts are tweaked and chunking strategies evolve. Without versioning, each change quietly rewrites history, and nobody can say why last month’s answers differ from this month’s. So how do you version a system with so many moving parts? You version each part separately, you record which versions combined to produce each answer, and you keep old versions retrievable for as long as their answers matter.

Versioning is often confused with backup. A backup lets you restore a system after a failure. Versioning lets you understand a system after a change. Both matter, but only versioning answers the question an auditor or a frustrated user actually asks: what was different when this answer was produced?

Key takeaways

  • Version documents, chunks, embeddings, retrieval settings, models and prompts — each changes on its own schedule.
  • Record the combination of versions behind every answer, not just the version of each part.
  • Make chunk identifiers deterministic so re-indexing does not break the link to past answers.
  • Keep old index versions available for comparison until their answers no longer matter.
  • Versioning is what makes rollbacks safe, regression tests meaningful and audits possible.

What needs versioning in a RAG system

A RAG answer is the product of at least six components, and each one changes independently. Documents change when authors edit them. Chunks change when the chunking strategy changes. Embeddings change when the embedding model changes. Retrieval settings change when someone tunes the number of results or the ranking weights. The language model changes when a new version is deployed. The prompt changes whenever anyone edits the instructions. Any one of these can alter an answer, and several usually change at once.

The practical consequence is that versioning a RAG system means versioning a pipeline, not a file. A document version on its own tells you little if you do not know which embedding model turned it into vectors or which prompt turned the retrieved chunks into prose. The unit that matters is the configuration: the set of component versions that were live at the moment an answer was generated.

That sounds heavy, and it can be. The trick is to record versions automatically at the points where they are decided — ingestion, indexing, deployment and query time — rather than asking people to maintain version records by hand. Manual version tracking fails the same way manual testing fails: it works until the team is busy, and then it stops.

Document and chunk versioning

Document versioning starts at the source. Most document systems already carry versions — a wiki page history, a contract revision, a policy document with a version number. The pipeline should capture the source version at ingestion and store it with every chunk, so that an answer can always be traced to the document revision it came from.

Chunk versioning is subtler. When a document is re-chunked, the chunks change even if the document did not. If chunk identifiers are random, the new chunks have no relationship to the old ones, and every historical citation breaks. The fix is deterministic chunk identifiers: derive the identifier from the document version and the chunk’s position, so identical content at the same position produces the same identifier across runs.

Superseded chunks need a policy too. When a document is updated, the old chunks should be removed or marked as superseded, not left to compete with the new ones in retrieval. A version-aware index filters by document version at query time, so only current chunks can be retrieved. Without that filter, answers quietly mix old and new information, and the citations look correct because they point at real documents. The provenance record that chunk versioning supports is what lets an answer be traced back to its source, and our article on RAG citation generation explains how citations surface that trace to users.

Embedding and index versioning

Embeddings are the most expensive component to version, because changing the embedding model means re-embedding the whole corpus. That cost tempts teams to skip versioning and simply overwrite the index. The result is an index whose contents nobody can describe: some vectors from the old model, some from the new, with no record of which is which.

The safer pattern is to treat each embedding run as a new index version. Build the new index alongside the old one, run regression tests against both, and switch traffic only when the new version performs at least as well. The old index stays available for comparison and rollback until the new one has proven itself in production. Storage is cheap compared with the cost of a bad migration discovered weeks later.

Index versioning also covers the retrieval configuration: the similarity metric, the number of chunks retrieved, the reranking step and any metadata filters. These settings change more often than the embedding model, and they change answers just as surely. Record them with the index version, and test them together. Our article on RAG regression testing shows how to compare index versions before switching.

Model and prompt versioning

Language models change on a schedule you do not control. Providers update models, rename them and retire old versions, and each change can shift answers in ways that are hard to predict. Record the exact model identifier — not just the family name — with every answer, and treat a model change as a release that deserves testing, not a silent upgrade.

Prompts deserve the same discipline as code. Store prompts in version control, review changes like any other change, and test them against a fixed evaluation set before deployment. A prompt edit that improves one class of question and damages another is a common failure, and it is only visible if the evaluation set is run before and after the change. Our guide to AI prompt version control covers the workflow in detail.

Model and prompt versions interact. A prompt tuned for one model may behave differently on another, so a model change should trigger a prompt review even when the prompt itself has not changed. Record the pair — model version plus prompt version — as a single generation configuration, and version that pair as one unit.

Component What changes How to version it
Documents Content edits and new revisions Capture source version at ingestion
Chunks Chunking strategy and boundaries Deterministic IDs from version and position
Embeddings Embedding model and parameters New index version per embedding run
Retrieval settings Top-k, ranking weights, filters Record with the index version
Language model Model updates and retirements Exact model identifier per answer
Prompt Instruction edits and template changes Version control with review and tests

Reproducing a past answer

Reproduction is the test that proves versioning works. Given an answer from last month, can you reconstruct the conditions that produced it? That requires four things: the query, the versions of every component, the retrieved chunks and their scores, and the generation output. The query and the output are easy. The versions and the retrieved chunks are where most systems fail.

The practical approach is a run record: a small log entry created for every answer, or for a sample of answers, that stores the query, the component versions, the chunk identifiers and the scores. The record does not need to store the chunk text itself — the identifiers plus the versioned index are enough to retrieve it again. What matters is that the record exists and that it is complete.

Reproduction is also the foundation of debugging. When a user reports a bad answer, the first step is to reproduce it with the recorded versions. If the answer reproduces, the fault is in the system as it was. If it does not, something changed without being recorded — which is itself a versioning failure worth investigating. That discipline is what makes RAG evaluation pipelines trustworthy over time.

A desk with a laptop, sticky notes on a wall and a printed timeline chart
Every component of a RAG answer changes on its own schedule, so each one needs its own version record.

Rollbacks: the reason versioning pays for itself

The moment versioning proves its value is the bad deployment. A new embedding model degrades retrieval, a prompt edit breaks formatting, a document update introduces errors — and the team needs to go back. Without versioning, rollback means guessing which combination of components was live before, and hoping the guess is right. With versioning, rollback means selecting the previous configuration and deploying it.

Safe rollback needs two things beyond version records. First, old versions must still exist: the previous index, the previous prompt, the previous model identifier. Deleting old versions to save space destroys the ability to roll back. Second, rollback must be tested. A configuration that has never been deployed in reverse is a hope, not a plan. Practise the rollback on a staging environment before production needs it.

There is a useful rule of thumb: keep the previous version of every component until the current version has served real traffic for a defined period — two weeks is a reasonable default. After that, older versions can be archived rather than kept live, as long as the archive can still reproduce their answers if an audit requires it.

Versioning checklist for your RAG pipeline

  • Capture the source document version at ingestion and store it with every chunk.
  • Use deterministic chunk identifiers derived from document version and position.
  • Build each embedding run as a new index version and keep the old index until the new one proves itself.
  • Record retrieval settings with the index version, not separately.
  • Store prompts in version control and test changes against a fixed evaluation set.
  • Log the exact model identifier and prompt version with every answer.
  • Keep a run record — query, versions, chunk identifiers and scores — for every answer or a representative sample.
  • Test rollbacks on staging before production needs them.

Frequently asked questions

What is RAG versioning?

RAG versioning is the practice of recording the exact version of every component behind an answer — documents, chunks, embeddings, retrieval settings, the language model and the prompt — so that past answers can be reproduced, explained and rolled back.

How is versioning different from provenance?

Provenance records where an answer’s content came from: the source documents and chunks. Versioning records which versions of every component were live when the answer was produced. The two overlap on documents and chunks, but versioning also covers models, prompts and retrieval settings that provenance does not.

Do I need to version the embedding model?

Yes. Changing the embedding model changes every vector in the index, which changes retrieval results. Treat each embedding run as a new index version, test it against the old one, and keep the old index available for rollback.

How long should old versions be kept?

Keep the previous version of each component live until the current version has served real traffic for a defined period, such as two weeks. Archive older versions with enough information to reproduce their answers, and let retention policy — not disk space — decide when archives are deleted.

Can I version a RAG system that is already in production?

Yes. Start by recording versions from today: capture document versions at ingestion, log model and prompt versions with answers, and build new index versions instead of overwriting. Historical answers from before versioning began cannot be fully reproduced, but every answer from now on can be.

What is the smallest useful versioning setup?

Three records: the document version on every chunk, the model and prompt version on every answer, and a run record linking the query to the versions and chunks involved. That alone makes most answers reproducible and most rollbacks safe.

Latest articles

Scroll to Top