advanced nlp-evaluation 40 min read

Significance Testing for NLP

Resampled corpora are points on a simplex, and swapped outputs are vertices of a cube. A corpus metric is a surface over both. Randomization is exact on any surface, the bootstrap only where the surface is smooth, and neither sees the variance that the resampled unit hides.

Overview & Motivation

The overlap-metrics topic scored ten summarizers on 90 synthetic filings and reported every gap as a point estimate. Some of those gaps are tiny. The reference-style writer beats the same writer with a tenth of its facts reversed by 0.00680.0068 corpus BLEU, and the extractive baseline beats TextRank by 0.00610.0061. Are those differences real, or would another 90 filings reverse them?

A significance test answers a narrower question than that, and this page is about the narrowing. Every test here compares two systems on one paired test set: each segment (a filing, a sentence, a prompt) has an output from each system. Everything starts from two pictures of “another test set like this one.”

  • The paired bootstrap resamples segments with replacement. A resample is a weight vector on the segments, a point of the simplex, and the observed test set is its center.
  • Approximate randomization swaps the two systems’ outputs on a random subset of segments. A swap pattern is a vertex of the cube {0,1}n\lbrace 0, 1 \rbrace^n.

A corpus metric is a function of the pooled statistics, so it is a surface over the simplex and over the cube. Corpus BLEU is not an average of per-segment scores, and that is why the tests built for means, the paired t-test of formalRAG’s significance topic, do not apply as they stand.

  1. Randomization is exact for any metric. Its Monte Carlo p-value is valid for every statistic and every number of draws (Theorem 1), and on right-or-wrong outcomes it is McNemar’s test (Proposition 1).
  2. The bootstrap gives two p-values. The two rules in common use invert two different intervals (Proposition 2). Corpus BLEU is asymptotically an average away from the brevity penalty’s kink (Theorem 2), and at the kink the bootstrap fails (Proposition 3).
  3. What the resampled unit hides. Clustered segments multiply a variance by a design effect (Theorem 3), and a test set says nothing about the variance from training (Theorem 4).
  4. Power and multiplicity. How many segments a gap needs (Proposition 4), and what it costs to report whichever metric rejects (Proposition 5).

Two testbeds have something real data rarely offer: a known truth. The decoding topic’s trigram generates two outputs per prompt from one distribution, so the null hypothesis holds exactly, and we can count how often each test rejects it. Topic 17’s simulated worlds let us redraw the training set as often as we like.


The unit of resampling

Definition 1 (Paired evaluation set and corpus metric).

A paired evaluation set has nn segments. Segment ii carries both systems’ outputs, the references, and per-system sufficient statistics siA,siB∈RKs_i^A, s_i^B \in \mathbb{R}^K. A corpus metric is

M=g(∑i=1nsi),M = g\Big(\sum_{i=1}^n s_i\Big),

and with weights w∈R≥0nw \in \mathbb{R}^n_{\ge 0}, Mw=g(∑iwisi)M_w = g(\sum_i w_i s_i). The test statistic is δ=M(A)−M(B)\delta = M(A) - M(B). The metric is decomposable when it is a mean: si=(xi,1)s_i = (x_i, 1) and g(P)=P1/P2g(P) = P_1/P_2.

For corpus BLEU the statistics are the ten numbers (c,r,m1,…,m4,t1,…,t4)(c, r, m_1, \dots, m_4, t_1, \dots, t_4) of the overlap topic: candidate length, closest reference length, clipped matches, and n-gram totals. Its gg is

g(P)=exp⁡(min⁡(0, 1−Pr/Pc)+14∑n=14log⁡PmnPtn),g(P) = \exp\Big(\min\big(0,\ 1 - P_r/P_c\big) + \frac{1}{4} \sum_{n=1}^{4} \log \frac{P_{m_n}}{P_{t_n}}\Big),

a function of ratios of pooled sums. So gg is homogeneous of degree 00: multiplying every weight by the same constant changes nothing, and weights on the simplex {w≥0:∑iwi=1}\lbrace w \ge 0 : \sum_i w_i = 1 \rbrace describe every resample. Accuracy is decomposable, and so is any mean of segment scores. Corpus BLEU and F1 are not.

Definition 2 (Paired bootstrap).

Draw counts (N1,…,Nn)∼Multinomial(n;1/n,…,1/n)(N_1, \dots, N_n) \sim \mathrm{Multinomial}(n; 1/n, \dots, 1/n), a random point w∗=N/nw^* = N/n of the simplex, and compute δ∗=Mw∗(A)−Mw∗(B)\delta^* = M_{w^*}(A) - M_{w^*}(B) with the same weights for both systems. Repeat BB times.

Koehn (2004, §6) draws 1,000 resampled test sets this way and writes that if one system wins on 95% of them, it is “better with 95% statistical significance.” We return to what that sentence means in Proposition 2.

Definition 3 (Approximate randomization).

For a swap pattern ε∈{0,1}n\varepsilon \in \lbrace 0, 1 \rbrace^n, let ε⋅X\varepsilon \cdot X exchange the two systems’ statistics siAs_i^A and siBs_i^B at every segment with εi=1\varepsilon_i = 1, and let δε\delta_\varepsilon be the statistic on the swapped data. Draw ε1,…,εB\varepsilon_1, \dots, \varepsilon_B independently and uniformly from the cube, and set

p=1+#{b:∣δεb∣≥∣δ^∣}B+1.p = \frac{1 + \#\lbrace b : |\delta_{\varepsilon_b}| \ge |\hat\delta| \rbrace}{B + 1}.

This is Riezler and Maxwell’s procedure (2005, Fig. 1), which they credit to Noreen (1989): each sentence’s statistic tuple is shuffled between the two systems with probability one half. The swap patterns form a group, G=(Z/2)nG = (\mathbb{Z}/2)^n under coordinatewise addition, and GG acts on the paired data.

