Forward Deployed EngineeringAI EngineeringModel Migration and Evaluation

Your provider is deprecating the model you built on. How do you detect and measure regression before migrating?

Question 53 of 73 · Updated

On this page

Interview-ready answer#

A replacement model is not a drop-in dependency merely because the API is compatible or its public benchmarks are better. I would treat migration as a change to the application's behavioral contract.

Before the old model disappears, I would preserve its effective configuration and capture an authorized, representative baseline. Then I would run the old and candidate models on the same labeled tasks, compare their correctness using paired measurements, and investigate regressions by failure type and customer segment.

I would define acceptance criteria before seeing the results: a justified non-inferiority margin for task quality, hard gates for critical safety and business invariants, and limits on end-to-end latency and cost. I would also test the candidate's tokenizer, context limits, structured outputs, tool behavior and deployment compatibility.

If the candidate fails, I would diagnose whether the issue is model capability, prompt compatibility or infrastructure, and test targeted remediation. Because the old model is being retired, rollback to it is a temporary option, not a long-term recovery strategy. I need an independently validated fallback before the cutoff.

1. Preserve a usable baseline before the deadline#

Confirm the actual provider retirement date, affected model identifiers, regions and access terms through official notices. Distinguish a deprecated model that still serves requests from a retired endpoint that no longer does.

Capture:

Baseline artifactWhy preserve it?
Effective model ID, prompt version, tokenizer assumptions and generation settingsIsolate the migration from unrelated configuration changes
Representative inputs, authorized evidence and expected outcomesRe-run equivalent tasks against replacement candidates
Old-model responses, tool trajectories and evaluator judgmentsAnalyze behavior even after old inference access ends
Actual token usage, latency distributions, errors and costCompare operational impact rather than relying on advertised prices
Data-handling, capacity and API requirementsReject candidates incompatible with the customer's deployment constraints

Use a privacy-approved evaluation dataset; redact or minimize sensitive inputs and restrict access to replay artifacts. Old outputs are evidence of historical behavior, not automatically correct golden answers. Human-validated labels, executable task checks and authoritative source evidence define correctness.

If the old endpoint is already unavailable, compare against recorded baseline outcomes and independently scored expectations. State explicitly that a fresh paired comparison with the old model is no longer possible. Historical telemetry collected under different traffic conditions is not equivalent to a controlled replay.

2. Test compatibility separately from quality#

Run contract tests before spending heavily on model evaluations.

  • Input: message roles, chat templates, token counting, maximum usable context, multimodal support and request-size limits.
  • Output: schema enforcement, refusal and truncation signals, stop behavior, streaming events and tool-call correlation.
  • Behavior: instruction priority, language support, citation fidelity, abstention, tool selection and multi-turn state handling.
  • Serving: authentication, regional availability, privacy requirements, quotas, rate limits, timeout behavior and observable usage.

A change in tokenization can increase the cost or truncate important evidence even when the raw prompt is unchanged. Different generation defaults can also alter behavior. Do not assume identical parameter names have identical semantics across providers.

First compare an equivalent supported configuration with the current prompt. Then test a candidate-specific prompt or adapter if necessary. Evaluate the final integrated configuration again: an improved prompt can recover quality while increasing latency or tool calls. FDE-0047 covers release versioning and rollout controls; here the focus is establishing whether a replacement is behaviorally and economically acceptable.

3. Measure paired regressions, not just average scores#

Use the same cases for both models. Freeze relevant evidence, tool fixtures and evaluation criteria; for agent workflows, use a sandbox that can reproduce initial state and evaluate task completion without executing real duplicate side effects.

For binary task success, record four outcomes:

Old modelCandidateExample count
PassPass880
PassFail (regression)40
FailPass (improvement)30
FailFail50

In this hypothetical 1,000-case evaluation:

  • Baseline success: (880 + 40)/1,000 = 92%.
  • Candidate success: (880 + 30)/1,000 = 91%.
  • Net change: (30 − 40)/1,000 = −1 percentage point.
  • Gross regression rate: 40/1,000 = 4% of all cases, or 40/920 ≈ 4.35% of baseline-successful cases.

The candidate improves 30 cases but breaks 40 previously working cases. Net accuracy alone hides that churn. Inspect the discordant cases: are the new failures formatting problems, incorrect policy decisions, retrieval omissions, or inability to perform a particular task?

For independent matched cases, an exact McNemar test conditions on the discordant pairs and tests whether the two directions of disagreement are equally probable under the null. Here the two-sided p-value is approximately 0.282. A nonsignificant difference does not establish equivalence or prove the candidate is safe to migrate to.

Non-inferiority is a different question#

