Did your new embedding model actually improve retrieval?

Did your new embedding model actually improve retrieval?

Part 5 of 7 in the Embedding Migration in Production series (change the model, not the reliability): engineer-level, on Azure AI Search and Microsoft Foundry, mapped to Microsoft exam AI-103.

TL;DR for managers. A fully loaded index proves the migration ran, not that search got better. Before switching, run the same set of real, judged questions against the old and new index, as the right users, and compare per question. Report the improvement with an uncertainty range, look at the questions that got worse, and check speed, cost and permission leaks alongside relevance. If the migration is forced by a retirement, "no worse" is a perfectly good result.

Microsoft's migration guide warns against assuming "that a newer model is better", and its validation checklist says not to switch "merely because the full load has finished". In part 4 shadow queries told us how often the new index returns different chunks. This part decides whether different means better, using the same golden-set approach as our RAG evaluation article, adapted for a two-system comparison.

Do this first, not last. The evaluation is described here, after the backfill, because that is when you make the switch decision. But build the golden set and measure the current index before any new embeddings are generated (part 1), and run it again on the 1% pilot (part 3). A baseline you didn't record can't be recreated once the old model has retired.

Build a golden set that represents the work

Start with 50 to 200 real questions, drawn from search logs where you can (with personal data removed), and grow it over time. Include the question types where embedding models differ most:

  • Exact codes and identifiers ("policy HR-012", "error 0x80070005"), where BM25 usually carries the result.
  • Paraphrased questions that share few words with the answer.
  • Acronyms and internal jargon.
  • Other languages, if your users ask in them. This is where OpenAI reports the largest difference between ada-002 and the text-embedding-3 models (MIRACL multilingual average 31.4 versus 54.9 for 3-large, OpenAI's figures).
  • Long, multi-part questions, ambiguous ones, rare documents, recently updated content.
  • No-answer questions, where the right behaviour is to find nothing convincing.
  • Permission-restricted questions, each attached to a specific test user.

Each question gets graded judgements: for example 2 for a chunk that answers it, 1 for partly relevant, 0 for not relevant. Subject matter experts do the judging, not the engineers who built the index.

Judge both systems' results, not just the old one's. If your judgements only cover chunks the old index used to return, every new chunk the new model finds counts as "not relevant" by default, and the evaluation is rigged in favour of the old model. Pool the top 10 from both indexes for every question and judge the union.

The metrics

Metric Question it answers
Recall@5, Recall@10 Of the relevant chunks, how many made it into the top 5 or 10? This is what the language model gets to see.
Precision@K How much of the top K is relevant, i.e. how much noise goes into the prompt?
MRR How high is the first relevant chunk, on average (1 for rank 1, 1/2 for rank 2...)?
NDCG@10 Does the ranking put the most relevant chunks first, using the graded judgements?
Latency p50, p95, p99 End-to-end search time, including the query embedding call.
Cost per 1,000 queries Query embedding tokens times price, plus any change in search capacity.
Permission leaks Results the test user couldn't open in the source system. Must be zero.

A worked example (illustrative numbers)

Three questions, so you can follow the arithmetic. Grades in brackets.

Question Relevant Old index ranks New index ranks
A d1 (2), d7 (1) d1 at 2, d7 at 5 d1 at 1, d7 at 2
B d5 (2) not in top 10 d5 at 3
C d2 (2), d8 (2) d2 at 1, d8 at 4 d2 at 2, d8 not in top 5
  • Recall@5: old (1 + 0 + 1) / 3 = 0.67; new (1 + 1 + 0.5) / 3 = 0.83.
  • MRR: old (1/2 + 0 + 1) / 3 = 0.50; new (1 + 1/3 + 1/2) / 3 = 0.61.
  • NDCG@10 for question A: the gain of a chunk is 2grade − 1, discounted by log2(rank + 1). Old: 3/log23 + 1/log26 = 1.89 + 0.39 = 2.28. The ideal order (d1 then d7) scores 3/1 + 1/log23 = 3.63. NDCG = 2.28 / 3.63 = 0.63. The new index has the ideal order, so 1.00.

The averages say the new model wins. The per-question view says something more useful: question C got worse. In a real evaluation, read every regression. It might be a judgement gap, a chunk the new model genuinely misses, or a class of question (codes, a language, a document type) you need to handle differently.

Compare per question, with an interval

Both indexes answer the same questions, so the comparison is paired: compute each question's score on both, take the differences, and bootstrap over questions to get a 95% interval for the mean improvement. Three questions prove nothing; with 100 or more you get a range you can act on.

import math, random, statistics

def recall_at_k(ranked: list[str], relevant: set[str], k: int) -> float:
    return len(set(ranked[:k]) & relevant) / len(relevant)

def reciprocal_rank(ranked: list[str], relevant: set[str]) -> float:
    return next((1 / i for i, d in enumerate(ranked, 1) if d in relevant), 0.0)

def ndcg_at_k(ranked: list[str], grades: dict[str, int], k: int = 10) -> float:
    dcg = sum((2 ** grades.get(d, 0) - 1) / math.log2(i + 1) for i, d in enumerate(ranked[:k], 1))
    ideal = sorted(grades.values(), reverse=True)[:k]
    idcg = sum((2 ** g - 1) / math.log2(i + 1) for i, g in enumerate(ideal, 1))
    return dcg / idcg if idcg else 0.0

def paired_bootstrap(old: list[float], new: list[float], n: int = 10_000, seed: int = 7):
    """Mean per-query improvement and a 95% interval, resampling QUERIES (the pairing is kept)."""
    diffs = [b - a for a, b in zip(old, new)]
    rng = random.Random(seed)
    means = sorted(statistics.fmean(rng.choices(diffs, k=len(diffs))) for _ in range(n))
    return statistics.fmean(diffs), means[int(0.025 * n)], means[int(0.975 * n)]

The decision rule depends on why you're migrating:

  • Migrating for quality: ship when the lower end of the interval for your main metric (say NDCG@10) is above zero and latency and cost stay within agreed limits.
  • Migrating because of a retirement: you're testing that the new model is no worse by more than an agreed margin. A small improvement is a bonus, not the bar.

Test the retrieval modes separately

Run the golden set through four configurations on both indexes, with everything except the embedding model kept the same:

CONFIGS = {
    "bm25":            dict(search_text=Q, vector_queries=None),
    "vector":          dict(search_text=None, vector_queries=[VQ]),
    "hybrid":          dict(search_text=Q, vector_queries=[VQ]),
    "hybrid+semantic": dict(search_text=Q, vector_queries=[VQ], query_type="semantic",
                            semantic_configuration_name="default"),
}
# Run every golden question through every config on BOTH indexes, as the user it is meant for
# (same security filter), with k_nearest_neighbors=50 and top=10, and keep the ranked chunk IDs.

BM25-only should give identical results on both indexes, because the text, analysers and BM25 settings were copied unchanged. If it doesn't, something other than the model changed (a field, an analyser, missing documents) and the rest of the comparison isn't trustworthy yet. That makes it a free data-parity check. Part 6 explains what to expect from the other three.

Check the dimension and compression options here

Part 2 left a capacity question open: text-embedding-3-large at 3,072 dimensions, at a smaller dimensions value, or quantised. This is where you answer it. Add each option as a separate candidate index built from the pilot sample, run the same golden set, and choose the smallest configuration that meets your quality bar. OpenAI reports that text-embedding-3 vectors shortened below 1,536 dimensions still slightly outperform ada-002 on its MTEB benchmark, but your documents aren't MTEB, so measure.

Retrieval first, generation second

Evaluate retrieval on its own before looking at answers. If retrieval improves, then run the end-to-end check: groundedness, answer relevance and citation accuracy, for example with the RAG evaluators in Microsoft Foundry. If you evaluate only final answers, a better retriever can be hidden by the prompt or the model, and a worse one can be hidden by a generous judge.

Common mistakes

  • Judging only what the old system returned, which biases the test towards the old model.
  • Reporting one average and never reading the regressions.
  • Running evaluation queries with an admin identity, so permission-restricted questions aren't tested at all.
  • Comparing raw similarity scores between models. They aren't on the same scale; compare ranks and metrics.

Key takeaways

  • A loaded index is not a better index. Measure, with judged questions that represent real work.
  • Pool and judge results from both systems, compare per question, and report an interval.
  • BM25-only results should match exactly: use that as a parity check.
  • For forced migrations, test "no worse"; for quality migrations, require a measured improvement.

Next, part 6: what happens to BM25, hybrid search and semantic ranking when the embedding model changes, and which settings to re-tune.

References

Learning this for AI-103? Microsoft's AI-103 exam (Azure AI Apps and Agents Developer Associate) covers implementing RAG with Azure AI Search, vector and hybrid search, and monitoring retrieval quality. Our live online AI-103 course builds these pipelines hands-on in Microsoft Foundry and Azure AI Search, on UK time, with mock assessments before you book the exam.

The Embedding Migration in Production series

Change the model, not the reliability.

  1. Part 1: Your embedding model is being retired
  2. Part 2: Why you can't simply swap embedding models
  3. Part 3: Re-embedding 10 million documents
  4. Part 4: Blue-green migration for Azure AI Search
  5. Part 5: Did the new model improve retrieval? (you are here)
  6. Part 6: BM25, hybrid and semantic ranking
  7. Part 7: The enterprise migration playbook
  8. Bonus: Document permissions in a migration
Back to blog

Ready to take the first step?

Live online courses on UK time, mapped to the current Microsoft AI exams. No coding needed for AI at work.

Explore AI coursesAsk us a question