The two pictures put their clouds in different places. The bootstrap cloud of δ∗\delta^* sits around the observed δ^\hat\delta; the randomization cloud of δε\delta_\varepsilon sits around 00, because a random swap pattern scrambles which system is which. The lab’s Two clouds tab draws both for five pairs of the overlap topic’s systems. For the writer against noisy-0.1 on all 90 filings, the observed gap is 0.00680.0068, and randomization gives p=0.0005p = 0.0005. For the extract against TextRank, the gap is 0.00610.0061 and p=0.2017p = 0.2017. Gaps of the same size, opposite verdicts. The first pair shares its whole surface and differs only in reversed verbs, so its gap barely varies from filing to filing; the second pair differs everywhere.


Randomization is exact for any metric

The hypothesis randomization tests is stronger than “equal expected BLEU.” The sharp null says that at every segment, the two systems’ outputs are exchangeable: the data have the same distribution after any swap pattern, ε⋅X=dX\varepsilon \cdot X \overset{d}{=} X for every ε∈G\varepsilon \in G. It holds, for example, when the two systems are one stochastic system run twice.

Theorem 1 (Monte Carlo randomization p-values are valid).

Under the sharp null, let TT be any statistic of the paired data, let ε1,…,εB\varepsilon_1, \dots, \varepsilon_B be independent and uniform on GG, independent of the data, and let p=(1+#{b:T(εb⋅X)≥T(X)})/(B+1)p = \big(1 + \#\lbrace b : T(\varepsilon_b \cdot X) \ge T(X) \rbrace\big)/(B + 1). Then for every B≥1B \ge 1 and every α∈[0,1]\alpha \in [0, 1],

P(p≤α)≤α.P(p \le \alpha) \le \alpha.
Proof.

Let U0U_0 be uniform on GG, independent of XX and of the εb\varepsilon_b, and set X′=U0⋅XX' = U_0 \cdot X. By the sharp null, X′=dXX' \overset{d}{=} X, and the εb\varepsilon_b are independent of both, so the vector (T(X′),T(ε1⋅X′),…,T(εB⋅X′))\big(T(X'), T(\varepsilon_1 \cdot X'), \dots, T(\varepsilon_B \cdot X')\big) has the same distribution as the one the test uses. Now εb⋅X′=(εb+U0)⋅X\varepsilon_b \cdot X' = (\varepsilon_b + U_0) \cdot X. The map (u,e1,…,eB)↦(u,e1+u,…,eB+u)(u, e_1, \dots, e_B) \mapsto (u, e_1 + u, \dots, e_B + u) is a bijection of GB+1G^{B+1}, so the elements V0=U0V_0 = U_0 and Vb=εb+U0V_b = \varepsilon_b + U_0 are again independent and uniform on GG, and independent of XX. Permuting the indices of (V0,…,VB)(V_0, \dots, V_B) does not change their joint distribution, so Tj=T(Vj⋅X)T_j = T(V_j \cdot X), j=0,…,Bj = 0, \dots, B, are exchangeable.

Let Rj=#{i:Ti≥Tj}R_j = \#\lbrace i : T_i \ge T_j \rbrace, which counts jj itself; the test’s p-value is R0/(B+1)R_0/(B + 1). For any kk, the set J={j:Rj≤k}J = \lbrace j : R_j \le k \rbrace has at most kk elements: if j∗j^* is the element of JJ with the smallest TT, every j∈Jj \in J has Tj≥Tj∗T_j \ge T_{j^*}, so ∣J∣≤Rj∗≤k|J| \le R_{j^*} \le k. By exchangeability each jj is equally likely to be the observed index, so

P(R0≤k)=1B+1∑j=0BP(Rj≤k)=E∣J∣B+1≤kB+1.P(R_0 \le k) = \frac{1}{B + 1} \sum_{j=0}^{B} P(R_j \le k) = \frac{E|J|}{B + 1} \le \frac{k}{B + 1}.

With k=⌊α(B+1)⌋k = \lfloor \alpha (B + 1) \rfloor, P(p≤α)=P(R0≤k)≤k/(B+1)≤αP(p \le \alpha) = P(R_0 \le k) \le k/(B + 1) \le \alpha. Ties among the TjT_j only shrink ∣J∣|J|, so they make the test conservative, never liberal.

∎

Nothing in the proof uses the form of TT: it holds for corpus BLEU, F1, or any statistic of the paired data, for any number of segments. Averaging over the whole group instead of BB draws is formalML’s permutation-test exactness (Theorem 3 there). Two details matter in practice. The "+1+1" counts the observed data as one of the draws; dropping it, as b/Bb/B, can return p=0p = 0 and inflates the type I error (Phipson and Smyth 2010, §3). And the Monte Carlo error is controlled by Hoeffding’s inequality (formalML, Concentration Inequalities, Theorem 4): B≥log⁡(2/η)/(2ϵ2)B \ge \log(2/\eta)/(2\epsilon^2) draws put the Monte Carlo p-value within ϵ\epsilon of the full-group one with probability 1−η1 - \eta.

An exact null. The decoding topic’s trigram draws 64 independent samples for each of its 188 MD&A prompts. Pair sample jj with sample j+32j + 32, call one “system A” and the other “system B,” and the sharp null holds by construction. Four sample streams give 128 such experiments. Splitting the prompts into disjoint blocks gives more, all independent: 2,304 experiments of 10 prompts, 1,152 of 20, and so on. At α=0.05\alpha = 0.05, randomization on corpus BLEU rejects in a share

prompts10204794188
experiments2,3041,152512256128
rejection rate0.0490.0490.0410.0410.0390.0390.0510.0510.0620.062

of them, each inside the binomial band around 0.050.05. The p-values are superuniform, not uniform: with 10 prompts many swaps change nothing (two empty samples swap into themselves), so the p-values have atoms, and the share below 0.50.5 falls short of 0.50.5. Theorem 1 promises exactly this inequality and no more. The lab’s A/A tab shows the histograms.

Right-or-wrong outcomes make the cube small enough to sum over by hand.

Proposition 1 (On 0/1 losses, randomization is McNemar's exact test).

Let ciA,ciB∈{0,1}c_i^A, c_i^B \in \lbrace 0, 1 \rbrace record whether each system is right on segment ii, and let n10n_{10} and n01n_{01} count the segments where only AA and only BB is right. The full-group randomization test of δ=cA‾−cB‾\delta = \overline{c^A} - \overline{c^B} rejects exactly when McNemar’s exact test does: conditional on nd=n10+n01n_d = n_{10} + n_{01}, the null distribution of n10n_{10} is Bin(nd,12)\mathrm{Bin}(n_d, \tfrac12), and the two-sided p-value is min⁡(1, 2F(min⁡(n10,n01)))\min\big(1,\ 2 F(\min(n_{10}, n_{01}))\big) with FF that binomial distribution function.

Proof.

A swap changes nothing on a segment where the systems agree. On a discordant segment it changes the sign of that segment’s contribution ciA−ciB=±1c_i^A - c_i^B = \pm 1. So under a uniform swap pattern, nδε=∑i discordantσin \delta_\varepsilon = \sum_{i \text{ discordant}} \sigma_i, with the σi\sigma_i independent and equal to ±1\pm 1 with probability one half each. Writing XX for the number of +1+1 signs, nδε=2X−ndn\delta_\varepsilon = 2X - n_d with X∼Bin(nd,12)X \sim \mathrm{Bin}(n_d, \tfrac12), and the observed value is n10−n01=2n10−ndn_{10} - n_{01} = 2 n_{10} - n_d. The full-group p-value is P(∣2X−nd∣≥∣n10−n01∣)P\big(|2X - n_d| \ge |n_{10} - n_{01}|\big), which by the symmetry of Bin(nd,12)\mathrm{Bin}(n_d, \tfrac12) equals 2F(min⁡(n10,n01))2F(\min(n_{10}, n_{01})), capped at 11. That is the sign test on the discordant pairs (formalML, Rank Tests, Theorem 1).

∎

McNemar (1947) gave the large-sample version; Dietterich (1998, §3.1) recommends it with a continuity correction, and Card et al. (2020, §3.1) call it the standard test for two classifiers. The exact form needs no correction. On the finance tone classifiers of Topic 17, the harness checks the equality exactly on enumerated subsets of 14 filings and against SciPy’s binomtest.


The bootstrap’s two p-values

Koehn’s rule reads the bootstrap cloud directly: count the resamples where AA does not win. The rule of Berg-Kirkpatrick, Burkett, and Klein (2012, Fig. 1) counts something else: resamples where AA wins by at least twice the observed gain. Their reason (§2.2) is that the resampled gains average around the observed gain, not around 00, so the cloud has to be shifted to 00 before it can play the null.

Proposition 2 (The two rules invert two intervals).

Let δ(1)∗≤⋯≤δ(B)∗\delta^*_{(1)} \le \dots \le \delta^*_{(B)} be the ordered bootstrap gains, and for α∈(0,1)\alpha \in (0, 1) let qα=δ(⌊αB⌋+1)∗q_\alpha = \delta^*_{(\lfloor \alpha B \rfloor + 1)} and q1−α=δ(B−⌊αB⌋)∗q_{1 - \alpha} = \delta^*_{(B - \lfloor \alpha B \rfloor)}. For the one-sided alternative that AA is better:

(a) Koehn’s p-value pK=#{b:δb∗≤0}/Bp_K = \#\lbrace b : \delta^*_b \le 0 \rbrace / B satisfies pK≤αp_K \le \alpha if and only if qα>0q_\alpha \gt 0: zero lies below the lower end of the one-sided percentile interval.

(b) The recentered p-value p2δ=#{b:δb∗≥2δ^}/Bp_{2\delta} = \#\lbrace b : \delta^*_b \ge 2\hat\delta \rbrace / B satisfies p2δ≤αp_{2\delta} \le \alpha if and only if 2δ^−q1−α>02\hat\delta - q_{1-\alpha} \gt 0: zero lies below the lower end of the one-sided basic interval.

(c) If the bootstrap distribution is symmetric about δ^\hat\delta, then pK=p2δp_K = p_{2\delta}.

Proof.

(a) The count #{δb∗≤0}\#\lbrace \delta^*_b \le 0 \rbrace is an integer, so it is at most αB\alpha B exactly when it is at most ⌊αB⌋\lfloor \alpha B \rfloor, which happens exactly when the (⌊αB⌋+1)(\lfloor \alpha B \rfloor + 1)-th smallest gain is positive.

(b) In the same way, #{δb∗≥2δ^}≤⌊αB⌋\#\lbrace \delta^*_b \ge 2\hat\delta \rbrace \le \lfloor \alpha B \rfloor exactly when the (⌊αB⌋+1)(\lfloor \alpha B \rfloor + 1)-th largest gain, q1−αq_{1-\alpha}, is below 2δ^2\hat\delta. The basic interval reflects the bootstrap quantiles through δ^\hat\delta, so its lower end is 2δ^−q1−α2\hat\delta - q_{1-\alpha}.

(c) Symmetry says δ∗−δ^\delta^* - \hat\delta and δ^−δ∗\hat\delta - \delta^* have the same distribution, that is, δ∗\delta^* and 2δ^−δ∗2\hat\delta - \delta^* do. Then P∗(δ∗≤0)=P∗(2δ^−δ∗≤0)=P∗(δ∗≥2δ^)P^*(\delta^* \le 0) = P^*(2\hat\delta - \delta^* \le 0) = P^*(\delta^* \ge 2\hat\delta).

∎

Berg-Kirkpatrick et al. count strictly (>\gt) and note the symmetric equivalence themselves (footnote 2); we count ≥\ge, the conservative choice. A third rule is in wide use. sacreBLEU’s paired bootstrap follows Riezler and Maxwell (Fig. 2) and Noreen: it subtracts the mean of ∣δ∗∣|\delta^*| from each ∣δ∗∣|\delta^*| and compares the result with ∣δ^∣|\hat\delta|, a recentering of absolute gains. Three conventions, three intervals, the same name.

When do they differ? For the writer against noisy-0.1 on all 90 filings, pK=0p_K = 0 and p2δ=0.0040p_{2\delta} = 0.0040: the cloud is skewed, and no resample has the writer losing. On the exact A/A null, the bootstrap rules hold their size only asymptotically. At α=0.05\alpha = 0.05 the shares of A/A experiments rejected are

prompts10204794188
Koehn0.0370.0370.0600.0600.0640.0640.0470.0470.0620.062
recentered (2δ2\delta)0.0690.0690.0600.0600.0610.0610.0590.0590.0550.055
randomization0.0490.0490.0410.0410.0390.0390.0510.0510.0620.062

At 10 prompts the recentered rule rejects 0.0690.069 of true nulls, outside the band (its edge is 0.0640.064) that randomization stays inside. From 94 prompts both bootstrap rules are back inside. Riezler and Maxwell (2005, §4.3) found the same direction on real MT systems: the bootstrap rejected more often than randomization on systems they considered equivalent.

A degenerate case shows how far the rules can part. On 10 filings, the extract and TextRank match no 4-gram between them, so corpus BLEU is 00 on most resamples and the bootstrap cloud is mostly a spike. There p2δ=0.0005p_{2\delta} = 0.0005, while randomization gives p=0.8545p = 0.8545.


Corpus BLEU near and far from its kink

The bootstrap needs the metric to be smooth near the truth. Corpus BLEU is smooth almost everywhere, and where it is, a corpus score behaves like a mean of per-segment contributions.

Theorem 2 (Corpus BLEU is asymptotically a mean).

Let Zi=(siA,siB)Z_i = (s_i^A, s_i^B) be i.i.d. with finite second moments, mean μ\mu, and covariance Σ\Sigma, and let δ(z)=g(zA)−g(zB)\delta(z) = g(z^A) - g(z^B) be the corpus-BLEU gap as a function of the mean statistics. Suppose every expected match count is positive and each system has Ec≠ErE c \ne E r. Then, with Zˉ\bar Z the sample mean,

(a) n(δ(Zˉ)−δ(μ))→N(0, ∇δ(μ)⊤Σ ∇δ(μ))\sqrt n\big(\delta(\bar Z) - \delta(\mu)\big) \to \mathcal N\big(0,\ \nabla\delta(\mu)^\top \Sigma\, \nabla\delta(\mu)\big);

(b) δ(Zˉ)=δ(μ)+1n∑i∇δ(μ)⋅(Zi−μ)+op(n−1/2)\delta(\bar Z) = \delta(\mu) + \frac1n \sum_i \nabla\delta(\mu) \cdot (Z_i - \mu) + o_p(n^{-1/2}), so each segment contributes its influence ∇δ(μ)⋅(Zi−μ)\nabla\delta(\mu) \cdot (Z_i - \mu);

(c) conditional on the data, the paired bootstrap’s n(δ(Zˉ∗)−δ(Zˉ))\sqrt n\big(\delta(\bar Z^*) - \delta(\bar Z)\big) converges to the same normal law, almost surely.

Proof.

Near μ\mu, log⁡g\log g is a sum of logarithms of positive ratios and, because Ec≠ErE c \ne E r, the brevity term is either identically 00 or the smooth 1−zr/zc1 - z_r/z_c. So δ\delta is continuously differentiable on a neighborhood of μ\mu. Its gradient is g⋅∇log⁡gg \cdot \nabla \log g for each system, and ∇log⁡g\nabla \log g has entries r/c2r/c^2 and −1/c-1/c in the length coordinates when c<rc \lt r (zero when c>rc \gt r), and 1/(4mn)1/(4 m_n) and −1/(4tn)-1/(4 t_n) in the match and total coordinates.

By the multivariate central limit theorem (formalStatistics, Central Limit Theorem, Theorem 7), n(Zˉ−μ)→N(0,Σ)\sqrt n(\bar Z - \mu) \to \mathcal N(0, \Sigma), so Zˉ−μ=Op(n−1/2)\bar Z - \mu = O_p(n^{-1/2}). Differentiability at μ\mu gives

δ(Zˉ)−δ(μ)=∇δ(μ)⋅(Zˉ−μ)+o(∣Zˉ−μ∣),\delta(\bar Z) - \delta(\mu) = \nabla\delta(\mu) \cdot (\bar Z - \mu) + o(|\bar Z - \mu|),

and n⋅o(∣Zˉ−μ∣)=op(1)\sqrt n \cdot o(|\bar Z - \mu|) = o_p(1). This is (b), since ∇δ(μ)⋅(Zˉ−μ)\nabla\delta(\mu) \cdot (\bar Z - \mu) is the mean of the influences. A fixed linear function of an asymptotically normal vector is asymptotically normal with variance ∇δ⊤Σ∇δ\nabla\delta^\top \Sigma \nabla\delta, which is (a). This is the delta method of formalStatistics (Theorem 8 there) in several dimensions at once.

For (c), Bickel and Freedman (1981) show that conditional on the data, n(Zˉ∗−Zˉ)→N(0,Σ)\sqrt n(\bar Z^* - \bar Z) \to \mathcal N(0, \Sigma) almost surely. The sample mean Zˉ\bar Z converges to μ\mu almost surely, so eventually it lies in the neighborhood where δ\delta is continuously differentiable, and the same expansion around Zˉ\bar Z gives n(δ(Zˉ∗)−δ(Zˉ))=∇δ(Zˉ)⋅n(Zˉ∗−Zˉ)+oP∗(1)\sqrt n\big(\delta(\bar Z^*) - \delta(\bar Z)\big) = \nabla\delta(\bar Z) \cdot \sqrt n(\bar Z^* - \bar Z) + o_{P^*}(1), with ∇δ(Zˉ)→∇δ(μ)\nabla\delta(\bar Z) \to \nabla\delta(\mu).

∎

Geometrically: near the center of the simplex the surface MwM_w is a plane, and the bootstrap cloud, which shrinks like n−1/2n^{-1/2}, sees only the plane. The scalar case is formalStatistics’ Efron–Bickel–Freedman theorem (Theorem 3 there). Theorem 2 also explains the two clouds’ common spread: to first order a swap pattern changes δ\delta by a sum of signed influences, with the same variance as the bootstrap sum.

On the finance systems, the bootstrap standard deviation of the gap matches the linearization within 5%5\% whenever both systems pool at least 50 matched 4-grams: 0.00220.0022 against 0.00220.0022 for the writer and noisy-0.1. The extractors pool only 3 to 7 matched 4-grams over 90 filings, log⁡m4\log m_4 is far from linear on that scale, and the two differ by 11%11\% (0.00500.0050 against 0.00450.0045). In the bootstrap world, where the 90 filings are the population, the remainder m ∣δ∗−δ^−ψˉ∗∣\sqrt m\, |\delta^* - \hat\delta - \bar\psi^*| shrinks from 0.00320.0032 to 0.000960.00096 to 0.000320.00032 as resamples grow from 30 to 300 to 3,000 segments, the m−1/2m^{-1/2} rate of (b).

The theorem excluded Ec=ErE c = E r. That case is not exotic: it is exactly where a well-tuned system sits.

Proposition 3 (The brevity penalty's kink).

Write log⁡BP=min⁡(0,u(Zˉ))\log \mathrm{BP} = \min(0, u(\bar Z)) with u(z)=1−zr/zcu(z) = 1 - z_r/z_c, and suppose Ec=ErE c = E r, so u(μ)=0u(\mu) = 0, and that a2=∇u⊤Σ∇u>0a^2 = \nabla u^\top \Sigma \nabla u \gt 0. Then

(a) nlog⁡BP(Zˉ)→min⁡(0,aW)\sqrt n \log \mathrm{BP}(\bar Z) \to \min(0, aW) with W∼N(0,1)W \sim \mathcal N(0, 1), a law with an atom of 12\tfrac12 at 00, not a Gaussian;

(b) the paired bootstrap is not consistent for it: for every t>0t \gt 0 there is an event of probability bounded away from 00 on which the bootstrap distribution function at tt stays at least 1−Φ(t/a)1 - \Phi(t/a) below the limit’s.

Proof.

(a) By Theorem 2’s argument applied to the smooth uu, Sn=n u(Zˉ)→aWS_n = \sqrt n\, u(\bar Z) \to aW. The map v↦min⁡(0,v)v \mapsto \min(0, v) is continuous and positively homogeneous, so nmin⁡(0,u(Zˉ))=min⁡(0,Sn)→min⁡(0,aW)\sqrt n \min(0, u(\bar Z)) = \min(0, S_n) \to \min(0, aW) by the continuous mapping theorem, and P(min⁡(0,aW)=0)=P(W≥0)=12P(\min(0, aW) = 0) = P(W \ge 0) = \tfrac12.

(b) Write Vn∗=n(u(Zˉ∗)−u(Zˉ))V_n^* = \sqrt n\big(u(\bar Z^*) - u(\bar Z)\big), which by Theorem 2(c) converges conditionally to N(0,a2)\mathcal N(0, a^2). The bootstrap quantity is

n(log⁡BP∗−log⁡BP^)=min⁡(0,Sn+Vn∗)−min⁡(0,Sn).\sqrt n\big(\log \mathrm{BP}^* - \log \widehat{\mathrm{BP}}\big) = \min(0, S_n + V_n^*) - \min(0, S_n).

The limit min⁡(0,aW)\min(0, aW) is at most 00, so its distribution function equals 11 at every t>0t \gt 0, and every t>0t \gt 0 is a continuity point. On the event Sn<−tS_n \lt -t, the bootstrap quantity is min⁡(−Sn,Vn∗)\min(-S_n, V_n^*), which is at most tt exactly when Vn∗≤tV_n^* \le t, an event of conditional probability tending to Φ(t/a)<1\Phi(t/a) \lt 1. Since Sn→aWS_n \to aW, the event Sn<−tS_n \lt -t has probability tending to P(aW<−t)>0P(aW \lt -t) \gt 0. So with probability bounded away from 00, the bootstrap distribution function at the continuity point tt misses the limit by about 1−Φ(t/a)1 - \Phi(t/a): the bootstrap law does not converge to the true limit in probability.

∎

The general fact behind (b) is Fang and Santos (2019, Theorem 3.1): with a Gaussian limit for the underlying means, the standard bootstrap is consistent for φ(Zˉ)\varphi(\bar Z) if and only if the directional derivative of φ\varphi is linear, and min⁡(0,⋅)\min(0, \cdot) is the textbook nonlinear one. Andrews (2000) gave the classic example, max⁡(Xˉ,0)\max(\bar X, 0) for a normal mean at the boundary μ=0\mu = 0.

How badly does it fail? The harness takes the reduced form φ(xˉ)=min⁡(0,xˉ)\varphi(\bar x) = \min(0, \bar x) for xˉ\bar x the mean of n=100n = 100 draws from N(h/n,1)\mathcal N(h/\sqrt n, 1), so hh measures the distance from the kink in standard errors, and bootstraps 2,000 datasets:

hhshare with φ^=0\hat\varphi = 0percentile coverbasic cover
−5-50.0000.0000.8860.8860.8870.887
−1-10.1690.1690.8850.8850.6320.632
−0.5-0.50.2980.2980.8930.8930.5440.544
000.5210.5210.9450.9450.9440.944
110.8340.8340.9960.9960.9960.996

Nominal coverage is 0.900.90. Far from the kink both intervals behave. Just on the linear side, the basic interval, the one the recentered rule inverts (Proposition 2), covers barely half the time; at the kink and beyond it, both over-cover. The bootstrap’s own atom, the share of resamples with φ∗=φ^\varphi^* = \hat\varphi, averages 0.3930.393 at h=0h = 0 but varies from dataset to dataset with standard deviation 0.3910.391 at n=100n = 100 and 0.3810.381 at n=400n = 400: a random law that does not settle, which is (b) in numbers.

The kink is live on the finance testbed. Every system that shares the writer’s surface sits at pooled c/r=1.0077c/r = 1.0077, almost on it. Within that family the two systems of a pair have identical lengths on every resample, so their brevity penalties cancel from the gap (the harness checks this). The kink bites when two systems differ in length near the reference length, as a well-tuned system and its slightly terser rival do.


Clustered segments

The bootstrap and randomization both treat segments as independent. Sentences from one filing are not: a reader that misreads a company’s sector misreads every sentence about it.

Definition 4 (Cluster bootstrap).

When segments fall into clusters (documents, or sentences holding several aspects), resample whole clusters with replacement and carry their segments along.

Theorem 3 (The design effect).

Let n=Kmn = Km segment scores fall into KK independent clusters of mm, each with variance σ2\sigma^2 and correlation ρ\rho between any two segments of one cluster. Then

(a) Var(xˉ)=σ2n(1+(m−1)ρ)\displaystyle \mathrm{Var}(\bar x) = \frac{\sigma^2}{n}\big(1 + (m - 1)\rho\big), and ρ≥−1/(m−1)\rho \ge -1/(m - 1);

(b) the segment bootstrap’s variance of the mean, 1n2∑i(xi−xˉ)2\frac{1}{n^2}\sum_i (x_i - \bar x)^2, has expectation σ2n(1−1+(m−1)ρn)\dfrac{\sigma^2}{n}\Big(1 - \dfrac{1 + (m - 1)\rho}{n}\Big), so its ratio to the truth tends to 1/(1+(m−1)ρ)1/(1 + (m - 1)\rho);

(c) the cluster bootstrap’s variance is consistent as K→∞K \to \infty.

Proof.

(a) Clusters are independent, so Var(∑ixi)\mathrm{Var}(\sum_i x_i) is KK times the variance of one cluster sum, which is mσ2+m(m−1)ρσ2m\sigma^2 + m(m - 1)\rho\sigma^2: mm variances and m(m−1)m(m - 1) covariances. Divide by n2=(Km)2n^2 = (Km)^2. A variance is nonnegative, so 1+(m−1)ρ≥01 + (m - 1)\rho \ge 0.

(b) Every xix_i has the same mean, so E∑i(xi−xˉ)2=∑iVar(xi)−nVar(xˉ)=nσ2−σ2(1+(m−1)ρ)E\sum_i (x_i - \bar x)^2 = \sum_i \mathrm{Var}(x_i) - n \mathrm{Var}(\bar x) = n\sigma^2 - \sigma^2\big(1 + (m - 1)\rho\big). Divide by n2n^2. As n→∞n \to \infty the ratio to (a) tends to 1/(1+(m−1)ρ)1/(1 + (m - 1)\rho).

(c) Resampling clusters is the ordinary bootstrap with clusters as the units, so its consistency is that of the bootstrap of a ratio of cluster means (Davison and Hinkley 1997, §3.8; Field and Welsh 2007).

∎

The factor 1+(m−1)ρ1 + (m - 1)\rho is the survey statistician’s design effect. It can be less than one, and the overlap topic’s neighbor, the aspect-sentiment topic, supplies an extreme case. Its 14,179 test aspects sit in 12,921 sentences in 1,500 filings, and every two-aspect sentence pairs opposite polarities. A reader blind to which aspect it is asked about is right on exactly one aspect of every such sentence, so within those sentences ρ=−1\rho = -1, and with sentences as clusters its design effect is 0.8230.823.

Documents push the other way. For the stand-in lexicon reader (accuracy 0.7850.785), the within-document correlation is 0.0570.057, and with about 9.5 aspects per filing the design effect is 1.5551.555: the cluster bootstrap’s standard error is 0.00430.0043 against the segment bootstrap’s 0.00350.0035. A confidence interval for one reader’s accuracy is a fifth too narrow if it treats aspects as independent. But the paired difference between the two readers has a within-document correlation of −0.012-0.012 and a design effect of 0.9310.931. Whatever makes a filing hard is hard for both readers, and pairing cancels it, as formalRAG’s Theorem 1 on pairing predicts. Comparisons survive clustering better than single scores do.


What a test set cannot tell you

Every test so far conditions on two trained systems. The claim usually wanted is about two ways of training a system, and those are different hypotheses.

Definition 5 (The procedure-level null).

A training procedure PP applied to a random training set DD gives a model with population accuracy acc(P,D)\mathrm{acc}(P, D). For two procedures let Δ(D)=acc(PA,D)−acc(PB,D)\Delta(D) = \mathrm{acc}(P_A, D) - \mathrm{acc}(P_B, D). The procedure-level null is ED[Δ(D)]=0E_D[\Delta(D)] = 0; the model-level null for one training set is Δ(D)=0\Delta(D) = 0.

Theorem 4 (A test set cannot test a procedure).

Let δ^\hat\delta be the test-set accuracy gap of the two models trained on DD, with E[δ^∣D]=Δ(D)E[\hat\delta \mid D] = \Delta(D).

(a) Var(δ^)=ED[Var(δ^∣D)]+VarD(Δ(D))\mathrm{Var}(\hat\delta) = E_D\big[\mathrm{Var}(\hat\delta \mid D)\big] + \mathrm{Var}_D\big(\Delta(D)\big), and resampling the test set estimates only the first term.

(b) Suppose the procedure-level null holds, P(Δ(D)=0)=π0P(\Delta(D) = 0) = \pi_0, and a level-α\alpha test-set test is consistent against every fixed Δ≠0\Delta \ne 0. As the test set grows, its probability of rejecting tends to at least 1−π01 - \pi_0 and at most 1−π0+π0α1 - \pi_0 + \pi_0 \alpha.

Proof.

(a) is the law of total variance, with E[δ^∣D]=Δ(D)E[\hat\delta \mid D] = \Delta(D); the test set is resampled with DD held fixed, so it sees only Var(δ^∣D)\mathrm{Var}(\hat\delta \mid D).

(b) Condition on DD. On {Δ(D)≠0}\lbrace \Delta(D) \ne 0 \rbrace consistency sends P(reject∣D)P(\text{reject} \mid D) to 11, and on {Δ(D)=0}\lbrace \Delta(D) = 0 \rbrace the level gives P(reject∣D)≤αP(\text{reject} \mid D) \le \alpha. These conditional probabilities lie in [0,1][0, 1], so by dominated convergence P(reject)=E[P(reject∣D)]P(\text{reject}) = E\big[P(\text{reject} \mid D)\big] has its limit points between 1−π01 - \pi_0 and 1−π0+π0α1 - \pi_0 + \pi_0\alpha.

∎

When Δ(D)\Delta(D) has a continuous distribution, π0=0\pi_0 = 0 and the rejection rate tends to one: a large enough test set “detects” a difference between procedures that are equal on average, in whichever direction this training set happened to favor. Topic 17’s bursty world makes this concrete. Naive Bayes is misspecified there and logistic regression is not, and their learning curves cross. Fix both procedures (add-one naive Bayes; logistic regression with λ=10−2\lambda = 10^{-2}), draw 40 training sets at each size, and find the size where the average population gap is smallest: 384 documents, where it is −0.0006±0.0013-0.0006 \pm 0.0013, zero to the draws’ precision. The between-draw variance of the gap is 6.5⋅10−56.5 \cdot 10^{-5}, larger than the within-draw variance a 3,000-document test set adds, 4.8⋅10−54.8 \cdot 10^{-5}. McNemar’s test on 3,000 test documents rejects in 0.1750.175 of the training draws, siding with logistic regression in some and with naive Bayes in others. On 20,000 test documents it rejects in 0.6250.625. A bigger test set answers the wrong question more confidently.

The remedy is to resample what varies: retrain on several training sets or seeds, as Dietterich’s 5x2cv test does (1998, §3.5), and compare the distributions of scores (Reimers and Gurevych 2017; Dror, Shlomov, and Reichart 2019). Reimers and Gurevych found that changing only the random seed moved one tagger from 89.9989.99 to 91.0091.00 F1, a gap that a test-set randomization test calls significant. The fine-tuning topic found the same on its own encoder, full fine-tuning ranging from 0.9700.970 to 0.9890.989 across three seeds.


Power and multiplicity

A test that cannot reject is uninformative, not reassuring. For McNemar’s test the power has a closed form.

Proposition 4 (The power of McNemar's exact test).

Let segments be independent, with probabilities p10p_{10} and p01p_{01} that only AA or only BB is right, pd=p10+p01p_d = p_{10} + p_{01}, and Δ=p10−p01\Delta = p_{10} - p_{01}. Then nd∼Bin(n,pd)n_d \sim \mathrm{Bin}(n, p_d), and given ndn_d, n10∼Bin(nd,p10/pd)n_{10} \sim \mathrm{Bin}(n_d, p_{10}/p_d), so the exact test’s power is

∑k=0n(nk)pdk(1−pd)n−k P(reject∣nd=k),\sum_{k=0}^{n} \binom{n}{k} p_d^k (1 - p_d)^{n-k} \, P\big(\text{reject} \mid n_d = k\big),

where the inner probability is a binomial tail beyond the exact test’s critical values. A normal approximation (Connor 1987) gives the sample size for power 1−β1 - \beta at two-sided level α\alpha:

n≈(z1−α/2pd+z1−βpd−Δ2)2Δ2.n \approx \frac{\Big(z_{1-\alpha/2} \sqrt{p_d} + z_{1-\beta} \sqrt{p_d - \Delta^2}\Big)^2}{\Delta^2}.
Proof.

Each segment is discordant with probability pdp_d, independently, and a discordant segment favors AA with probability p10/pdp_{10}/p_d, so the two binomials follow, and the power is the average of the conditional rejection probability over ndn_d. For the approximation: n10−n01n_{10} - n_{01} is a sum of nn independent terms in {−1,0,1}\lbrace -1, 0, 1 \rbrace with mean Δ\Delta and variance pd−Δ2p_d - \Delta^2. Under the null its variance is npdn p_d, and the test rejects when ∣n10−n01∣>z1−α/2npd|n_{10} - n_{01}| \gt z_{1-\alpha/2}\sqrt{n p_d}. Requiring that bound to lie z1−βz_{1-\beta} alternative standard deviations below the alternative mean nΔn\Delta and solving for nn gives the formula.

∎

Connor’s original is one-sided (z1−αz_{1-\alpha}); the two-sided form above is the usual approximation to it. At the approximate nn the exact power lands between 0.7760.776 and 0.7870.787 in four test cases, a little under the 0.800.80 asked for. Card et al. (2020) make the same point for NLP by simulation: power depends on the accuracy gap and on how often the systems agree.

On the finance tone classifiers of Topic 17 (1,500 test filings), the near-tie between the NB-weighted bigram model (0.7760.776) and the bigram logistic regression (0.7710.771) has 108 and 101 discordant filings and an exact McNemar p-value of 0.6780.678. Its power at 1,500 filings is 0.0670.067, and 80% power would take 50,21550{,}215 filings. The test set cannot resolve a half-point gap; “not significant” here means “not measured.”

The second hazard is choosing after looking. The overlap topic computed six metrics; an author who reports whichever one rejects has run six tests.

Proposition 5 (Metric shopping).

If kk tests each have size at most α\alpha, the test “reject if any of them rejects” has size at most kαk\alpha. If the kk tests are independent its size is 1−(1−α)k1 - (1 - \alpha)^k, and if they always agree it is α\alpha.

Proof.

The union bound: P(⋃jRj)≤∑jP(Rj)≤kαP(\bigcup_j R_j) \le \sum_j P(R_j) \le k\alpha (formalCalculus, Probability and the Union Bound, Corollary 1). Under independence, P(⋃jRj)=1−∏j(1−P(Rj))P(\bigcup_j R_j) = 1 - \prod_j (1 - P(R_j)). If the rejection events coincide, the union is one of them.

∎

On the exact A/A null with 10 prompts, testing corpus BLEU alone rejects 0.0500.050 of the time; adding the overlap topic’s six segment metrics one at a time raises the size to 0.0900.090, 0.0990.099, 0.1080.108, 0.1090.109, 0.1370.137, and 0.1610.161. The metrics are positively dependent, so the size stays well below the independent case’s 0.3020.302, but it more than triples. Holm’s step-down and Benjamini and Hochberg’s step-up procedures (formalStatistics, Multiple Testing and False Discovery, Theorems 3 and 5) control the family-wise error and the false discovery rate when many pairs or metrics are tested at once.


Finance case study

Corpus-BLEU gap of writer over noisy 0.1 on 90 filings: 4,000 bootstrap resamples and 4,000 random swaps
pair
filings
0100200300400-0.0050.0000.0050.0100.015gap in corpus BLEU
bootstrap δ* (centered near δ̂)randomization δ (centered at 0)observed δ̂zero
observed gap δ̂
0.0068
randomization p (two-sided)
0.0005
Koehn p (one-sided)
0.0000
2δ rule p (one-sided)
0.0040
bootstrap sd
0.0022
delta-method sd
0.0022

Koehn's p counts resamples where the first system does not win; the 2δ rule counts resamples that win by at least twice the observed gap. They invert the percentile and the basic interval (Proposition 2). The delta-method sd is Theorem 2's linearization; it is undefined when a system matches no 4-gram, and loose for the extractors, which match only a handful.


Where this sits

A corpus metric is a surface over the simplex of segment weights and over the cube of swaps. Randomization tests a sharp null and is exact for every statistic on that surface (Theorem 1); on right-or-wrong outcomes it is McNemar’s test (Proposition 1). The bootstrap’s two common p-values invert two different intervals (Proposition 2); away from the brevity penalty’s kink corpus BLEU is asymptotically a mean of influences and the bootstrap is consistent (Theorem 2), and at the kink it is not (Proposition 3). Clusters multiply a variance by the design effect, which pairing mostly cancels (Theorem 3), and no test set can test a training procedure (Theorem 4). McNemar’s power has a closed form (Proposition 4), and choosing the metric after the fact multiplies the size (Proposition 5).

The tests built here sit beside formalRAG’s significance topic, which covers the paired t-test, its power-based query count, and the variance pairing removes, and they apply unchanged to the entity-recognition topic’s span F1, another ratio of pooled counts. Every test on this page looks at the data once. Monitoring a system as test data arrive needs the anytime-valid tests of formalML’s always-valid inference.


Honest caveats


Implementation

The companion notebook (notebookPath) imports the topic’s Python module, which owns every number on this page. It imports the overlap topic’s module for BLEU’s statistics, the summarizers, the decoding prompts, and the trigram sampler; the linear-classifier topic’s module for the tone classifiers and the simulated worlds; and the aspect-sentiment topic’s module for the aspect rows. Corpus BLEU is computed for a whole batch of resamples at once, as pooled statistics times a matrix of weights or swaps. Its harness checks:

  • Theorem 1 on 4,352 experiments of the exact A/A null, against the full group of 4,096 swaps, and against SciPy’s permutation_test;
  • Proposition 1 against SciPy’s binomtest, exactly on enumerated subsets;
  • Proposition 2’s inversions on every bootstrap cloud, and the bootstrap rules’ sizes on the A/A null;
  • Theorem 2’s gradient against finite differences and its variance against the bootstrap, and Proposition 3 on its reduced form;
  • Theorem 3’s algebra exactly and on simulated clusters, and the aspect rows’ design effects;
  • Theorem 4 on 40 training draws at each of nine sizes, and Propositions 4 and 5;
  • every finance number this page states.

The laboratory reads its data from a JSON file that one of the harness’s tests requires to equal the module’s viz_payload() exactly, so the figure cannot drift from the code.

Connections

  • Its 188 MD&A prompts and the trigram it decodes supply the exact A/A null of Theorem 1: two ancestral samples of one prompt are exchangeable, so the sharp null holds by construction. beam-search-decoding
  • Its aspect rows sit inside sentences inside documents, and its aspect-blind reader is right on exactly one aspect of every contrast sentence, Theorem 3's example of a within-cluster correlation of minus one. aspect-based-sentiment
  • Its span F1 is another non-decomposable corpus metric, a ratio of pooled counts like corpus BLEU, so Theorems 1 and 2 apply to its system comparisons unchanged. named-entity-recognition
  • Its seed spreads, with full fine-tuning between 0.970 and 0.989 across three seeds, are the between-training variance of Theorem 4 measured on a real training procedure. fine-tuning-low-rank-adaptation

References & Further Reading