Learning Objectives
- Distinguish evals ("can the model do the job") from A/B tests ("do users care").
- Enumerate three testable axes (prompt, model, parameters) and pick the metric for each.
- Explain CUPED, sequential testing, and Benjamini-Hochberg multiple-comparison corrections.
- Pick Statsig or GrowthBook based on warehouse-SQL posture and corporate acquisition stance.
The Problem
You hand-tuned a system prompt. It feels better. You ship it. Conversion changes by noise. You blame the metric. Or you shipped a new model and conversion didn't move — did the model degrade or was the change too small to detect? You don't know, because you shipped without an A/B.
Evals answer whether the model can do a task on a labeled set. They do not answer whether users prefer the output. Only a controlled online experiment answers that, and only if the experiment has enough power, controls for non-determinism, and corrects for multiple comparisons.
The Concept
Evals vs A/B tests
Evals — offline, labeled set, judge (rubric or LLM-as-judge or human). Answer: "Is the output correct / helpful / safe on this fixed distribution?"
A/B test — online, live users, randomized. Answer: "Does the new variant move the user-level metric that matters?"
Both required. Evals catch regressions before exposure; A/B confirms product impact after.
What to test
- Prompt engineering — wording, system-prompt structure, examples. Metric: task success, user retention, cost/request.
- Model selection — GPT-4 vs GPT-3.5-Turbo vs Llama-OSS. Metric: accuracy (task) + cost/request + latency P99. Multi-objective.
- Generation parameters — temperature, top-p, max_tokens. Metric: task-specific (output diversity vs determinism).
CUPED — variance reduction
Controlled-experiments Using Pre-Experiment Data. Regress out pre-period variance before comparing post-period. Typical variance reduction: 30-70%. Effective sample size goes up for free.
Implementation: both Statsig and GrowthBook implement.
Sequential testing
Classical A/B assumes fixed sample size. Sequential tests ("peek-and-decide") control false-positive rate under repeated looks. Always-valid sequential procedures (mSPRT, Howard's confidence sequences) let you stop early on clear winners.
Multiple-comparison corrections
Running 20 A/B tests at 95% confidence produces one false positive by chance. Bonferroni correction tightens α per-test; Benjamini-Hochberg controls false-discovery rate. GrowthBook implements both.
SRM — sample ratio mismatch
Assignment hash randomizes users to variants. If 50/50 split delivers 47/53, something is broken — SRM check flags it. Both platforms implement.
Statsig vs GrowthBook
Statsig:
- Acquired by OpenAI for $1.1B (September 2025). Hosted, SaaS.
- Sequential testing, CUPED, held-out populations.
- All-in-one: feature flags + experimentation + observability.
- Best fit: team already wants a bundled product, doesn't care about OpenAI ownership.
GrowthBook:
- Open-source (MIT); warehouse-native (reads from Snowflake/BigQuery/Redshift directly).
- Multiple engines: Bayesian, Frequentist, Sequential.
- CUPED, SRM, Bonferroni, BH corrections.
- Self-host or managed cloud.
- Best fit: warehouse-SQL shop, data team controls the metric layer, wants OSS.
Non-determinism complicates power
Same prompt produces varying outputs. Traditional power calculations assume IID observations. With LLM non-determinism, effective sample size is lower than nominal. Multiply required sample size by ~1.3-1.5x as a safety margin.
Real case outcomes
- Chatbot reward model variant: +70% conversation length, +30% retention.
- Nextdoor subject lines: +1% CTR after reward-function refinement.
- Khan Academy Khanmigo: iterative latency-vs-math-accuracy trade.
The anti-pattern: shipping on vibes
Every senior engineer can name a feature that was shipped because "it feels better" with no A/B. Most of them regressed product metrics the team didn't notice for months. A/B is the forcing function.
Numbers you should remember
- Statsig acquired by OpenAI: $1.1B, September 2025.
- GrowthBook: open-source MIT; Bayesian + Frequentist + Sequential.
- CUPED variance reduction: 30-70%.
- LLM non-determinism → +30-50% sample-size buffer.
Interactive figure coming later.
Use It
code/main.py simulates a sequential A/B test with fixed and sequential boundaries. Shows how sequential lets you stop early.
Ship It
This lesson produces outputs/skill-ab-plan.md. Given feature change, workload, baseline, picks platform, gates, sample size.
Exercises
- Run
code/main.py. For an expected 5% lift with baseline 3% conversion, what sample size to 80% power? - Pick Statsig or GrowthBook for a healthcare-regulated on-prem customer.
- Design an A/B that tests GPT-4 vs GPT-3.5 on cost-per-resolved-ticket. What's the primary metric, guardrail metric, secondary?
- Your canary passes but A/B shows -1.2% conversion. Do you ship? Write the escalation criteria.
- Apply CUPED to a pre-period with 60% of the variance of post. Compute the effective-sample-size boost.
Key Terms
| Term | What people say | What it actually means |
|---|---|---|
| Eval | "offline test" | Labeled-set evaluation of model capability |
| A/B test | "experiment" | Live randomized comparison on users |
| CUPED | "variance reduction" | Pre-period regression to reduce variance |
| Sequential test | "peek-ok test" | Always-valid procedure allowing early stop |
| Multiple comparison | "the family error" | Running many tests inflates false positives |
| Bonferroni | "tight correction" | Divide α by number of tests |
| Benjamini-Hochberg | "BH FDR" | False-discovery-rate control, less conservative |
| SRM | "bad split" | Sample ratio mismatch; assignment bug |
| Statsig | "OpenAI owned" | Commercial all-in-one, acquired 2025 |
| GrowthBook | "the OSS one" | MIT warehouse-native platform |
| mSPRT | "sequential probability ratio test" | Classical sequential procedure |
Further Reading
Code
main.py
python phases/17-infrastructure-and-production/21-ab-testing-llm-features/code/main.pyOpen on GitHub ↗
Take-away files
skill-ab-plan.md
--- name: ab-plan description: Design an LLM A/B test — pick platform (Statsig or GrowthBook), primary metric, guardrails, sample size with LLM-noise buffer, CUPED, sequential stopping, and multiple-comparison correction. version: 1.0.0 phase: 17 lesson: 21 tags: [ab-testing, statsig, growthbook, cuped, sequential, benjamini-hochberg, srm] --- Given the feature change (prompt / model / generation parameter), baseline metrics, expected lift, and team posture (warehouse-native OSS vs bundled SaaS), produce an A/B plan. Produce: 1. Platform. Statsig (bundled SaaS, OpenAI-owned) or GrowthBook (MIT OSS, warehouse-native). Justify. 2. Primary metric + guardrails. Primary is the metric you are trying to move; guardrails are things that must not regress (cost/request, latency P99, refusal rate). 3. Sample size. Classical power calculation × 1.4 (LLM non-determinism buffer). 4. Design. Fixed-horizon or sequential. Sequential if you expect strong signals; fixed if the change is subtle. 5. CUPED. Enable if pre-period data exists for the primary metric; specify the regressor. 6. Correction. Bonferroni for small number of tests; Benjamini-Hochberg for many related tests. 7. SRM. Require SRM check on every experiment; halt and debug if flagged. Hard rejects: - Shipping on vibes. Refuse — require A/B or documented no-A/B exception. - Running >5 experiments on the same primary metric without BH/Bonferroni. Refuse — false discovery certain. - Skipping SRM check. Refuse — assignment bugs are common. Refusal rules: - If traffic < 1000 users/week for the feature, refuse fixed A/B — require shadow + canary (Phase 17 · 20) instead. - If the primary metric is subjective (e.g., "quality") without an objective proxy, require human eval in parallel. - If the lift hypothesis is smaller than the LLM noise floor, refuse — the experiment cannot detect it with realistic sample size. Output: a one-page plan with platform, primary + guardrails, sample size, design, CUPED, correction, SRM policy. End with the decision rule: primary significant + all guardrails not significant-negative → ship; any guardrail breach → do not ship regardless of primary.