Chatbot Quality Metrics: Joint Probability and A/B Testing
Statistics & ExperimentsModel answerLast updated
Apply independence rules, expected counts with uncertainty, and a two-proportion hypothesis test to evaluate and compare chatbot response quality.
Scenario
You are a data scientist reviewing the output quality of a customer-service chatbot. Internal evaluation has established two metrics for any given response:
- P(accurate) = 0.7
- P(on-topic) = 0.8
Part 1 — Joint probability
Assuming accuracy and on-topic-ness are independent events, what is the probability that a single response is both accurate and on-topic? Briefly explain what happens to that estimate if the independence assumption does not hold.
Part 2 — Expected count
You pull a random sample of 1,000 logged responses. How many would you expect to be neither accurate nor on-topic? Attach an appropriate measure of uncertainty to that estimate.
Part 3 — Comparing two models
Your team wants to decide whether a new model (Model B) produces on-topic responses at a different rate than the current model (Model A). Describe, end to end, how you would run a hypothesis test at significance level α = 0.05, including:
- how you would collect and label the data
- the hypotheses and test statistic
- a worked numerical example
- how to interpret a non-significant result
- when you would use a different test instead
A strong answer will also address sample size planning and at least two practical pitfalls.
Hints
Hint 1
For Part 1, the product rule P(A ∩ B) = P(A)·P(B) only holds under independence — think about Fréchet bounds for the general case and whether honesty and relevance are likely positively or negatively correlated in practice.
Hint 2
For Part 2, use complements or inclusion-exclusion to find P(neither), then model the count as a Binomial to get the standard deviation — if your observed count is far outside ±2 SDs, that is evidence your assumptions are off.
Hint 3
For Part 3, know when to use the pooled versus unpooled standard error, why the paired design (same prompts shown to both models) calls for McNemar's test instead of a two-proportion z-test, and why a non-significant p-value is not the same as proving the models are equivalent.
Model answer
Easy Try it yourself first — then compare your approach, complexity and edge cases.
Solution Walkthrough
This question tests three skills in sequence: applying basic probability rules correctly, translating a probability into an expected count with proper uncertainty, and setting up a two-proportion test without confusing pooled and unpooled standard errors. Strong candidates also challenge the independence assumption rather than accepting it silently.
Part 1: P(accurate AND on-topic)
Let A = accurate, T = on-topic, with P(A) = 0.7 and P(T) = 0.8.
Under independence:
$$P(A \cap T) = P(A) \cdot P(T) = 0.7 \times 0.8 = \mathbf{0.56}$$
What if independence fails? The Fréchet bounds give the full range without any distributional assumption:
$$\max(0,\ 0.7 + 0.8 - 1) \le P(A \cap T) \le \min(0.7, 0.8) ;\Rightarrow; 0.5 \le P(A \cap T) \le 0.7$$
In practice, accuracy and on-topic-ness are almost certainly positively correlated — a model that understood the question is more likely to be both on-point and factually correct. That makes 0.56 a likely underestimate. You can verify this empirically by comparing the observed joint rate in logs against the product of the marginals, using a chi-square test of independence on the 2×2 contingency table.
Part 2: Expected count of "neither" in 1,000 responses
Using complements (independence assumed):
$$P(A^c \cap T^c) = (1 - 0.7)(1 - 0.8) = 0.3 \times 0.2 = 0.06$$
Cross-check via inclusion-exclusion:
$$P(A \cup T) = 0.7 + 0.8 - 0.56 = 0.94 ;\Rightarrow; P(\text{neither}) = 1 - 0.94 = 0.06\ ✓$$
Expected count: 1,000 × 0.06 = 60 responses.
Uncertainty: The count follows Binomial(1000, 0.06):
$$\text{SD} = \sqrt{1000 \times 0.06 \times 0.94} = \sqrt{56.4} \approx 7.5$$
A plausible 95% range is roughly 45 to 75. Observing 30 or 100 should make you question either the stated marginal probabilities or the independence assumption.
Without independence, P(neither) = 1 − P(A ∪ T), and since P(A ∪ T) ∈ [0.8, 1.0], P(neither) ∈ [0, 0.2] — anywhere from 0 to 200 responses.
Part 3: Hypothesis test comparing two models' on-topic rates
Step 1 — Data collection and labeling. Use a shared prompt set drawn from the production distribution. Assign prompts randomly to both models, or better, have both models answer every prompt (paired design). Use human raters with a clear rubric, blind to which model produced each response. Measure inter-rater agreement (Cohen's κ) before proceeding. Fix the sample size in advance; do not peek at results and stop early.
Step 2 — Hypotheses. Two-sided unless you pre-committed to a direction:
$$H_0: p_A = p_B \qquad H_1: p_A \ne p_B$$
Step 3 — Test statistic (independent samples).
$$\hat p = \frac{x_A + x_B}{n_A + n_B}, \qquad z = \frac{\hat p_A - \hat p_B}{\sqrt{\hat p(1-\hat p)!\left(\tfrac{1}{n_A} + \tfrac{1}{n_B}\right)}}$$
Use the pooled estimate $\hat p$ in the denominator because the SE is computed under $H_0$ (where $p_A = p_B$). The normal approximation holds when each group has at least ~10 successes and ~10 failures.
Step 4 — Worked example. Model A: 820/1000 on-topic; Model B: 790/1000.
- $\hat p_A = 0.82$, $\hat p_B = 0.79$, observed difference = 0.03
- Pooled $\hat p = 1610/2000 = 0.805$
- $\text{SE} = \sqrt{0.805 \times 0.195 \times (2/1000)} \approx 0.0177$
- $z = 0.03 / 0.0177 \approx 1.69$, two-sided $p \approx 0.09$
Since $p > 0.05$, we fail to reject $H_0$. There is insufficient evidence of a difference.
Step 5 — Report a confidence interval (using the unpooled SE here, since we are estimating the difference, not testing under $H_0$):
$$\text{SE}_{\text{unpooled}} = \sqrt{\tfrac{0.82 \times 0.18}{1000} + \tfrac{0.79 \times 0.21}{1000}} \approx 0.0177$$
$$95%\ \text{CI}: 0.03 \pm 1.96 \times 0.0177 \approx (-0.005,\ 0.065)$$
The interval includes 0 (consistent with the test), but also shows that Model A could plausibly be up to 6.5 percentage points better — which may be practically meaningful.
Step 6 — Power and sample size. To detect a 3-point difference (0.82 vs. 0.79) with 80% power at α = 0.05:
$$n \approx \frac{(1.96 + 0.84)^2,[p_A(1-p_A) + p_B(1-p_B)]}{\delta^2} = \frac{7.84 \times 0.3135}{0.0009} \approx 2{,}730\ \text{per model}$$
1,000 responses per arm was underpowered for this effect size — which is exactly why the result was non-significant. A non-significant result is not evidence of equivalence; report the CI and the power.
Step 7 — When to use a different test. If both models answer the same prompts, the samples are paired and the two-proportion z-test is wrong. Use McNemar's test, which focuses on discordant pairs:
- $b$ = prompts where A is on-topic but B is not
- $c$ = prompts where B is on-topic but A is not
$$\chi^2 = \frac{(b - c)^2}{b + c} \sim \chi^2_1$$
Use an exact binomial test when $b + c$ is small (under ~25). Pairing removes prompt-difficulty variance and typically requires far fewer samples.
Common Mistakes
- Multiplying probabilities without stating the independence assumption, or blindly assuming it holds.
- Computing P(A or T) as 0.7 + 0.8 = 1.5. Always subtract the intersection.
- Using the pooled SE for the confidence interval, or the unpooled SE for the z-test statistic — these serve different purposes.
- Treating a non-significant result as proof that the models perform equally. It is not.
- Running an independent-samples test on paired data. Use McNemar's test instead.
- Ignoring clustering: multiple responses from the same conversation are correlated. Sample one response per session, or use cluster-robust standard errors.
- Testing multiple model pairs or metrics at α = 0.05 each without multiplicity correction. Apply Bonferroni or Holm, or pre-register a single primary metric.
- Ignoring label noise. An inconsistent human rater or a biased LLM judge can skew the comparison in favor of whichever model's style the judge happens to prefer.
Summary Table
| Quantity | Answer |
|---|---|
| P(accurate ∩ on-topic), independent | 0.56 |
| P(neither), independent | 0.06 |
| Expected "neither" in 1,000 responses | 60 (SD ≈ 7.5) |
| Correct test, independent samples | Two-proportion z-test; reject $H_0$ if $p < 0.05$ |
| Correct test, paired samples | McNemar's test |
| Non-significant result means | Insufficient evidence of a difference — report the CI and power |