Why old and new vectors cannot be mixed
Two toy models with three numbers per word, one a reordering of the other. Real models differ in far more than order, and real scores are not these.
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.
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.
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
Why can't you mix vectors from two embedding models?
Describe a safe migration to a new embedding model.
How would you decide whether to cut over, and what would stop you?
What is a dual write and why is it needed during a backfill?
Expected output
old docs, old query: D2=0.000 D3=0.000 D8=0.894 -> top D8
new docs, new query: D2=0.000 D3=0.000 D8=0.894 -> top D8
old docs, NEW query: D2=1.000 D3=0.447 D8=0.447 -> top D2
guard: refused: index built with toy-v1, query embedded with toy-v2
guard: top D8