Skip to content
Small changes can't be detected; calculate the sample size before drawing conclusions

Small changes can't be detected; calculate the sample size before drawing conclusions

A week of canary rollout, and nothing was measured

A typical scenario goes like this: in the retrieval stage of a RAG question-answering system, chunks are switched from 512 tokens to 384, with 64 tokens of overlap added. Answer accuracy on the offline eval set rises by 4 percentage points, and at the review meeting everyone agrees it’s worth a try. It ships to 10% of traffic as a canary, runs for a week, and the like rate and follow-up rate are watched—both wobble within the noise range. The conclusion: “this change has no value,” roll back.

Two things are being conflated here: whether the change has an effect, and whether this experiment has the power to detect the effect. The former is a product judgment; the latter is a statistical one. Most “small changes can’t be measured” debates are actually stuck on the second, while everyone argues about the first.

Let me put the conclusion up front. In RAG scenarios, a change that only affects a subset of requests and lifts a single-digit percentage point locally basically cannot be measured within two weeks using a conventional parallel A/B test. It’s not that the experiment was done wrong—traffic and variance won’t allow it. To measure it, you have to change the measurement method.

First compute the effect size to detect, then talk about the experiment

For a binary metric (correct or incorrect, adopted or not adopted), there’s a usable approximation for the per-group sample size:

n ≈ 16 × p(1-p) / δ²

p is the baseline proportion, δ is the absolute lift you want to detect. The coefficient 16 comes from two-sided 95% confidence plus 80% statistical power; (1.96 + 0.84)² is about 7.85, times 2 and rounded. Good enough for budgeting; no need to carry it out to decimal places.

Taking a baseline accuracy of 70% as an example:

Absolute lift to detect Sample size per group Total for two groups
1 percentage point about 34,000 about 67,000
2 percentage points about 8,400 about 17,000
3 percentage points about 3,700 about 7,500
5 percentage points about 1,300 about 2,700

This table is brutal to read. To detect 3 percentage points, the two groups together need over seven thousand; to detect 1 percentage point, sixty-seven thousand. And this is the ideal case—no clustering, no judge noise, no metric dilution. Real projects only get larger.

For a product with 2,000 Q&A sessions per day, split 50/50, each group gets 1,000 samples per day. Detecting 1 percentage point takes 34 days, 2 percentage points takes 8 days, 3 percentage points takes 4 days. It looks like anything within 2 percentage points is still doable, but put the “ideal case” premise back in and 8 days becomes 12 or more.

So the first question to ask before starting an experiment isn’t how to split traffic—it’s how much lift I expect this change to bring, and can I afford to measure something of that magnitude. If you can’t answer that, there’s no point running the experiment, because you won’t be able to interpret the result anyway.

Continuous metrics (ratings, durations, token counts) use another approximation: n ≈ 16σ²/δ². σ is the standard deviation, δ is the mean difference you want to detect. For a 5-point rating with σ around 1 point, detecting a 0.1-point difference requires 1,600 per group. The number looks small, but the noise in the rating itself is often ignored—more on that later.

Small changes can’t be measured because they get diluted

This is the most underrated reason.

A change often doesn’t take effect on all requests. Switching chunk strategy only affects long-document retrieval; changing query rewriting only affects questions where coreference resolution fails; adding a tool only affects questions that need real-time data. Suppose the trigger rate is 15%, and on that subset accuracy goes from 60% to 70%—a local 10 percentage points, well worth doing. But the full-population metric sees 0.15 × 10 = 1.5 percentage points.

Per the formula above, 1.5 percentage points requires 15,000 samples per group. For a product with 2,000 per day, split 50/50, that’s 15 days. Multiply by the design effect and it’s 20 days or more. Most teams hold the retrospective on day seven.

Two solutions, neither easy.

The first is to move the metric to the triggered subset. Don’t measure full-population accuracy; measure accuracy on multi-hop questions, and δ goes from 1.5 back to 10, dropping the sample size by two orders of magnitude. The cost is that you have to label requests accurately as they come in. If the trigger condition itself is determined by a classifier, the classifier has its own accuracy problem, and mislabeled samples dilute the effect all over again.

The second is to stop using the full-population average metric for decisions and let it serve only as a guardrail. The full-population metric answers whether things got worse; the subset metric answers whether things got better. Ask the two questions separately, and budget samples for them separately.

Once you’ve computed the trigger rate and the local effect, the measurement approach is basically determined:

flowchart TD
    A[准备上线一个改动] --> B{影响超过一成请求}
    B -->|否| C[直接上线 看长期指标]
    B -->|是| D[局部效应乘触发率]
    D --> E{两周内样本够}
    E -->|够| F[平行实验]
    E -->|不够| G[离线配对比较]
    G --> H{配对仍测不出}
    H -->|是| C
    H -->|否| I[上线 线上只看护栏]

RAG variance has four layers

Observed variance comes from at least four places:

  • Between users: different users ask questions of very different difficulty
  • Between queries: the same user asks different things in different sessions
  • Sampling: when temperature is above 0, the same query run twice gives different answers
  • Judging: using an LLM to judge correctness online, the judge itself has noise

The first two layers are real variance and can only be reduced by adding samples or pairing. The latter two are artificial variance and can be suppressed directly.

