Skip to content
Visual explainer 3h to learn 4 steps

Release prompt, model and index revisions with rollback

Roll out compatible prompt, model and index revisions with versioned metadata, candidate traffic checks and defined rollback criteria.

By Invicly Tech, , in Generative AI, Agentic AI and RAG. About 11 minutes to read.

Topic 30 of 34

In short

Prompts, models, embedding models and the index are one release unit: an embedding model change makes old vectors incomparable with new query vectors, and a prompt may depend on how chunks are shaped. A safe release builds the new index beside the old one with versioned metadata, sends candidate traffic through it, compares results against defined criteria and switches with a single pointer change. Rollback is the same pointer change in reverse.

Think of it like this: Build the new bridge next to the old one, test it with a few cars, then move the signs; if it wobbles, move the signs back.

Explained simply

The assistant depends on several moving parts: the prompt, the chat model, the embedding model that turns text into vectors, the way documents are cut into chunks, and the documents themselves. Change any one and answers can change. Some of these must change together. If you switch embedding models, every stored vector must be rebuilt, because old and new vectors cannot be compared.

So treat them as one release with a version, like release r7. A small record, the manifest, lists exactly which prompt, models, chunker and document snapshot r7 uses. Every vector row is tagged with its release.

You build the new index next to the old one while the old one keeps serving users. Then you test it: first with the golden dataset, then with real requests that also go to the new version but whose answers are not shown, or with a small share of users.

If it passes, you flip one setting so r7 becomes active. If problems appear, you flip it back. Because the old index is still there, rolling back takes seconds instead of hours.

Press Play on a diagram to walk through it one step at a time.

FlowSide-by-side index release
  1. 1
    Version metadata

    Release ID, embedding model, dimension, chunker, prompt

  2. 2
    Build beside

    New table or column, index created concurrently

  3. 3
    Offline eval

    Golden dataset against the candidate

  4. 4
    Candidate traffic

    Shadow or small share, compared to current

  5. 5
    Switch pointer

    Active release ID changes in one transaction

  6. 6
    Keep old

    Until the rollback window closes

CompareWhich changes need a re-embed?
Prompt or chat model change
  • Vectors stay valid
  • Re-run golden dataset
  • Can use canary directly
  • Rollback is a config change
Chunker change
  • Chunk IDs and text change
  • Re-embed every chunk
  • Citations shift to new sections
  • Build beside the old index
Embedding model change
  • All vectors incompatible
  • Dimension may change
  • Query and index must switch together
  • Build beside, then switch pointer

In depth

What goes in the release manifest

A manifest is a small, versioned record that answers: what exactly is serving right now? Include a release ID, the prompt version, the chat model ID, the embedding model ID and its output dimension, the chunker name and settings, the corpus snapshot ID, the creation time and the evaluation report it passed. Store it in a table, and keep the same release ID on every vector row and in every trace.

This is what makes compatibility checkable. At startup the API reads the active manifest and refuses to start if the query embedding model it is configured with does not match the manifest. In traces, the release ID lets you split latency and abstention by release, which is how you see a candidate's effect.

  • release_id, prompt_version, chat_model
  • embedding_model and dimension
  • chunker version and settings
  • corpus snapshot and eval report link

Building beside the old index in PostgreSQL

With pgvector, a vector column has a fixed dimension, such as vector(768). If the new embedding model has a different dimension, add a new table (or a new column) rather than altering the old one. Load vectors in batches, then create the approximate index. pgvector supports HNSW and IVFFlat indexes; its documentation recommends CREATE INDEX CONCURRENTLY in production so writes are not blocked. That command cannot run inside a transaction block, so run it as its own statement.

pgvector can index the vector type up to 2,000 dimensions; halfvec allows more. Check this limit before choosing a large embedding model. The query code reads the active release, then queries that release's table with a query vector from that release's embedding model.

LayersTwo releases side by side
  1. 1
    active_release

    One row: kb points to r6 or r7

  2. 2
    chunk_vectors_r7

    Candidate: new model, vector(768), HNSW

  3. 3
    chunk_vectors_r6

    Current: old model, vector(384), HNSW

  4. 4
    chunks and documents

    Shared text, IDs, scopes and versions

Candidate traffic: shadow and canary

Offline evaluation uses your golden dataset, which cannot cover every real phrasing. Candidate traffic fills the gap. In shadow mode the API serves the current release as usual and also runs the candidate in the background, recording only outcome codes, source IDs, latency and cost for comparison. Users never see the candidate's answers. In canary mode, a small, stable share of callers (for example by hashing the user ID) is served by the candidate.

Shadow mode doubles cost while it runs, so time-box it. For both modes, compare the same metrics: outcome mix, overlap of source IDs with the current release, abstentions, p95 latency, cost per request and any cross-scope hits. Permission filters must apply to the candidate exactly as to the current release.

Rollback criteria and the switch

Write rollback criteria before the release and make them measurable. Typical examples: any cross-scope disclosure; abstention rate more than 5 percentage points above the current release over an hour; p95 latency above the budget for 15 minutes; golden smoke cases failing. Name who can trigger a rollback.

