BXUP Track progress & test yourself — free
Data Science & ML/AI · Playbook · Advanced · ~6 min read
DATA SCIENCE & ML/AI · PLAYBOOK · ADVANCED

Online A/B Experiments for LLM Features: Your Stats Background Is the Edge

Offline evals (pb-34→pb-38) tell you a change should help; only an online experiment tells you it did — with real users, real inputs, and real stakes.

Tier: Advanced · Workflow area: Evaluation Engineering

This is where an experienced data scientist outruns the prompt-engineer crowd: LLM teams routinely ship on "the new prompt feels better" with no power analysis, no guardrails, and peeking-driven false positives. This playbook transfers your classical experimentation rigor to LLM changes — prompt swaps, model bumps, retriever updates — with the LLM-specific twists: noisy judge-based outcome metrics, cost/latency guardrails, and sequential monitoring so you can stop early without lying to yourself.

When to use

  • An LLM change passed offline gates (pb-37) and the decision is now "does it improve real outcomes?" — user acceptance, task success, retention-proxy metrics.
  • Offline and online signals have disagreed before (they will: golden sets lag live traffic), and leadership needs the tiebreaker.
  • A model migration promises cost savings and you must prove quality holds at production scale before switching fully.

Skip the experiment for changes below your minimum detectable effect or with trivial blast radius — ship behind a flag with monitoring instead; experiments are for decisions worth their sample cost.

Prerequisites

  • A randomization point you control: the LLM gateway or feature-flag layer assigning users (not requests — see step 2) to arms, logging assignment with the trace.
  • Outcome metrics computable per unit: explicit (thumbs, edit-distance on accepted drafts, task completion) and/or judge-scored quality on sampled traffic (pb-36 calibrated judge only).
  • Guardrail metric plumbing: p95 latency, cost per request, error/refusal rate, safety flags — live per arm.
  • Your existing A/B stack, or a modest homegrown harness: assignment log + metrics join + a stats notebook is genuinely enough.