Temperature is the easiest step to miss. Fix it at 0 during the experiment, or at least fix the seed, and the repeated variance for the same query disappears. The cost is lower answer diversity. If diversity is itself product value—creative scenarios, say—you can’t do this step, and then you have to budget that variance into the sample size. I lean toward turning it off first to measure direction, then turning it back on once the direction is confirmed, and measuring the impact of diversity separately in another round of experiments.

Judge noise must be quantified. Judge the same batch of answers twice and look at the proportion of inconsistent conclusions—on some models this proportion reaches double digits. To reduce noise: fix the prompt and model version, set temperature to 0, judge the same sample k times and take the majority; variance drops roughly to 1/k, and cost multiplies by k. A cheaper approach is to hand-label three or four hundred examples for calibration, compute the judge’s accuracy and bias direction on your task, and then decide how much to trust it.

Then there’s clustering. The same user asking five questions in a row—those five are not independent samples. The same document being retrieved repeatedly is not either. The effective sample size must be discounted:

n_eff = n / (1 + (m-1) × ρ)

m is the average number of samples per cluster, ρ is the intra-cluster correlation coefficient. With m = 5 and ρ = 0.15, the design effect is 1.6, so the sample size multiplies by 1.6. In RAG, the same document being hit repeatedly is common, and ρ may be higher than 0.15. If the budget doesn’t multiply by this coefficient, the experiment will be systematically over-optimistic, showing up as “always just barely not significant.”

False negatives come in three forms

The first: concluding before running long enough. The p-value is 0.3, and the team says no effect. But at that point the confidence interval might run from -1 percentage point to +4 percentage points—it explains nothing. You need to distinguish “no evidence of a difference” from “evidence of no difference,” which means checking whether the upper bound of the confidence interval is below the minimum effect you care about. Without that step, “not significant” cannot be written into the retrospective as “no effect.”

The second: peeking while running, and stopping when it doesn’t look promising. This way of stopping hurts false negatives more than false positives, because the judgment always happens in the early period when variance is largest. Either run to the pre-computed sample size, or use sequential testing to control the error from multiple looks. Casual peeking somewhere in between is the most dangerous.

The third issue: the wrong metrics were chosen. Like rates carry extremely weak signal in RAG scenarios—dissatisfied users don’t necessarily downvote, and satisfied users don’t necessarily like. Follow-up rates are somewhat better, but a follow-up may stem from an incomplete answer or from an overly verbose one—the direction isn’t even consistent. Using a high-noise sensor to measure a small signal, failure to detect it is inevitable.

The current default combination is: the primary metric should be a behavior close to the business but clearly defined, such as answers being adopted or citations being clicked; the auxiliary metrics should be dense metrics, such as retrieval hit rate, citation coverage, and first-answer length. Look at both; when they diverge, the primary metric prevails, but use the auxiliary metrics to explain the divergence rather than ignore it.

Paired comparison is more cost-effective than increasing traffic

The most expensive part of parallel A/B is that it folds the variance across queries entirely into the error term. Feeding the same batch of queries to two versions for a paired test cancels out that variance.

A rough sample-size calculation for the McNemar test: if the proportion of discordant judgments between the two versions is about 20%, and the new version wins over the old by 4 percentage points more than it loses, the required sample is around 1,000 pairs. Compare that with the 7,500 samples for the parallel experiment above—a difference of an order of magnitude.

The cost is that pairing can’t be done online. The same user can’t see two answers at once. So pairing can only be done on a fixed offline evaluation set, or via shadow dual-running, where online requests are copied to the new version without affecting users. Shadow doubles the cost and adds a bit of latency, but for low-traffic products it’s often the only way to accumulate enough samples.

Pairing also can’t measure certain things: the distribution of real users, the long tail of real queries, and what users do next after seeing an answer. However large the fixed evaluation set, it’s still one you selected. So the default division of labor is: offline pairing answers whether there’s an improvement, and small online traffic answers whether anything got worse. The former sets direction, the latter sets risk. Using one experiment to answer both questions usually answers neither well.

Some changes aren’t worth experimenting on

The boundaries need to be clear.

If a change is reversible, affects less than 10% of traffic, and has a rollback fallback for the worst case, ship it directly. Accumulating statistical power for a change that affects only 5% of requests with controllable worst-case loss will most likely cost more than the change itself is worth.

If the effect size is below your detection floor, don’t test it either. At that point the criterion isn’t whether there’s an effect, but whether the worst-case cost is bearable. If it’s bearable, ship it; if not, cut it—this has nothing to do with statistics. Packaging this as an experimental question only lengthens the decision cycle.

There’s also a category of things no short-term experiment can measure: users’ trust in the system, changes in usage habits, and the impact of answer style on long-term retention. These can only be observed via a long-term holdback group or supplemented with qualitative interviews. Cramming them into a two-week experiment yields only noise—and very expensive noise.

Back to the chunk-change example from the beginning. An offline gain of 4 percentage points suggests the direction is probably right. The reason a one-week canary test couldn’t detect it is that the overall like rate is both sparse and diluted. The right approach is to first calculate the sample size on the triggering subset; if you find you can’t accumulate enough within two weeks, skip the online parallel experiment, switch to offline pairing to confirm direction, and keep only one online guardrail: citation coverage must not drop by more than 2 percentage points.

About this Post

This post is written by Lu's Blog, licensed under CC BY-NC 4.0.

#A/B Testing #RAG #Sample Size

Comments