Offline evals won't win a renewal. A clean A/B test will
Assign users with a stable hash, log the right fields and check for sample ratio mismatch before you show the client a single number.
In brief
- A model that passes offline validation has not yet proved its value on the client's real data; an A/B test is what does that.
- Variation in LLM output adds to variation in user behavior, so you need more traffic and should run for 3-4 weeks.
- If the group split deviates from the design, fix the instrumentation first and do not read the results.
Two weeks after nodding through a demo of your AI feature, the client’s head of operations asks a blunt question: “Do you have any numbers showing it actually helps?” Accuracy on a test set cannot answer that. Only a controlled experiment on real users can.
Offline validation tells you whether a model generalizes. Generalizing on a held-out dataset, however, says nothing about the impact on the client’s actual workflows and users.
For a forward deployed engineer, that is the gap between “the model is good” and “the client renews the contract”. The guide below shows how to build a minimal but technically sound A/B test on a laptop, then take it to the client.
What will you build?
Take a hypothetical case: the client is an e-commerce company, and you deploy an LLM feature that suggests replies to customer support agents.
The treatment group sees the suggestions; the control group works as before. You need three things: a stable assignment function, logs with enough information, and a data quality check before reading any results.
Requirements: Python 3 and the standard library (hashlib, math), plus write access to logs on the client’s system. The code below is stripped down for learning. In production, these pieces belong in whatever experimentation platform the client already uses.
Step 1: Choose metrics before writing a line of code
Split metrics into three tiers. The primary metric measures behavior close to the feature, such as the share of suggestions agents actually use. The business metric sits further out, for example ticket handling time. The last tier is guardrails: things that must not get worse.
Expectations for the business tier usually run too high. Downstream metrics are the least sensitive, so detecting a meaningful lift on them requires a large sample and a long run.
With a low-traffic client, agree at the outset that the primary metric decides the outcome and the business metric is only monitored.
Guardrails are the part many people forget with AI features. One Milvus document gives an example: if Model B triggers the PII detector 10% more often than Model A, that is a clear signal to review the training data. The rate of safety-filter blocks and the rate of PII detections should be measured in parallel in both groups.
Check: you have a one-page document listing each metric and its formula, signed off by the client’s owner.
Step 2: Assign groups with a hash, not a random draw per request
The same user must always land in the same group. If an agent sees suggestions today and none tomorrow, you are measuring their confusion rather than the feature’s effect.
import hashlib
EXPERIMENT = "reply-suggestions-v1"
def assign(user_id: str) -> str:
key = f"{EXPERIMENT}:{user_id}".encode()
bucket = int(hashlib.sha256(key).hexdigest(), 16) % 100
return "treatment" if bucket < 50 else "control"
Including the experiment name in the key gives each experiment an independent split. Check: run the function on 10,000 fake user_ids and count the two groups. The split should be close to 50/50, and calling it again with the same ID must return the same result.
Step 3: Pin the model version and log it
Your treatment does not stand still. LLM providers update models constantly, often with no commitment that a version will stay fixed for the length of your experiment. If the model changes midway, the first and second halves of the experiment are effectively measuring two different features.
MODEL_VERSION = "specific-model-name-with-pinned-version" # do not use an alias that points to the latest release
def log_exposure(user_id, variant, ts):
return {
"experiment": EXPERIMENT,
"user_id": user_id,
"variant": variant,
"model_version": MODEL_VERSION if variant == "treatment" else None,
"ts": ts,
}
Setting temperature to 0 does not settle the matter: it does not remove the nondeterminism of LLM output. So beyond pinning the version, write model_version into every log line. If something changes midway, you can still split the data by version for analysis.
Check: query the logs and count the distinct model_version values in the treatment group. The answer must be one.
Step 4: Estimate traffic up front, then run long enough
LLM features are harder to measure than a button that changes color. Variation in LLM output stacks on top of variation in user behavior, pushing up both the standard error and the minimum detectable effect, so the experiment needs more traffic.
Duration is also a trap. A two-week window is often too short to separate a real lift from a novelty effect, so plan for 3-4 weeks. At a client, say this in the kickoff meeting: nobody wants to hear “we need two more weeks” at the last minute.
Check: plot the primary metric by week for each group. If the gap between the groups narrows over time, you are watching a novelty effect fade.
Step 5: Check for SRM before looking at results
Before opening the results table, verify that the two groups match the designed ratio. Sample Ratio Mismatch (SRM) occurs when the observed number of users in each group deviates from the planned allocation.
import math
def srm_pvalue(n_a, n_b, ratio_a=0.5):
total = n_a + n_b
exp_a, exp_b = total * ratio_a, total * (1 - ratio_a)
chi2 = (n_a - exp_a) ** 2 / exp_a + (n_b - exp_b) ** 2 / exp_b
return math.erfc(math.sqrt(chi2 / 2)) # chi-square with 1 degree of freedom
print(srm_pvalue(5200, 4800))
Try it with an illustrative figure: a 50/50 design across 10,000 users, but the logs record 5,200 in treatment and 4,800 in control. Each group is 200 away from the expected 5,000, the chi-square statistic is 16 and the p-value is about 0.00006. A gap like that is almost impossible by chance.
Authors from Microsoft Research, in a paper at KDD 2019, likened SRM to a fever: a single symptom that can stem from many different kinds of data quality problem.
Treatment logs might be lost when the LLM call times out, or bots might fall into only one group. SRM does not go away if you wait longer or add users. The fix lies in the instrumentation; reweighting the data after the fact does not repair it.
Check: set a strict threshold in advance, such as 0.001. If the SRM p-value is below 0.001 (like 0.00006 in the example above), stop reading the results and trace the logging path of the group that is short. A strict threshold keeps you from raising false alarms when you run this check every day.
What are the most common mistakes?
The most common mistake is reporting after a few days because the numbers “look good”, just as the novelty effect peaks. The second is assigning by request instead of by user. The third is logging exposure only in the treatment branch, which quietly creates the very SRM you will later have to untangle.
Also avoid using the business metric as the win-or-lose criterion when the client’s traffic is small. You will get a result that is “not statistically significant”, and the client will hear “the feature doesn’t work”.
How does this skill show up at the client and on a CV?
At the client, the first task is sitting down with the owner to agree on the primary metric, the guardrails and the 3-4 week run, before anyone writes an assign function. Logging and the SRM check come after. The final report should open with the line “SRM: pass”, and only then give the lift.
When reading FDE job descriptions, look for whether the role asks for impact measurement or running experiments with clients; if it does, put this skill at the top of your CV. A strong bullet point is specific: per-user assignment, a pinned model version, a PII guardrail, and an SRM bug detected and fixed.
That last detail shows an interviewer you have actually run experiments, beyond reading about them.
A demo wins you a pilot contract. A renewal takes an experiment that the client’s own data team can audit without finding a flaw.
Was this article useful?
Thanks for the feedback!
5 sources
- What is Machine Learning? | IBM · 2025-08-18
- A/B Testing AI Features When the Treatment Is Non-Deterministic · 2026-04-19
- Diagnosing Sample Ratio Mismatch in Online Controlled Experiments: A Taxonomy and Rules of Thumb for Practitioners · 2019-07
- What is a Sample Ratio Mismatch? · 2026-07-03
- What role do guardrails play in A/B testing LLM applications?