The workflow

  1. Write the experiment design doc first (one page). Hypothesis with direction and size ("model B raises draft-acceptance rate by ≥ 2pp"), primary metric (exactly one), secondary metrics, guardrails with stop thresholds, unit of randomization, power analysis output (n and expected duration), analysis plan (test, sequential method, slice list — pre-registered), and the ship/no-ship decision rule. Pre-registration is what makes the answer credible when it is inconvenient.

  2. Randomize by user, stratify if traffic is lumpy. Request-level randomization contaminates within-user experience and violates independence (users issue correlated requests). Hash user ID → arm at the gateway; log (user, arm, timestamp) immutably. For B2B products with whale accounts, stratify or use account-level assignment — one enterprise tenant landing in arm B can dwarf the treatment effect.

  3. Do the power analysis with LLM-realistic variance. Get the primary metric's baseline mean and variance from 2 weeks of logs — judge-scored quality metrics are much noisier than click metrics, so expect larger n than intuition suggests. Standard formula, honest inputs: for a proportion metric, n ≈ 16·p(1−p)/δ² per arm rule-of-thumb at α=0.05, power 0.8. Two variance-reduction levers before enlarging n: CUPED-style regression adjustment using each user's pre-experiment metric, and paired judging on identical prompts where the same input can safely receive both arms' responses offline (interleaving-style) — often cutting required n by 30–50%.

  4. Set guardrails as hard stops, not dashboards. Per arm: p95 latency ceiling, cost/request ceiling, error+refusal-rate ceiling, safety-violation count (from pb-38-style checks). Breaches trigger automatic ramp-down, not a meeting. LLM changes fail operationally more often than qualitatively — a model that is 3% better and 2× slower usually loses, and you want to learn that at 5% traffic.

  5. Ramp with sequential monitoring — peek legally. Launch at 5% → 20% → 50% following the ramp plan. You will look at results daily, so choose a method that permits it: group-sequential bounds (O'Brien-Fleming via alpha-spending) or always-valid inference (mSPRT/confidence sequences). Naive daily t-tests at α=0.05 push false-positive rates toward 25–30% over a few weeks of peeking — this is the single most common LLM-experimentation malpractice, and the one your training exists to prevent.

  6. Sample traces into judge scoring with QC. For quality metrics, route a fixed sample per arm/day through the pb-36 judge (same pin, both arms, order-randomized when pairwise). Keep the 5–10% human re-grade flowing during the experiment — a judge drifting mid-experiment is a differential measurement error that quietly manufactures a winner.

  7. Analyze exactly what you pre-registered. Primary metric with CI under the sequential method; guardrail deltas; pre-registered slices only (intent type, user tenure, input length) with multiplicity correction — everything else is labeled exploratory for the next experiment's hypothesis. Then the LLM-specific decomposition: join outcomes to traces and ask where the win came from (which intents, which retrieval-quality bands) — pb-34 trace reading applied to experiment cells.

  8. Decide by the rule, write the memo, archive everything. Ship/no-ship per the pre-registered rule; memo records design, actuals vs plan, primary/guardrail results, surprises, and the follow-up hypothesis. Archive assignment logs and analysis code — model-migration experiments get audited later ("when did quality actually change?") more than any other kind.

Key Takeaway:

Every prompt tweak that ships without an experiment is an experiment with n=all-your-users and no control group — rigor here is not slower, it is the only version where you learn the answer.

Tool variants

  • Your existing A/B platform (in-house, GrowthBook/Statsig-class): add the arm ID to LLM trace metadata so assignment joins to traces; the platform handles sequential stats.
  • Gateway-level homegrown: LiteLLM-style router or feature flag assigns arms; a notebook with statsmodels + a confidence-sequence library does the analysis — fully sufficient and boundary-friendly.
  • Interleaved offline-online hybrid: for low-traffic products, pair pb-36 pairwise judging on live-sampled inputs with a small online holdout — weaker causal claim, honest about it, far better than nothing.

Verification

  • Design doc pre-registered (timestamped commit) before first assignment; exactly one primary metric.
  • Assignment is user-level, hash-stable, and logged; SRM check passed (arm sizes match planned split, chi-square p > 0.001 — sample-ratio mismatch invalidates everything downstream).
  • Power analysis used measured variance from real logs; n and duration were respected or deviations documented.
  • Sequential method named and applied; no naive repeated testing anywhere in the analysis.
  • Judge pin unchanged across the experiment window; human re-grade agreement stable across arms.
  • Guardrail auto-stops tested (fire-drill on the ramp-down path) before launch.

Pitfalls

  • Peeking with naive tests. The classic; use group-sequential or always-valid methods, or lock the analysis date.
  • Request-level randomization. Correlated requests per user shred your independence assumptions and understate variance — user-level is the default, always.
  • Ignoring SRM. A 51.8/48.2 split on a planned 50/50 with large n means broken assignment (caching, bot traffic, hash bias) — check it before reading any metric.
  • Judge as an unstable ruler. A judge-model version bump mid-experiment differentially scores arms; pin it, monitor agreement, and treat any judge change as experiment-invalidating.
  • Shipping on the exploratory slice. The one green subgroup among twelve is how false discoveries get promoted; slices are pre-registered or they are hypotheses.
  • Quality-only decisions. Cost and latency are co-primary in LLM systems economically even when statistically "guardrails" — report the quality-per-rupee framing to decision-makers.

Restricted-environment variant

  • All experimentation machinery runs inside your boundary already (gateway, logs, notebook); the external-facing risk is judge scoring — use the self-hosted pb-36 judge for arm scoring on client traffic.
  • For client deliveries, the experiment memo (metrics, deltas, decision) crosses the boundary; assignment logs and traces do not.
  • If the client's compliance bars user-level experimentation, fall back to the interleaved-offline hybrid plus a time-staggered rollout with CUPED-adjusted pre/post analysis — state the weaker causal grade explicitly in the memo.
Note

Randomizing users into a materially worse-quality arm has ethics weight in high-stakes domains (medical, financial guidance) — cap exposure, ramp conservatively, and clear such experiments with the product owner in writing.

Success criteria

  • A shipped (or correctly killed) LLM change backed by a pre-registered, adequately powered, sequentially monitored experiment.
  • Guardrails held or triggered automatically; no post-hoc metric swapping anywhere in the record.
  • The decomposition tied the aggregate result to specific traffic slices, generating the next testable hypothesis.
  • Your team's rollout template now includes the design doc, SRM check, and sequential plan — the rigor became the default, which was the actual deliverable.
This is the free reading view. Open BXUP to track your progress, run the hands-on labs, and prove it with original, exam-pattern assessments.
© Anvi Innovate · BXUP — Be Exponentially Upskilled · BXUP is an independent learning platform, not affiliated with or endorsed by AWS, Microsoft, Google, NVIDIA, IBM, Salesforce, Databricks, Oracle or Anthropic. All trademarks belong to their respective owners. · bxup.in