The switch itself is one row update in a transaction. Because the API reads the active release per request (or caches it briefly), the change takes effect quickly with no deploy. Rollback is the same update back to r6. Keep r6's table and index until a set window has passed, for example a week, then drop them in a separate change.

  • Any cross-scope disclosure: roll back immediately
  • Abstention or latency over limit for a set period
  • Smoke cases failing after the switch
  • Keep the previous release until the window ends

Learn it in 4 short steps

About 45m each. Track them with a timer in your plan.

  1. 1
    Version source and embedding metadata~45m
  2. 2
    Build the new index beside the old one~45m
  3. 3
    Send candidate traffic and compare~45m
  4. 4
    Define rollback criteria~45m

Key points

  • Store the embedding model ID, dimension, chunker version and corpus snapshot with every vector.
  • Never mix vectors from two embedding models in one search; the query must use the same model as the index.
  • Build the new index next to the old one and create pgvector indexes with CREATE INDEX CONCURRENTLY to avoid blocking writes.
  • Write rollback criteria before the release: leaks, recall drop, abstention spike, latency or cost ceilings.
  • Switch and roll back by changing which release is active, not by rebuilding.

Key terms

Tap a card to flip it. 0/5 known

Examples

sql
CREATE TABLE chunk_vectors_r7 (
  chunk_id   text PRIMARY KEY REFERENCES chunks(id),
  release_id text NOT NULL DEFAULT 'r7',
  embedding  vector(768) NOT NULL
);
-- after loading vectors:
CREATE INDEX CONCURRENTLY chunk_vectors_r7_hnsw
  ON chunk_vectors_r7 USING hnsw (embedding vector_cosine_ops);
-- switch (and roll back) by changing one row:
UPDATE active_release SET release_id = 'r7' WHERE name = 'kb';

A new table per embedding release keeps dimensions and indexes separate.

Releasing a new embedding model

Prerequisites: release r6 active, golden dataset v3, local stack running. Step 1: create manifest r7 with the new model and 768 dimensions. Step 2: create chunk_vectors_r7, embed all chunks in batches and confirm row counts match chunks. Step 3: create the HNSW index concurrently. Step 4: run the golden dataset against r7; recall improves and leaks stay at zero. Step 5: shadow traffic for a day; abstentions match r6 within one point. Step 6: switch the pointer. Evidence: traces show release_id r7. Rollback: set the pointer back to r6.

sql
INSERT INTO releases (release_id, embedding_model, dim, chunker, prompt_version)
VALUES ('r7', 'embed-model-b', 768, 'headings-v2', 'answer-v5');
SELECT count(*) FROM chunk_vectors_r7;  -- must equal count of chunks
CREATE INDEX CONCURRENTLY chunk_vectors_r7_hnsw
  ON chunk_vectors_r7 USING hnsw (embedding vector_cosine_ops);
BEGIN;
UPDATE active_release SET release_id = 'r7' WHERE name = 'kb';
COMMIT;

A canary rollback

A prompt change ships as r8 to 10 percent of callers chosen by hashing the user ID. Step 1: after 30 minutes, the canary shows abstentions at 19 percent against 11 percent on r7, breaking the 5-point criterion. Step 2: the on-call engineer sets the canary share to zero. Step 3: traces confirm no new r8 spans. Step 4: the team adds three cases reproducing the abstentions to the golden dataset before trying again. No index rebuild was needed, because the prompt change reused r7's vectors.

Quick reference

  • Prompt, chat model, embedding model, chunker and corpus ship as one versioned release
  • Tag every vector row and every trace with release_id
  • Embedding model change means re-embed everything; never mix models in one search
  • CREATE INDEX CONCURRENTLY: avoids blocking writes; cannot run inside a transaction
  • pgvector indexes the vector type up to 2,000 dimensions; halfvec goes higher
  • Shadow: candidate runs, answers hidden; canary: small share of users served
  • Switch and roll back by updating one active-release row

Common mistakes

  • Re-embedding rows in place, so for hours half the index uses the old model and half the new one.
  • Changing the prompt and embedding model in separate deployments that can drift out of step.
  • Dropping the old index right after the switch, which turns a rollback into a long rebuild.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1You change only the prompt. What must be rebuilt?

Question 2

2Why build the new index in a separate table instead of updating vectors in place?

Question 3

3What is shadow traffic?

Question 4

4Which is a good rollback criterion?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Write the fields of a release manifest for a release that changes only the chat model.

  2. Exercise 2medium

    Write a startup check in Python that refuses to start when the configured embedding model or dimension differs from the active release.

  3. Exercise 3hard

    Write a function that picks a stable canary bucket per user (0 to 99) and decides which release serves the request given a canary percentage.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Can I keep two embedding models in one column?
Not usefully. A vector column has one dimension, and even with the same dimension, vectors from different models are not comparable. Use a separate table or column per embedding release.
How long should I keep the old index?
Until the rollback window you agreed on has passed with healthy metrics, often days to a week. Then drop it in a separate, reviewed change.
Is shadow traffic worth the extra cost?
For embedding or chunker changes it usually is, because they affect every query. Time-box it and sample a share of requests if cost is a concern.

Go deeper

ShareXLinkedInWhatsApp