Model A/B testing

Also known as: online model experiment

On this page 7

Model A/B testing is a controlled online experiment in which live requests or users are randomly split between a current production model and one or more candidate models, so that their effect on real outcome metrics can be compared with statistical rigor. In MLOps & deployment, it is the final validation step between offline evaluation and full rollout, also described as an online model experiment.

Offline metrics such as accuracy or AUC show how a model scores on historical data, but they often fail to predict user behavior, revenue or latency in production. A/B testing closes that gap by measuring the causal effect of a model change on the people and systems it actually serves.

How model A/B testing splits and measures traffic

A model A/B test works by assigning each randomization unit, usually a user, session or account, to a variant through a deterministic hash of its identifier. The control group keeps the incumbent model (A), while the treatment group receives the candidate model (B). Stable assignment matters: if one user sees both models, the effects contaminate each other and the comparison loses validity.

The serving layer, often a feature-flag service or a router inside the inference platform, logs every prediction together with the variant label and a request identifier. Downstream events such as clicks, purchases or support tickets are later joined to those logs, which allows analysts to compute metrics per variant and test whether the observed difference exceeds random variation.

The table below lists the main components of a typical setup and the role each one plays.

ComponentRoleTypical failure if missing
Assignment serviceHashes units into stable variantsUsers flip between models
Model routerSends requests to model A or BUneven or leaking traffic
Exposure loggingRecords variant, request and predictionMetrics cannot be attributed
Metrics pipelineJoins outcomes to exposuresDelayed or biased results
Statistical engineComputes effects and confidence intervalsDecisions based on noise
Core components of a model A/B testing setup

Metrics and statistical parameters

Every test needs one primary metric chosen before launch, a set of guardrail metrics that must not degrade, and a pre-registered analysis plan. The primary metric should reflect the business goal, for example conversion rate or watch time, rather than a proxy that the new model was trained to optimize directly.

Sample size follows from four inputs: the baseline rate, the minimum detectable effect, the significance level and the desired statistical power. Common defaults are a significance level of 0.05 and power of 0.8, although teams that run many tests often tighten thresholds to limit false discoveries.

ParameterTypical valueEffect of a stricter setting
Significance level (alpha)0.05 or 0.01Fewer false positives, larger sample
Statistical power0.8 to 0.9Fewer missed effects, longer test
Minimum detectable effect0.5% to 5% relativeSmaller effect needs much more traffic
Traffic allocation50/50 or 90/10Unequal split reduces power
Test duration1 to 4 full weeksCaptures weekly seasonality
Key statistical parameters and their effect

Variance reduction techniques such as CUPED, which adjusts outcomes using pre-experiment covariates, can shorten tests considerably. Sequential testing methods allow safe early stopping, whereas repeatedly checking a fixed-horizon test, known as peeking, inflates the false positive rate.

Model A/B testing is one of several progressive delivery patterns, and each answers a different question. Shadow deployment checks technical behavior without affecting users, a canary release limits blast radius, and a champion-challenger model setup compares candidates over a longer period, often in regulated domains.

PatternUsers affectedMain question answered
Model A/B testingRandom share sees model BDoes B cause better outcomes
Shadow deploymentNone, B runs silentlyIs B stable, fast and consistent
Canary releaseSmall share, increased graduallyIs B safe to roll out
Champion-challengerDefined share over monthsDoes B beat A over time
Multi-armed banditShifting share toward winnersWhich variant earns most during the test
Model A/B testing versus neighboring deployment patterns

A multi-armed bandit reduces the cost of exposing users to a weaker model, but it gives less reliable effect estimates than a fixed randomized split. Teams that need a defensible decision record usually prefer a classic A/B test.

Running a model A/B test in practice

A sound workflow starts with offline evaluation and shadow traffic, so that only candidates that are technically healthy reach users. The team then writes a hypothesis, fixes the primary metric and duration, runs an A/A test or sample ratio check to validate the plumbing, and launches with a small allocation before ramping to the planned split.

  1. Validate the candidate offline and in shadow mode.
  2. Define the hypothesis, primary metric and guardrails.
  3. Calculate sample size and duration in advance.
  4. Launch, monitor guardrails daily and check the sample ratio.
  5. Analyze once at the planned end and record the decision.
  6. Promote, iterate or perform a model rollback.

The decision table below maps common results to a recommended action.

ResultRecommended actionReason
Primary metric up, guardrails stablePromote model BClear net benefit
Primary metric flat, latency betterPromote with cautionOperational gain only
Primary metric up, guardrail downInvestigate before promotingHidden harm possible
Sample ratio mismatch detectedDiscard and rerunAssignment is broken
No significant differenceKeep model A or extend testEffect smaller than planned
Decision table for interpreting results

Limitations and common mistakes

Model experiments carry pitfalls that general product tests rarely face. Feedback loops arise when a model influences the data used to train its successor, and delayed ground truth, for example loan defaults that appear months later, can make short tests misleading. Network effects in marketplaces or social products violate the assumption that units are independent.

  • Peeking at results and stopping early when the difference looks significant.
  • Novelty effects that fade after the first days of exposure.
  • Optimizing a short-term proxy that harms long-term retention.
  • Ignoring training-serving skew that makes model B behave differently in production.
  • Running many overlapping tests without correcting for multiple comparisons.

Ethical and regulatory constraints also apply. In credit, health or hiring, exposing a random group to an unvalidated model may require review and documentation, and fairness metrics should be monitored per segment, not only in aggregate.

Stripped to the essentials

Imagine a shop that wants to test a new way of suggesting products. It does not switch everyone at once. Instead, it shows the old suggestions to half of the visitors and the new ones to the other half. Visitors are picked by chance, so both groups are alike.

After a few weeks, the shop compares the two groups. Did people buy more? Did the site get slower? If the new version clearly wins and causes no harm, it replaces the old one. That is model A/B testing: a fair, side-by-side contest with real people, judged by real results.

Where it is applied

A video streaming service trains a new recommendation model that improves offline ranking accuracy by 3% on held-out data. Before replacing the production model, the team routes 10% of users to the candidate for two days to check latency and error rates, then ramps to a 50/50 split for three weeks.

The primary metric is weekly viewing hours per user, and guardrails include playback start time and subscription cancellations. At the planned end, the candidate shows a 1.2% increase in viewing hours with a confidence interval that excludes zero, while guardrails stay flat. The team promotes the new model, records the result in the model registry and keeps the old version ready for an immediate rollback.