Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 11.8 — Changing the Embedding Model
RAG and Vector Search · Example 2 of 2

Backfill, dual write, a measured cut-over and a rollback

Each candidate model is stood in for by a synonym table, so the measurement is real and reproducible. A real migration would embed with the new model instead.

Vectors from different embedding models live in different spaces and cannot be compared. Changing the model means building a second index, filling it in the background, measuring it on your test questions, switching only if it is better, and keeping a way back.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write check_same_model(index_model, query_model) that raises ValueError with the message index built with <a>, query embedded with <b> when they differ. Call it with two different names inside try/except and print the message.

02

Write overlap_at_k(old_ids, new_ids, k) returning the share of the top-k ids of the old list that also appear in the top-k of the new one, as a number, and print it with two decimals for ["D8", "D2", "D3"] against ["D8", "D3", "D4"] at k = 3.

Explain it without notes

01

Why can't you mix vectors from two embedding models?

02

Describe a safe migration to a new embedding model.

03

How would you decide whether to cut over, and what would stop you?

04

What is a dual write and why is it needed during a backfill?

Backfill, dual write, a measured cut-over and a rollback
Sign in to run this example in your browser.

Expected output

  backfill new-1: 3/8
  backfill new-1: 6/8
  backfill new-1: 8/8
measure new-1: hit@1 4/6 (old 3/6), regressions: Q1
BLOCKED: still serving old
  backfill new-2: 3/8
  backfill new-2: 6/8
  backfill new-2: 8/8
edit D8 written to: old, new-2
measure new-2: hit@1 5/6 (old 3/6), regressions: none
CUT OVER: serving new-2
ROLLBACK: serving old, old index still has 8 entries