Suppose the customer agrees that a quality loss larger than 2 percentage points is unacceptable. Let Δ = candidate success minus baseline success. The migration quality gate requires sufficient evidence that Δ > −0.02.

For illustration, define each paired difference as −1 for a regression, +1 for an improvement and 0 otherwise. Using a large-sample normal approximation with plug-in variance, the standard error of the mean difference is:

SE = sqrt([(b + c)/n − Δ²]/n),

where b is the regression count, c the improvement count and n the total number of pairs. Here SE ≈ 0.00836. The approximate one-sided 95% lower confidence bound is Δ − 1.645 × SE ≈ −0.02375 (−2.38 percentage points).

The bound crosses the −2-point margin, so this example does not establish non-inferiority. It does not prove that the true degradation exceeds the margin either. Use a suitable prespecified paired confidence interval in production; the simple normal approximation can be unreliable for small samples, rare failures or dependent observations.

If several cases come from the same customer, conversation or document, account for clustering. For repeated stochastic trials, aggregate or resample at the independent case/cluster level rather than treating every generation as independent. Plan sample size around the margin, likely discordance, power and critical slices. Correct for multiplicity where making multiple inferential claims.

Tested Python: exact paired comparison#

PYTHON
from math import comb from fractions import Fraction def paired(a, b, c, d): if any(type(x) is not int or x < 0 for x in (a,b,c,d)) or a+b+c+d == 0: raise ValueError('nonnegative counts and nonempty paired set required') n = a+b+c+d delta = Fraction(c-b,n) m = b+c p = min(Fraction(1), Fraction(2*sum(comb(m,k) for k in range(min(b,c)+1)),2**m)) return delta,p

The arguments follow the four rows of the table. The function returns the exact net success-rate difference and the two-sided exact conditional McNemar p-value; it returns p = 1 when no pairs disagree. It does not calculate a non-inferiority interval. For very large discordant counts, use a validated statistical library instead of constructing large exact binomial integers.

Executed verification: Python 3.13.5 passed 1,300 checks: 1,295 nonempty count combinations (each cell 0–5) compared with an independently enumerated fair-binomial sample space and rate-difference calculation, four invalid-input cases, and the worked example's net difference. The worked p-value and approximate lower bound were also calculated locally. These are synthetic calculations, not observed model-migration results.

4. Look for critical failures hidden by averages#

Choose slices based on the actual customer's risk and traffic, rather than arbitrary demographic or task categories.

SliceWhat to compare
High-impact business actionsUnauthorized operations, wrong eligibility, duplicate or falsely reported effects
Structured extraction and tool callingSchema validity, correct arguments, actual task completion
Long and multi-document inputsTruncation, exception coverage, citation correctness
Missing or contradictory evidenceAppropriate abstention, unsupported claims and over-refusal
Customer-specific languages and terminologyLabeled task accuracy, not fluency alone

Report denominators and uncertainty for each slice. Investigate new critical failures even if overall quality improves. Hard application invariants must remain enforced independently of either model. Zero observed critical failures in a finite evaluation is not proof that the risk is zero.

For free-form answers, use a task-specific rubric with human calibration. A judge model can introduce systematic preference for its own style or verbosity. Blind the candidate identity when feasible, randomize presentation order, validate judge agreement against human judgments, and adjudicate important disagreements.

5. Compare cost and latency at the application boundary#

A cheaper model per input token can be more expensive per successful task if it generates longer answers, makes more tool calls or requires correction attempts.

Measure the full workflow: input/output and cached-token usage under the candidate tokenizer, reasoning charges where applicable, retrieval/tool calls, retries, review time, and completed task rate. Compare cost per correct completed task under the same accounting rules and workload.

Benchmark time to first token and end-to-end p50/p95/p99 latency under representative request sizes and concurrency. Include cold and warm cache conditions, throttling and timeout failures. Do not add individual stage p95 values to estimate the workflow p95. Record throughput and error rates as well: a low latency measurement from successful requests alone can conceal widespread timeouts.

Agree on quality, safety, latency, capacity, privacy and cost gates with the customer before choosing the replacement.

6. Migration decision and contingency#

Loading diagram…

The retirement deadline is a genuine operational constraint. Prioritize regression fixes by business impact and time remaining. Reserve enough time for a controlled transition using the release process in FDE-0047.

If no replacement passes, consider a validated second model, a deterministic workflow for critical tasks, narrower supported functionality, or human-reviewed handling of uncertain cases. Do not silently weaken safety gates to meet a deadline. Document unresolved quality differences and obtain approval for any changed service commitments.

After cutover, compare the candidate against the preserved reference suite and monitor real outcomes by effective model/configuration ID. If the old endpoint has retired, route to the validated contingency rather than relying on an impossible rollback.

Related questions

Explore other topics:AI AgentsAI System DesignLarge Language Models