Design A/B Testing for LLM Features
Understanding the Problem
🔀 What is A/B testing for LLM features? When a team changes an LLM feature, the change is usually a new prompt, a different model, or new parameters such as temperature or the tools offered. Offline evals tell you whether the change is plausible; only real traffic tells you whether users are better off. An LLM A/B testing system sends a slice of live traffic to the new configuration, compares it with the current one on quality, safety, latency and cost, and gets the change out of the way fast if it causes harm.
The running example is a customer support assistant. The team wants to try prompt v13 on a newer model for 10% of users, track five metrics, and have the system roll back automatically if the new variant produces more unsafe responses than the current one.
Functional Requirements
General A/B testing platforms already exist; see the A/B testing platform. Clarify with your interviewer that the interesting part here is what's different about LLMs: variants are prompts and models, the outputs are free text, and a bad variant can do harm in minutes.
Core Requirements
- Developers should be able to define an experiment in config: the variants (prompt version, model, parameters), the traffic split, the targeting and the metrics, with no code deploy.
- Applications should get a consistent variant for each user and call the LLM with that variant's configuration.
- The system should compute five metrics per variant: task success, response quality, safety violation rate, latency and cost.
- The system should automatically roll back the treatment when its safety metric regresses against control, and alert the owners.
Below the line (out of scope)
- Offline evaluation on golden datasets before launch; see LLM evaluation. We'll require it as a gate, not build it.
- The LLM gateway that routes to providers; see LLM gateway.
- Multi-armed bandits that shift traffic automatically to the winner.
Non-Functional Requirements
Ask about traffic and about how fast a bad variant must be stopped. For our design: the support assistant handles 2M conversations a day, about 10 LLM calls per conversation, so 20M calls a day (about 230 per second on average and around 700 at peak). A company might run 50 LLM experiments at once across products.
Core Requirements
- Variant assignment should add under 1 ms and must keep working when the experiment service is down.
- Config changes, including a rollback, should reach every application instance within 30 seconds.
- At full 10% traffic, a severe safety regression (say, unsafe responses doubling) should be detected and rolled back within about 10 minutes, without a human in the loop.
- Results must be statistically trustworthy even though people watch the dashboard continuously.
- Experiments must not change behavior for the 90% of users in control.
Below the line (out of scope)
- Regional data residency for logged conversations.
- Per-tenant experiments for enterprise customers.
The back-of-the-envelope math decides how fast we can catch a regression. 10% of 20M calls is 2M treatment responses a day, or about 1,400 a minute. Suppose the safety classifier flags 0.2% of responses today. In a 10-minute window, the treatment arm produces about 14,000 responses, so we'd expect about 28 flags at the baseline rate. If the new prompt doubles the rate, we'd see about 56. The gap of 28 is about five standard deviations of a Poisson count of 28 (√28 ≈ 5.3), which is clearly detectable. A 25% increase (35 vs 28) is not detectable in 10 minutes; it takes hours. So the system can catch big regressions in minutes and small ones over a day, and the design should be honest about that.
Detection speed is set by traffic and base rates, not by how fast your pipeline is. Working through this arithmetic out loud tells your interviewer what "auto-rollback within minutes" can and can't promise, and why a staged ramp (1% → 5% → 10%) is still worth having.