Manuscript Offprint
arXiv:2608.27428Stochastic Estimation of Transduced Language Models
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original. This text is shared under the same licence.
ABSTRACT
Transduced language models (TLMs) compose a pretrained source language model with a functional finite-state transducer to induce a language model over target strings. Computing the probability of a target prefix under a TLM amounts to summing the source-model probabilities of all source strings that the transducer maps to target strings beginning with that prefix. This set can be exponentially large or infinite. Prior work uses a computational shortcut based on source prefix probabilities, then approximates the resulting sum with threshold-pruned beam summing. This produces a lower bound with unknown error. Instead, we resample source prefixes without replacement and reweight each selected prefix by the inverse of its inclusion probability. We show that applying this correction recursively gives an unbiased estimator of the target prefix probability and lets us estimate the mass lost by threshold pruning. Our beam-summing algorithm extends the retained source prefixes and samples which prefixes to keep, reducing their number as more probability mass is added to the running estimate. This can save computation and guarantees that the run halts with probability one. We evaluate the method on encyclopedic text and DNA against sequential Monte Carlo baselines that resample with replacement. It achieves a better compute–variance tradeoff on text and lower error at the same maximum number of particles on DNA. On a DNA-to-amino-acid transduction, it reduces runtime by several orders of magnitude relative to threshold-pruned beam summing and makes estimating prefix probabilities for long target strings feasible. Replacing threshold pruning with unbiased sampling in a published reading-time analysis substantially lowers the estimated corpus surprisal but leaves the published conclusions unchanged.
1 INTRODUCTION
Language models define distributions over strings, while applications may require distributions induced by deterministic transformations of those strings. Snæbjarnarson et al. (2026) call this the string mismatch problem. They address it by composing a pretrained source model with a functional finite-state transducer, inducing a language model over target strings without retraining, a transduced language model (TLM). This makes it possible, for example, to compute word-level surprisal for reading-time prediction (Kiegeland et al., 2026) or to obtain a model over amino-acid strings from one defined over DNA strings. The TLM's next-symbol probabilities are obtained from its target prefix probabilities. Each target prefix probability amounts to summing the source-model probabilities of all source strings that the transducer maps to target strings with that prefix. This set of source strings is the target prefix's precover.
Snæbjarnarson et al. (2026) derive a computational shortcut for enumerating and marginalizing over the precover. They implement it as a beam-summing algorithm that enumerates source prefixes breadth-first. When every extension of a prefix belongs to the precover, the algorithm adds the prefix's entire probability mass to the running estimate. Otherwise, if the prefix itself belongs to the precover as a complete source string, it adds that string's probability. To keep the calculation manageable, Snæbjarnarson et al. (2026) prune low-weight prefixes along the way. With a sufficiently low thresh-old, beam summing can closely approximate the target prefix probability when most of the relevant mass is carried by a relatively small set of prefixes (Snæbjarnarson et al., 2026; Vieira et al., 2025).
To evaluate the impact of threshold pruning, the prior work compares normalized next-symbol distributions across thresholds, revealing changes in relative probabilities as the threshold varies. This does not, however, quantify the total mass discarded by pruning. The computation also becomes difficult when mass is spread across many similarly weighted prefixes. Retaining most of the mass then requires tracking many prefixes, and a practical threshold can discard a non-negligible amount. In such settings, the pruning error is unknown, and threshold-pruned beam summing can be too expensive for useful target lengths.
This work replaces threshold pruning with resampling without replacement. We sample distinct prefixes using weight-based inclusion probabilities and reweight each selected prefix by the inverse of its inclusion probability (Horvitz & Thompson, 1952; Fearnhead & Clifford, 2003; Shah & Kroese, 2018). This preserves each prefix's weight in expectation without changing the rest of the beam summing algorithm. We also reduce the number of retained prefixes as more probability mass is added to the running estimate, saving computation.
We show that this reweighting gives an unbiased estimator of the target prefix probability as long as the run halts with probability one (Theorem 3.3). We then show that adaptively reducing the number of retained prefixes preserves unbiasedness and that the resulting run halts with probability one (Proposition 3.4). Repeated runs estimate the sampling variation of the unbiased estimator, whereas deterministic threshold-pruned beam summing returns the same value every time. At each target prefix, the difference between the mean of the unbiased estimates and the threshold-pruned value is an estimate of the mass lost through pruning.
The experiments show that the method makes estimating prefix probabilities along longer target strings feasible under a high-entropy source model and quantifies how pruning bias affects a downstream analysis. On the DNA-to-amino-acid transduction, threshold-pruned beam summing exceeds a five-minute limit at target position 13, whereas the sampling-based version reaches position 200 in about five seconds (Fig. 9b). In psycholinguistics, Kiegeland et al. (2026) use a TLM to derive word-level surprisal from a token-level language model for reading-time prediction. Replacing threshold pruning with unbiased sampling changes the estimated corpus surprisal by 106 nats but leaves the published conclusions unchanged (§4.5). We compare against two unbiased sequential Monte Carlo (SMC) baselines that extend each retained prefix by one sampled live source symbol and use resampling with replacement. On encyclopedic text, resampling without replacement achieves a better compute–variance tradeoff than the SMC baselines. On DNA, it achieves lower error at the same maximum number of particles. Comparisons with exact target prefix probabilities validate the estimator where those values are available (§4).
2.1 LANGUAGE MODELS
Let be a set of symbols called an alphabet, and be the set of all finite strings of those symbols. We write , equivalently , when is a prefix of . A cylinder with basis is . We define the prefix-free operation as .
A language model is a distribution over . With EOS a special end-of-sequence symbol, we define the prefix probability and the conditional prefix probabilities as
§A collects all notation in one place.
When , we take and . An interface to the language model is then given by . When , the conditionals also give the distribution over the completions of a prefix, for , written .
2.2 TRANSDUCED LANGUAGE MODELS
A transduced language model is a language model characterized by the tuple where is a transducer encoding a function . Let be a random variable drawn from . For , we then define
and its prefix probability
Snæbjarnarson et al. (2026) give a computational shortcut by defining the quotient and remainder. For , we define the precover of with respect to as . Let , then is the largest union of cylinders (§2.1) contained in . The quotient and remainder are and . The computational shortcut is the quotient–remainder decomposition:
Snæbjarnarson et al. (2026) show that the decomposition counts every source string exactly once, since the precover splits as the disjoint union . Their algorithms use the predicates below to determine whether a given prefix belongs to the quotient or the remainder.
Precover predicates. The three predicates classify a source prefix x relative to :
Live, is_live(x, y): some extension covers y, that is .
Member, is_member(x, y): , the output emitted so far covers y.
Cylinder, is_cylinder(x, y): for every , every extension covers y.
These predicates locate the decomposition members Eq. (4): the first cylinder prefix on a path generates a cylinder of and so belongs to the quotient , a member that is not a cylinder is a remainder element of , and a non-live prefix is dropped. Finite-state transducers make these semantic tests computable. When f is encoded by a finite-state transducer, the Live, Member, and Cylinder predicates can be evaluated in finite time. Following Snæbjarnarson et al. (2026), the implementation evaluates them through lazy determination, expanding only the states reached as it enumerates source prefixes. The algorithms otherwise require only these three predicates and apply to any representation that can compute them.
3 UNBIASED ESTIMATION OF TRANSDUCED LANGUAGE MODELS
The quotient–remainder decomposition (Eq. (4)) writes the prefix probability of a transduced language model ( ) as a sum of source-model mass over the precover . That sum is often far too large to enumerate, so the beam summing of Snæbjarnarson et al. (2026) applies prune , discarding mass to keep the calculation manageable. We therefore replace deterministic pruning
Because a language model places all its mass on finite strings, ancestral sampling from these conditionals reaches EOS with probability one, and the mass beyond depth , , vanishes as grows. In practice an autoregressive model supplies the conditionals directly, and they define a language model exactly when their ancestral sampler terminates with probability one. Such conditionals are called tight (Cotterell et al., 2024).
def beam_summing(y, , prune): N |y| if N = 0: (Q', R'), ( , ), [] else: (Q', R'), beam_summing(y < N, , prune) QUEUE(Q') (Q, R), A ( , ), 0 for (x, w) R': if is_member(x, y): R.add((x, w)) A += w while : for x, w : if is_cylinder(x, y): Q.add((x, w)) A += w continue if is_member(x, y): R.add((x, w (EOS | x))) A += w (EOS | x) for x' with : .add((x x', w (x' | x))) prune( , A) .append(A) return (Q, R),
28 def prune_M( ): # Standard beam search ((x^{(i)}, w^{(i)}))_{i=1}^N \leftarrow sort_descending( , key=w) return {(x^{(i)}, w^{(i)}) for i = 1, ..., min(M, N)}
32 def prune_ ( ): # Keep heaviest particles holding # of the mass if : return ((x^{(i)}, w^{(i)}))_{i=1}^N \leftarrow sort_descending( , key=w) W_i for i = 1, ..., N k smallest i with return {(x^{(i)}, w^{(i)}) for i = 1, ..., k}
Figure 1: Beam summing for transducing language models (§3.1), the prior work’s enumeration (Snæbjarnarson et al., 2026) made to return the estimate, with the deterministic prunes it runs. beam_summing hands each prune call the pool and the current-position running total A. A prune takes only the arguments it needs. The twist gates the extension step (§3) and can weight a prune’s draw. keeps exactly the particles such that holds. beam_summing with , keeping the heaviest particles, is standard beam search, and keeps the heaviest particles holding at least of the pool’s mass, for some fixed and .
with resampling without replacement among the source prefixes produced at each extension step, using inclusion-probability reweighting to preserve their weights in expectation (§3.2). We write for this estimand and seek an estimate that meets three criteria:
(i) it is unbiased, i.e.,
(ii) it has low variance
(iii) it comes at a reasonable and configurable computational cost
As a consequence of (iii), we require that the algorithms halt almost surely (with probability 1). This lets us estimate prefix probabilities whose quotient–remainder decomposition (§2.2) is infinite, something the prior work cannot guarantee.
We build this estimator starting with the prior work’s algorithm, which computes the decomposition in §2.2, where is its only lossy step (§3.1). We then replace with sampling without replacement (SWOR) (§3.2), which samples which distinct source prefixes survive rather than discarding them deterministically. The algorithm adds a prefix’s quotient contribution when the is_cylinder predicate holds and, otherwise, its remainder contribution when the is_member predicate holds. Adding the remainder contribution directly rather than sampling the stop decision is a variance-reducing Rao–Blackwellization. We extend the SWOR-based pruning function to use the running total to reduce the number of retained source prefixes as mass is accumulated, saving compute and ensuring almost-sure halting (§3.4).
3.1 BEAM SUMMING OVER THE PRECOVER DECOMPOSITION
The algorithm in Fig. 1 is the beam summing approach of the prior work made to return the estimand directly, here named beam_summing (Snæbjarnarson et al., 2026). The recursion computes the quotient–remainder decomposition (Eq. (4)), one call per target prefix. It adds cylinder elements to Q (quotient contributions) and member stop branches to R (remainder contributions). We call the queue’s entries particles, each a source prefix x carrying a nonnegative weight w, and the queue itself the pool. The queues and the collections Q and R are multisets. With no pruning, a particle’s weight is exactly its source prefix mass (§3). Within each call, beam_summing enumerates source pre-fixes breadth-first. The practical implementation of Snæbjarnarson et al. (2026) uses prune to keep the enumeration manageable by deterministically keeping at least of the mass, for some threshold , potentially biasing the estimate by discarding positive covering mass (Tab. 1, Fig. 1).
Each nonempty call to beam_summing first recurses on the target prefix one position shorter, then initializes its pool from the returned quotient entries and passes the returned remainder entries through a membership re-check (§3). Within a call, each iteration processes every particle in the pool, forms child particles by extending non-cylinder prefixes by one source symbol, and updates the running total A using the predicate checks (§3). It is passed to prune after each iteration, and when the pool empties, the call appends A to the returned list (Eq. (6)). Snæbjarnarson et al. (2026) enqueue only source prefixes that pass the Live predicate. beam_summing generalizes this restriction through a twist , a nonnegative weighting on source prefixes. At every position , a twist must be positive wherever the optimal twist defined below is positive, so it zeroes only children with no covering mass ahead. The extension step only creates child particles with (§3). The stochastic prunes introduced below use the twisted weights to choose survivors (§3.2). Setting and using as the pruning function recovers the algorithm of Snæbjarnarson et al. (2026).
At position , let and be the quotient and remainder entries collected by the call for . Grouping these entries by source prefix and dividing the remainder entries by their stop factor defines
the per-prefix estimate of produced by the call for . A remainder summand is defined to be zero when , in which case its contribution to is also zero. Since the quotient and remainder entry weights are the only terms added to , grouping them by source prefix gives
the quotient–remainder decomposition Eq. (4) with each exact prefix mass replaced by (Eq. (1)).
What beam summing computes. Fix the target y and define the optimal twist of a source prefix as the probability that a completion ( ) covers the target,
It is optimal because weighting the source conditionals by it yields the source model conditioned on covering . Under the corresponding importance weighting, every sampled path receives the same weight, so the target-prefix probability estimate has zero variance. At we set , matching Eq. (8) under the conventions of §2.1. The optimal twist returns the share of a prefix's mass that can still cover the target.
The next lemma gives the backward recursion for the optimal twist and its subtree-mass identity. The recursion mirrors prune-free beam_summing. Its cylinder and stop terms are exactly the contributions accumulated by the algorithm, and unfolding the recursion from the empty prefix gives the quotient–remainder decomposition. Write for the live set of next source symbols.
Lemma 3.1 (A backward recursion for the optimal twist). The optimal twist of Eq. (7) (relative to y) satisfies the backward recursion
and every source prefix x obeys
The name follows the twisted particle filters of Whiteley & Lee (2014), a look-ahead factor multiplying, twisting, the weights a filter tracks (Heng et al., 2020; Zhao et al., 2024).
Table 1: The TLM algorithm family. beam_summing (Fig. 1) extends live particles to every live child before applying pruning. beam_swor and beam_swor_adaptive (Fig. 2) extend beam_summing with pruning functions that sample distinct survivors without replacement. In contrast, smc_simple and smc_rb sample one child for each particle. smc_simple also samples the stop decision. smc_rb instead adds quotient and remainder contributions directly. The prune-free row is exact whenever the run halts. With , keeping at most the heaviest particles, beam_summing is standard beam search (Fig. 1), and with it is the beam summing of Snæbjarnarson et al. (2026). The qualitative variance labels summarize the full-scale measurements of Tab. 2.
| Algorithm | Prune | (i) Unbiased | (ii) Variance (qual.) | (iii) Particle count |
|---|---|---|---|---|
| beam_summing (Fig. 1) | none | ✓ | unbounded | |
| + | keep heaviest | ✕ | fixed | |
| + | keep mass | ✕ | mass-set | |
| smc_simple (B) | multinomial | ✓ | high | fixed |
| smc_rb (B) | multinomial | ✓ | lower | fixed |
| beam_swor | SWOR | ✓ | lowest | fixed |
| beam_swor_adaptive | SWOR, adaptive | ✓ | lowest | adaptive, |
the source mass of the completions of that cover . In particular, .
Proof. The proof is deferred to §B.1.
3.2 STOCHASTIC PRUNING
Running beam_summing with either of the prune functions in Fig. 1 can give a biased estimate. To make it unbiased, we introduce pruning functions that draw the survivors without replacement (SWOR) and correct for unequal selection using Horvitz–Thompson reweighting (Horvitz & Thompson, 1952). This preserves the pool’s sums in expectation.
SWOR retains every positive-weight particle when there are at most of them and otherwise replaces the pool by a size- subset , reweighting survivors by their inclusion probabilities (Fearnhead & Clifford, 2003). In beam_summing, particle in the pool passed to the prune is a child particle of its parent , with weight (Fig. 1). For a function , SWOR estimates by
The estimate is unbiased for any valid inclusion probabilities, those with only where (Horvitz & Thompson, 1952). With and ,
Choosing the inclusion probabilities. First consider the untwisted case, . Write for the set of positive-weight child particles. When the prune keeps all of them unchanged. Otherwise, any valid probabilities give an unbiased estimate, and we set each child particle’s inclusion probability proportional to its weight, capped at one because a probability cannot exceed one,
with the constant fixed by the second equation. The capped child particles form the certainty set and survive with their weights unchanged (Shah & Kroese, 2018, §3.2.5), and every non-certain survivor carries the same reweighted value . This means that the reweighted total matches the pool total on every draw, the randomness deciding which prefixes carry the mass forward.
40 def swor_M,ψ(P'): 41 W ← {w(i) · ψ(x(i)): (x(i), w(i)) ∈ P'} 42 I₊ ← {i : W(i) > 0} 43 if |I₊| ≤ M: 44 return {(x(i), w(i)) : i ∈ I₊} 45 π ← pps(W, M) 46 S ~ systematic(π, M) 47 return {(x(i), ) : i ∈ S} 48 def pps((w(i))i=1, M): 49 K ← ∅ 50 π ← 0 51 while True: 52 π_i ← (i ∉ K) 53 K' ← {i ∉ K : π_i ≥ 1} 54 if K' = ∅: break 55 π_K' ← 1 56 K ← K ∪ K' 57 return π 58 def systematic(π, M): 59 φ ~ uniform perm. of {1,...,N} 60 C_i ← (i = 0...N) 61 u ~ Uniform(0,1) 62 return {φ(i) : ∃k < M, C{i-1} ≤ u + k < C_i}
63 def swor_adaptive_M,ψ,ρ(P', A): 64 W(i) ← w(i) · ψ(x(i)) 65 W ← 66 I₊ ← {i : W(i) > 0} 67 if W = 0: 68 return ∅ 69 μ ← 70 m ← 71 if m = 0: 72 B ~ Bernoulli(μ) 73 if B = 0: return ∅ 74 m ← 1, w(i) ← w(i)/μ (∀i) 75 if |I₊| ≤ m: 76 return {(x(i), w(i)) : i ∈ I₊} 77 π ← pps(W, m) 78 S ~ systematic(π, m) 79 return {(x(i), ) : i ∈ S} 80 def beam_swor(y, M, ψ): 81 return beam_summing(y, ψ, swor_M,ψ) 82 83 def beam_swor_adaptive(y, M, ψ): 84 return 85 beam_summing(y, ψ, swor_adaptive_M,ψ,ρ)
Figure 2: SWOR. The without-replacement resample swor replaces the prune in Fig. 1, and swor_adaptive uses the mass accumulated so far to set the number of particles retained at each prune. To ensure halting even when A = 0, this calculation uses the effective value of Eq. (17). §3.4 gives the full construction and its almost-sure halting guarantee. beam_swor and beam_swor_adaptive are beam_summing run with these prunes.
The pruning function swor (Fig. 2) combines these pieces. If the pool has more than M positive twisted weights, it hands them to pps (probabilities proportional to size) for the inclusion probabilities and their certainty set, and draws the size-M subset with systematic (Fig. 2). Any fixed-size draw with those inclusion probabilities qualifies, and systematic realizes them exactly in (Madow, 1949). Each survivor gets the Horvitz–Thompson weight of Eq. (10).
The recursion in pps (Fig. 2) finds the certainty sets, pins child particles whose inclusion probabilities reach one, and recurses on the others with the remaining sample size. Zero-weight child particles keep and are never drawn. beam_summing with swor as its pruning function is the particle filter of Fearnhead & Clifford (2003), instantiated for the source-prefix enumeration over the precover. We write beam_swor for beam_summing run with the swor prune (Fig. 2).
The second pruning function of Fig. 2, swor_adaptive, uses the current-position running total to set the next live-particle count and save compute. We introduce the resulting beam_swor_adaptive algorithm and its almost-sure halting guarantee in §3.4, once the SWOR guarantees are in place (§3.3).
3.3 UNBIASEDNESS GUARANTEES
We now give sufficient conditions for when beam_summing (Fig. 1), combined with a prune function, gives an unbiased estimate. Without pruning, each particle carries its exact prefix mass (§3.1, Snæbjarnarson et al., 2026). The lemma below shows that pruning preserves these pool weights in expectation. The theorem that follows uses this result to show that, if the run halts, its accumulated quotient and remainder contributions sum to an unbiased estimate.
For a pool , write for its weight at a source prefix . For every fixed choice of the inputs to the prune, let denote its random output. We require
The expectation in Eq. (13) is only over the prune’s internal randomness, with all its inputs, including and A, held fixed.
For a run of beam_summing on a target string , consider the call for , at the top of the recursion. Its starting pool holds the re-queued quotient entries of the target one symbol shorter, with total weight one at when . For , the extension step builds from , and the prune returns . Write for the formal pools generated by the corresponding prune-free recursion, defined through their weight at each source prefix even if the complete reference enumeration does not halt.
Lemma 3.2 (Pruning preserves the unpruned pool weights in expectation). Fix a target string y and run beam_summing (Fig. 1), with some prune function satisfying Eq. (13). Then, at every iteration i and every source prefix x,
Proof. The proof is deferred to §B.1.
Theorem 3.3 (Unbiasedness). Fix a nonempty target string y and run beam_summing (Fig. 1) with a twist (§3.1). Suppose that
(1) every prune preserves the pool’s expected weight at every prefix (Eq. (13)), and
(2) the run halts almost surely.
Then
Proof. The proof is deferred to §B.1.
The stochastic pruning functions we consider (Fig. 2) meet the expected-weight hypothesis of Theorem 3.3, while halting is established separately for each algorithm. The draw swor meets hypothesis (1) by the Horvitz–Thompson identity (Eq. (10)), its inclusion probabilities are positive wherever the twisted weight is, and the extension step only hands it particles with positive twist (§3). For hypothesis (2), the full beam_swor run halts whenever the decomposition is finite at every recursive prefix position. For target-prefix calls whose source-prefix enumeration would otherwise continue indefinitely, the tail-roulette prune of §B.6 preserves hypothesis (1) and makes each call halt almost surely. For beam_swor_adaptive, both hypotheses follow from Proposition 3.4.
3.4 ADAPTIVE-BUDGET SWOR AND ALMOST-SURE HALTING
For a finite quotient–remainder decomposition, every branch of the beam_summing enumeration reaches a cylinder or a dead end (a prefix whose live set is empty) after finitely many iterations, so the call halts (Snæbjarnarson et al., 2026, Thm. 4.1). When the decomposition is infinite, this may not be the case.
As an example, take the one-state transducer of Fig. 4 and the target . Choose a source model that assigns positive probability to both a and b after every prefix . A prefix covers c once it holds a b, and every extension keeps covering, so the decomposition is all quotient, , one cylinder at every depth. At depth , the prefix has two children, the cylinder child and the prefix . At the next iteration, is recognized as a cylinder and its weight is added to A. The prefix remains live, is never a member, a cylinder, or dead, and is extended in turn. For any , the prune keeps both child particles and no randomness enters, so the call never halts. Although the weight along this path decays to zero, the source-prefix enumeration may continue forever. To ensure halting, the fixed-M methods of Tab. 1 compose their usual prune with the tail-roulette prune of §B.6. The prune presented below instead halts this example on its own.
The swor function uses a fixed cap of M particles at every iteration. We instead decrease the live-particle count as the current-position running total grows, saving compute. The result is the
(a) Before the draw
(b) Count filled particles
(c) After the draw

Figure 3: One swor_adaptive prune, left to right (top), and successive prunes at one target position (bottom). Each bar is one child particle of the pool with height its weight. The dashed line is the per-particle threshold (drawn at ). Panel (b) shows how each child particle fills of one of the M slots, so a child particle above the threshold counts for at most of the mass however heavy, the counts sum to , and the particle count , the nearest integer, is fixed before any randomness. In panel (c), pps then keeps exactly m particles, re-solving the constant to , pinning the child particles above the new threshold, and drawing each remaining survivor with probability at the shared weight , so the draw passes the twisted total through unchanged (Proposition 3.4). Bottom row: as A grows, the pool's bars shrink against the threshold and the particle count falls. When the pool counts for less than half a particle, a coin flip determines whether the call continues with a one-particle draw or halts.

Figure 4: The one-state transducer of the halting example. Both arcs loop on the single initial, final state, a emitting nothing and b emitting c, so a source string maps to one c for each b it contains.
swor_adaptive prune of Fig. 2, and beam_swor_adaptive is beam_summing run with it. We call this method adaptive-budget SWOR. At every prune call ( of Fig. 2), we set
Here A is the current-position running total (Fig. 1), W is the pool's total twisted weight, and M is the maximum particle count. The corresponding per-particle threshold 1/c sets the twisted-weight scale for the count . Thus controls this count and, through m, the number of particles retained. Children below the threshold contribute in proportion to their twisted weight, while those at or above it contribute one (the dashed line of Fig. 3(a,b)). The resulting fixes the particle count m before sampling according to
This replaces the calculation of Eq. (12), where the constant is solved so that the capped counts sum to the fixed particle count . pps then keeps exactly particles, re-solving the constant to , so every non-pinned survivor carries the shared weight (Fig. 3(c)). In the limit , swor_adaptive recovers the fixed- swor prune. Under the live twist, the capped count satisfies
, where is the pool's remaining live share. A source-extension iteration never increases the pool's mass. When the pool counts for less than half a particle, , a Russian roulette draw (Kahn, 1955) decides whether to empty the pool ( ). To also cover a position that can continue forever without adding anything to A, we replace it at position t by
This substitution applies only to the count and threshold in §3.1 and Eq. (15). The capped count therefore vanishes as the pool's total live weight vanishes relative to . The preceding estimate is fixed before position begins. The resulting particle count is therefore fixed before sampling, so the SWOR draw still preserves each weight in expectation. Fig. 3 traces one draw through panels (a) to (c), as rises and the particle count falls.
Proposition 3.4 (Adaptive-budget SWOR). Fix a positive integer , a twist , , and , and run beam_swor_adaptive using from Eq. (17). Then (I) each prune call satisfies Eq. (13). Under the live twist , (II) the full run halts almost surely. Consequently, under the live twist, at every position.
Proof. The proof is deferred to §B.2.
beam_swor_adaptive uses and the current twisted weights to set its particle count, which can give a compute advantage at matched accuracy, as we experimentally show in Fig. 8. An ablation of the parameter is given in §C.
3.5 SMC WITH MULTINOMIAL RESAMPLING
The beam_swor estimator (Fig. 2) keeps the full enumeration of beam_summing and randomizes only the pruning. A standard sequential Monte Carlo (SMC) construction instead uses multinomial resampling with replacement, gated by an effective sample size test (ESS, §B), as its prune (Fig. 5). Two such algorithms complete the family of Tab. 1 and serve as the baselines of §4. First, smc_simple (Fig. 10) is a textbook particle filter (Doucet et al., 2001; Naesseth et al., 2019) run with the precover-restricted proposal. It collects mass only when a particle happens to draw EOS at a member prefix, and its resample duplicates heavy particles, so the pool's M slots hold dependent repeats exactly where the weights have collapsed. Second, smc_rb (Fig. 12) marginalizes the stop branch rather than drawing it, a Rao–Blackwellization of the stop decision. Both smc_rb and beam_swor use importance weighting to account for the probability mass of children left out of the pool. smc_rb samples one live child for each particle and may resample particles with replacement. beam_swor instead forms every live child before pruning and samples distinct survivors without replacement. §B develops both SMC baselines in full. It proves smc_rb unbiased with the same nested induction as §3.3, after showing that its sampled extension gives each child the same expected weight as the all-child extension.
3.6 RELATION TO PRIOR WORK
Our SWOR prune functions combine unequal-probability sampling without replacement with Horvitz–Thompson reweighting (Horvitz & Thompson, 1952). We implement the draw using systematic pps (Madow, 1949) and the certainty-set construction from without-replacement particle-filter resampling (Fearnhead & Clifford, 2003). Conditional Poisson stochastic beam search (Meister et al., 2021) likewise samples prefixes without replacement, but its Horvitz–Thompson estimate of expectations over complete source strings requires their inclusion probabilities under the full search. We instead correct each pruning draw locally, and these expected-weight identities compose into an unbiased estimate of the precover's total mass (Shah & Kroese, 2018). Shah & Kroese (2018) consider a fixed number of sampling stages, whereas a target-prefix call may require an unbounded number of source-extension iterations. We extend the argument to this setting while adding quotient and remainder contributions, recurring over target positions, and adapting the particle count (Theorem 3.3 and Proposition 3.4).
4 EXPERIMENTS
Unbiasedness, criterion (i) of §3, is established in §3. We measure the bias of beam-summing estimates computed with prune and the variance of the unbiased estimates on paragraphs from WikiText

(a) All-child extension followed by SWOR pruning (beam_swor, beam_swor_adaptive).

(b) Sampled extension followed by ESS-triggered multinomial resampling (smc_simple, smc_rb).
Figure 5: Two ways to maintain a bounded particle pool. Dashed rings in (a) mark children removed by pruning. In (b), the cross marks a dropped particle and orange marks a duplicate. Grey edges show unexplored branches. Dot size shows weight.

beam_summing( )
smc_simple
smc_rb
beam_swor
beam_swor_adaptive ( )
Figure 6: Unbiased methods versus beam summing with prune on the TLM, compared with exact probabilities. Panels (a) and (b) plot relative root-mean-square error RMSE[ ]: (a) a single example paragraph and (b) the ten-paragraph corpus total, both against the mean live particle count. Labels give the maximum particle count . Bars give 95% bootstrap intervals. Panel (c) counts the paragraphs each method resolves, capturing at least 5% of a paragraph’s mass.
2 (Merity et al., 2017) in §4.1, confirming that variance decreases as the number of particles grows, criterion (ii). §4.2 shows that running time can be controlled at the cost of variance, criterion (iii).
On a DNA-to-amino-acid transduction whose precover grows exponentially, §4.3 shows that beam_summing run with prune gets prohibitively slow after a dozen amino acids, while beam_swor_adaptive reaches position 200 in about five seconds. Finally, §4.5 revalidates a published psycholinguistic analysis (Kiegeland et al., 2026) by running beam summing with swor_adaptive rather than the biased pruning function prune .
Estimators. We evaluate the four unbiased methods smc_simple, smc_rb, beam_swor, and beam_swor_adaptive (Fig. 2 and §3.5), against the prior work's beam summing, beam_summing with the mass prune prune (Fig. 1). Every setting uses the live twist is_live. The comparison in §4.4 separates the effect of marginalizing the EOS decision rather than sampling it (smc_simple versus smc_rb) from the combined change to extending every live child and pruning without replacement (smc_rb versus beam_swor).
Reporting. Over seeds we report the log of the averaged estimate, . Each seed's is unbiased for , so the average is unbiased as well, and its log estimates . Averaging in the other order, , would estimate instead, and is concave, so by Jensen's inequality ity , a downward bias. We report between-seed standard deviations alongside method comparisons. We report particle counts as the mean number of live particles.
4.1 BYTE-TO-WORD TRANSDUCTION ON REAL TEXT
The Penn Treebank (PTB) tokenizer segments raw text into PTB units, for example splitting !!! into three successive ! units (Marcus et al., 1993). Following Snæbjarnarson et al. (2026); Kiegeland et al. (2026), we write for a transducer encoding these rules and evaluate it on ten WikiText-2 paragraphs. We now measure what the bias correction changes in this setting using a bigram model. The source model is a smoothed byte-level bigram model trained on the WikiText-2-raw train split and evaluated on the test paragraphs.
We calculate the exact target prefix probabilities by composing with the weighted finite-state representation of . Standard forward and backward path sums in the resulting automaton give the per-position values, as described in §D.
Results are shown in Fig. 6, using the relative root-mean-square error across seeds, RMSE[ ] = , as a function of the mean live particle count. On the single paragraph, threshold-pruned beam summing has error floors from 0.48 at the lowest threshold to 1.0 at the harshest. On the corpus, its error remains close to 1. The with-replacement samplers are unbiased, but their corpus error remains near 1 even with thousands of particles. beam_swor and beam_swor_adaptive drive the corpus error down to 0.17 and 0.21 at their largest tested M values, between-seed standard deviations and below smc_simple's (Tab. 2). Panel (c) shows they resolve most paragraphs where smc_rb needs M in the thousands to do so and smc_simple never resolves the full corpus. §G shows the comparison at every position of all ten paragraphs. The unbiased methods track the exact ratio closely, while beam_summing with prune_ falls below it when pruning discards covering mass.
GPT-2 on PTB. We also run with GPT-2 large, (Radford et al., 2019). Exact target prefix probabilities are unavailable for GPT-2 on the WikiText paragraphs, so we report between-seed variance and convergence as M grows and compare with the threshold-pruned lower bound. The estimates in Fig. 7 are shown for smc_rb, the lowest-variance method with replacement, and beam_swor_adaptive, the lowest-variance method without replacement (Tab. 2), along with the lower bound at . At the largest tested value of M, the two agree within 0.5 nats on the paragraph. On the corpus, smc_rb remains 4.7 nats below the beam_swor_adaptive plateau, which is reached at a much smaller mean live particle count. Tab. 4 reports estimates for each of the ten paragraphs. The threshold-pruned estimate lies below the beam_swor_adaptive estimate on every paragraph, by 0.24 to 7.7 nats and 33.4 nats in total. The between-seed standard deviation of beam_swor_adaptive is smaller than this gap on every paragraph and at least an order of magnitude smaller on five of ten.
4.2 COMPARING COMPUTE–VARIANCE FRONTIERS
We compare the estimators against walltime in Fig. 8. With the source, there is no GPU overhead, and with the walltime includes the source model's forward passes. On , beam_swor_adaptive at nominal takes 772 seconds, compared with 1224 seconds for beam_summing with prune_ . The point of Tab. 4 takes as long as that baseline. Under both source models, the beam_swor_adaptive frontier dominates both SMC baselines. On the bigram, at effectively matched between-seed standard deviation (0.36 against 0.35 nats), beam_swor_adaptive is four times faster than beam_swor (346 against 1390 seconds) and uses fewer live particles (153 against 789). At matched walltime, its standard deviation is nearly three times lower (0.36 against 0.98 nats). With at nominal , 149 seeds give a standard deviation of 0.163 nats (95% CI [0.146, 0.184]), consistent with the 0.170 nats of fixed-M beam_swor at about one fifth of its CPU time ( ). The parameter of beam_swor_adaptive is swept in .
We use add- smoothing with (Jurafsky & Martin, 2026, Ch. 3).
All timings come from one workstation with an Intel Core i9-12900KF, 128 GB of RAM, and a single NVIDIA RTX 3090 with 24 GB of memory. For the CPU experiments, we report the total CPU time of each run, pinned to a P-core on an otherwise idle machine. For GPT-2 we report wall-clock time with one job at a time on the GPU.
(a) Single paragraph (para 0)

(b) Corpus total
(c) Paragraphs resolved
smc_rb beam_swor_adaptive ( ) ---- beam_summing reference ( )
Figure 7: GPT-2-large transduced with . Panels (a) and (b) plot the estimates in nats against the mean live particle count. Labels give the maximum particle count . Each point is , with a failed run contributing . Thick bars give 95% bootstrap intervals, thin whiskers span the finite per-run log estimates, and clipped minima are printed at the lower edge. The dashed line is the threshold-pruned lower bound at . The two algorithms appear to converge to a common value. The lower bound is 2.0 nats below this value on the paragraph and approximately 33 nats below it on the corpus. Panel (c) counts the paragraphs on which each method recovers at least the lower bound's mass.

(a)

(b)
Figure 8: Accuracy–walltime comparisons. (a) For , where exact target prefix probabilities are available, the between-seed standard deviation of the corpus log-estimate against per-seed corpus walltime. Annotations in both panels give the mean live particle count, with the maximum particle count in parentheses. The beam_summing lines using report bias relative to the exact values, and bars give the 95% confidence interval of each standard deviation. (b) For , where exact target prefix probabilities are unavailable, the finite per-seed corpus log-estimates over 32 seeds. Boxes span the interquartile range with whiskers at 1.5 IQR and seeds beyond them drawn as dots, and the black bar marks the median seed. The star marks the pooled estimate , the log of the seed-averaged , computed from all 32 seeds with a failed run contributing . Because the pooled estimate averages before taking the logarithm, occasional high estimates can make it larger than the median per-seed estimate. The beam_summing line shows its corpus total at .

beam_swor_adaptive ()
smc_rb
---- beam_summing ()
(a) Validation against exact values.

beam_swor_adaptive ()
beam_summing ()
(b) Cumulative walltime per amino acid.
Figure 9: DNA-to-amino-acid results. (a) Relative RMSE against exact values over 64 seeds and three targets, with bootstrap intervals. The error of beam_swor_adaptive decreases faster with than that of smc_rb, while beam_summing with prune has fixed error. (b) Cumulative walltime for the bigram model. beam_summing with prune exceeds five minutes at position 13, while beam_swor_adaptive (, ) reaches position 200 in about five seconds.
4.3 TRANSDUCING DNA LANGUAGE MODELS
The DNA→amino-acid map maps DNA strings over a four-letter alphabet to amino-acid strings. Combined with a high-entropy source model, it gives the setting where materializing the precover is most costly in our experiments. Each amino acid is the image of several source codons, and the high-entropy model places non-negligible mass on all of them, so the set of source strings an exhaustive method must track multiplies for each added symbol. We train a bigram model on the DNA training corpus, and use , a GPT-2 model trained on human DNA, the same model used by Snæbjarnarson et al. (2026). Fig. 9a compares both DNA models with exact target prefix probabilities obtained by brute-force enumeration of the precover. In both the validation and scaling comparisons, beam_summing uses prune with .
Fig. 9b shows the running time of beam_summing with prune growing rapidly within a dozen amino acids, while beam_swor_adaptive scales approximately linearly. §E gives a uniform-source worst case for beam_summing with prune. Its captured mass ratio vanishes exponentially in the target length, while smc_simple, smc_rb, and fixed-M beam_swor are exact for any .
4.4 VARIANCE ACROSS ESTIMATORS
Tab. 2 compares the four unbiased estimators across the three transductions. Marginalizing the EOS decision rather than sampling it (smc_simple versus smc_rb) reduces variance only modestly. The large reduction in every setting occurs between smc_rb and beam_swor, which changes both the extension to every live child and the pruning to sampling without replacement. Compared to beam_swor, beam_swor_adaptive achieves comparable variance with less computation on the bigram corpus, lower variance on GPT-2, and identical results on DNA, where swor_adaptive retains the same number of particles as swor (Tab. 2 and Fig. 8).
Table 2: Between-seed standard deviation, in nats, of each estimator's log probability estimate log . The columns report the ten-paragraph WikiText-2 total for the bigram model, the first WikiText-2 paragraph for GPT-2, and the amino-acid target for DNA. Reported values use eight seeds and maximum particle counts of 2000, 200, and 256, respectively, except beam_swor_adaptive on the bigram (, mean live count 251). The smc_simple GPT-2 run covered only 120/850 bytes.
| Algorithm | |||
|---|---|---|---|
| smc_simple | 9.78 | — | 0.111 |
| smc_rb | 7.86 | 3.23 | 0.107 |
| beam_swor | 0.170 | 0.395 | 0.062 |
| beam_swor_adaptive () | 0.200 | 0.199 | 0.062 |
4.5 PSYCHOLINGUISTICS: SURPRISAL FOR READING-TIME PREDICTION
Surprisal theory hypothesizes that processing time increases with contextual surprisal, the negative log probability of a linguistic unit in context. Kiegeland et al. (2026) test this hypothesis on the MECO eye-tracking corpus (Siegelman et al., 2022), computing contextual surprisal from GPT-2 Small through transducers for PTB words, whitespace-delimited words, and characters. The surprisals come from the per-position beam-summing estimate of Snæbjarnarson et al. (2026), computed with . Each next-unit probability is estimated by the ratio . Pruning lowers both estimates, but it can remove different fractions of their mass, so the ratio and resulting surprisal can err in either direction.
Beam summing with gives no way to determine how the resulting bias affects these conclusions. We therefore replace with unbiased SWOR pruning, recompute the PTB-word contextual surprisals, and rerun the corresponding fits. The resulting estimate of corpus surprisal is 106 nats lower than the original. We evaluate first-fixation duration, gaze duration, and total reading time. These are, respectively, the duration of the first fixation on a word, the sum of its first-pass fixations, and the sum of all its fixations including refixations. For each measure, is the per-observation improvement in held-out log likelihood from adding contextual surprisal to the shared baseline.
For each reading-time measure, we compare fits using contextual surprisal computed by beam summing with either or swor_adaptive. The model specification, evaluation protocol, and beam-based unigram-surprisal control of Kiegeland et al. (2026) are unchanged (Tab. 3; details in §F). We find no evidence of a predictive difference between the two fits on any reading-time measure (one-sided in both directions). Under either estimator, adding contextual surprisal computed over PTB words improves held-out prediction for all three reading-time measures (Tab. 3). Thus, replacing with swor_adaptive in beam summing leaves the published conclusions unchanged.
5 CONCLUSION
In the beam-summing method of Snæbjarnarson et al. (2026), the threshold prune is the only approximation, discarding mass to control the computation. This work replaces that prune with a weight-proportional draw without replacement and Horvitz–Thompson reweighting while retaining the enumeration and the per-position estimate. beam_swor_adaptive uses the current-position running total to set its particle count. Its roulette rule ensures that the run halts almost surely. The resulting estimator is unbiased and replaces unknown pruning error with sampling variance. The method applies to target prefix probability estimation for a pretrained source model composed with a deterministic transformation, providing an unbiased reference for estimating threshold-pruning error. In the DNA→amino-acid setting, it also makes target prefix probability estimation feasible for longer targets over high-entropy sources.
ACKNOWLEDGEMENTS
VS is supported by DNRF grant P1 and NNF grant NNF26OC0114089.
REFERENCES
Nicolas Chopin and Omiros Papaspiliopoulos. An Introduction to Sequential Monte Carlo. Springer Series in Statistics. Springer, 2020. doi: 10.1007/978-3-030-47845-2. URL https://doi.org/10.1007/978-3-030-47845-2.
Table 3: Predictive contribution of PTB-word contextual surprisal on MECO. Values are in nats. For swor_adaptive, we use , nominal , and 10 seeds. * ; ** ; *** .
| Pruning function | First fixation | Gaze duration | Total reading time |
|---|---|---|---|
| swor_adaptive | 0.76** | 2.05*** | 3.26*** |
| prune | 0.81** | 2.13*** | 3.24*** |
Ryan Cotterell, Anej Svete, Clara Meister, Tianyu Liu, and Li Du. Formal aspects of language modeling, 2024. URL https://arxiv.org/abs/2311.04329.
Pierre Del Moral, Arnaud Doucet, and Ajay Jasra. Sequential Monte Carlo samplers. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 68(3):411–436, 2006. doi: 10.1111/j.1467-9868.2006.00553.x. URL https://doi.org/10.1111/j.1467-9868.2006.00553.x.
Arnaud Doucet, Nando de Freitas, and Neil J. Gordon (eds.). Sequential Monte Carlo Methods in Practice. Statistics for Engineering and Information Science. Springer, 2001. ISBN 978-1-4419-2887-0. doi: 10.1007/978-1-4757-3437-9. URL https://doi.org/10.1007/978-1-4757-3437-9.
Paul Fearnhead and Peter Clifford. On-line inference for hidden Markov models via particle filters. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 65(4):887–899, 2003. doi: 10.1111/1467-9868.00421. URL https://doi.org/10.1111/1467-9868.00421.
Jeremy Heng, Adrian N. Bishop, George Deligiannidis, and Arnaud Doucet. Controlled Sequential Monte Carlo. The Annals of Statistics, 48(5):2904–2929, 2020. doi: 10.1214/19-AOS1914. URL https://doi.org/10.1214/19-AOS1914.
D. G. Horvitz and D. J. Thompson. A generalization of sampling without replacement from a finite universe. Journal of the American Statistical Association, 47(260):663–685, 1952. doi:10.1080/01621459.1952.10483446. URL http://www.jstor.org/stable/2280784.
Daniel Jurafsky and James H. Martin. Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition with Language Models. 3rd edition, 2026. URL https://web.stanford.edu/~jurafsky/slp3/. Online manuscript released August 19, 2026.
Herman Kahn. Use of different Monte Carlo sampling techniques. Paper P-766, RAND Corporation, Santa Monica, CA, 1955. URL https://www.rand.org/pubs/papers/P766.html.
Samuel Kiegeland, Vésteinn Snæbjarnarson, Tim Vieira, and Ryan Cotterell. On the proper treatment of units in surprisal theory. In Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 32202–32224, 2026. doi: 10.18653/v1/2026.acl-long.1485. URL https://aclanthology.org/2026.acl-long.1485/. Oral.
William G. Madow. On the theory of systematic sampling, II. The Annals of Mathematical Statistics, 20(3):333–354, 1949. doi: 10.1214/aoms/1177729988. URL https://doi.org/10.1214/aoms/1177729988.
Mitchell P. Marcus, Beatrice Santorini, and Mary Ann Marcinkiewicz. Building a large annotated corpus of English: The Penn Treebank. Computational Linguistics, 1993. URL https://aclanthology.org/J93-2004/.
Clara Meister, Afra Amini, Tim Vieira, and Ryan Cotterell. Conditional Poisson stochastic beams. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 664–681, 2021. doi: 10.18653/v1/2021.emnlp-main.52. URL https://aclanthology.org/2021.emnlp-main.52.
Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer Sentinel Mixture Models. In International Conference on Learning Representations, 2017. URL https://openreview.net/forum?id=Byj72udxe.
Mehryar Mohri. Weighted Automata Algorithms, pp. 213–254. Springer Berlin Heidelberg, 2009. ISBN 978-3-642-01492-5. doi: 10.1007/978-3-642-01492-5_6. URL https://doi.org/10.1007/978-3-642-01492-5_6.
Christian A. Naesseth, Fredrik Lindsten, and Thomas B. Schön. Elements of sequential Monte Carlo. Foundations and Trends in Machine Learning, 12(3):187–306, 2019. doi: 10.1561/2200000074. URL https://doi.org/10.1561/2200000074.
Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language Models are Unsupervised Multitask Learners. OpenAI blog, 1(8), 2019. URL https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf.
Rohan Shah and Dirk P. Kroese. Without-replacement sampling for particle methods on finite state spaces. Statistics and Computing, 28(3):633–652, May 2018. ISSN 1573-1375. doi:10.1007/s11222-017-9752-8. URL https://doi.org/10.1007/s11222-017-9752-8.
Noam Siegelman, Sascha Schroeder, Cengiz Acartürk, Hee-Don Ahn, Svetlana Alexeeva, Simona Amenta, Raymond Bertram, Rolando Bonandrini, Marc Brysbaert, Daria Chernova, et al. Expanding horizons of cross-linguistic research on reading: The Multilingual Eye-movement Corpus (MECO). Behavior Research Methods, 54(6), 2022. URL https://link.springer.com/article/10.3758/s13428-021-01772-6.
Vésteinn Snæbjarnarson, Samuel Kiegeland, Tianyu Liu, Reda Boumasmoud, Tim Vieira, and Ryan Cotterell. Transducing language models. In Proceedings of The Fourteenth International Conference on Learning Representations, 2026. URL https://openreview.net/forum?id=qOyF214xmg.
Tim Vieira, Benjamin Lebrun, Mario Giulianelli, Juan Luis Gastaldi, Brian Dusell, John Terilla, Timothy J. O'Donnell, and Ryan Cotterell. From language models over tokens to language models over characters. In Aarti Singh, Maryam Fazel, Daniel Hsu, Simon Lacoste-Julien, Felix Berkenkamp, Tegan Maharaj, Kiri Wagstaff, and Jerry Zhu (eds.), Proceedings of the 42nd International Conference on Machine Learning, volume 267 of Proceedings of Machine Learning Research, pp. 61391–61412. PMLR, 13–19 Jul 2025. URL https://proceedings.mlr.press/v267/vieira25a.html.
Nick Whiteley and Anthony Lee. Twisted particle filters. The Annals of Statistics, 42(1):115–141, 2014. doi: 10.1214/13-AOS1167. URL https://doi.org/10.1214/13-AOS1167.
Stephen Zhao, Rob Brekelmans, Alireza Makhzani, and Roger Grosse. Probabilistic Inference in Language Models via Twisted Sequential Monte Carlo. In Proceedings of the 41st International Conference on Machine Learning, ICML'24, pp. 60704–60748, 2024. URL https://proceedings.mlr.press/v235/zhao24c.html.
CONTENTS OF THE APPENDIX
A Notation Glossary 19
B Sequential Monte Carlo over the Precover 20
B.1 Proofs for the SWOR Estimator 20
B.2 Proof for Adaptive-Budget SWOR 22
B.3 Sequential Monte Carlo 24
B.4 Intermediate Targets and the smc_rb Algorithm 25
B.5 Unbiasedness of smc_rb 27
B.6 A Common Tail-Roulette Prune 28
C Sensitivity to Pruning Parameters 29
D Exact Ground Truth for Bigram Models 30
E The Genetic-Code Worst Case 30
F Details of the MECO Rerun 31
G Additional Byte-to-Word Results 32
A NOTATION GLOSSARY
| Notation | Gloss |
|---|---|
| Empty string | |
| EOS | End-of-string symbol |
| Symbols in the source alphabet | |
| Source strings | |
| Set of all source strings | |
| Concatenation | |
| Symbols in the target alphabet | |
| Target strings, with the length- target prefix | |
| Set of all target strings | |
| Functional string-to-string transformation | |
| Transducer implementing | |
| is a prefix of | |
| Cylinder spanned by , i.e. | |
| pf() | Prefix-free operation on (2.1) |
| Precover of : (Eq. (4)) | |
| Largest union of cylinders contained in | |
| Quotient: prefix-free generators of | |
| Remainder: | |
| Source language model over | |
| Source prefix probability | |
| Conditional next-symbol prefix probability | |
| Source stop probability | |
| Transduced (target) language model | |
| Target prefix probability, the normalizing constant we estimate (Eq. (26)) | |
| is_member() | : the output emitted covers |
| is_cylinder() | : every extension covers |
| is_live() | Some extension of covers |
| Live set: live next source symbols \{x' \in \mathcal{X} : \text{is_live}(xx', y)\} | |
| Fixed or maximum particle count | |
| Particle pool: source prefixes and their weights | |
| Particle weight | |
| Reference weight inherited by particle under tail roulette (B.6) | |
| Prefix-probability estimate | |
| Optimal twist of , relative to or | |
| Twisted live mass, | |
| Proposal normalizer, \mathbb{1}_{\{\text{is_member}(x, y \le_t)\}} \overrightarrow{p_{\mathcal{X}}}(\text{EOS} \mid x) + \sum_{x'' \in \mathcal{A}(x)} \overrightarrow{p_{\mathcal{X}}}(x'' \mid x) \psi_t(xx'') | |
| ESS, | Effective sample size (Eq. (30)), resample when ESS < |
| Prior work's prune threshold, keep of the pool's mass | |
| Current-position running total, returned as | |
| Halting constant | |
| Scales swor_adaptive's threshold | |
| Tail-roulette threshold relative to (B.6) | |
| Certainty set: child particles pinned to | |
| Sampled child set, of size or | |
| Horvitz–Thompson reweighting |
Notation conventions. Color encodes domain: magenta for source-domain objects () and olive for target-domain objects (). Font encodes type: lowercase italic for symbols (), bold italic for strings (), calligraphic for sets and alphabets (), and typewriter for the transducer () and for algorithm and predicate names (is_member, is_cylinder, is_live, smc_simple, resample). The overrightarrow marks prefix probabilities ( is the prefix probability of ).
86 def smc_simple(, , ): 87 88 89 while : 90 91 for : 92 sample 93 94 if : 95 96 else: 97 98 99 return
100 def resample(): 101 if : return 102 if : 103 return 104 105 return
Figure 10: A minimal sequential Monte Carlo algorithm for estimating Z (Eq. (26)). M particles extend one symbol at a time under the proposal, with the incremental weights of Eq. (27), finish with the potential factor at EOS, and hand uneven weights to resample. resample is an ESS-gated multinomial resample (Eq. (30)) that samples with replacement and resets weights to their mean.
B SEQUENTIAL MONTE CARLO OVER THE PRECOVER
This appendix first gives the proofs deferred from the main text ( §§ B.1 and B.2). It then develops the with-replacement SMC algorithms for estimating the total mass of the precover, including the generic estimator and its resampling ( §B.3), the intermediate targets and the smc_rb algorithm ( §B.4), and the unbiasedness of smc_rb ( §B.5). Finally, it gives the common tail-roulette prune for the fixed-M methods ( §B.6).
B.1 PROOFS FOR THE SWOR ESTIMATOR
Lemma 3.1 (A backward recursion for the optimal twist). The optimal twist of Eq. (7) (relative to y) satisfies the backward recursion
and every source prefix x obeys
the source mass of the completions of x that cover y. In particular, .
Proof. Suppose first that . If is_cylinder( ) holds, every completion of covers , so . Otherwise, condition on whether the completion stops immediately with EOS or begins with a source symbol . The stop event covers exactly when is_member( ) holds, and after drawing the conditional probability of covering is . A non-live child has optimal twist zero, so the sum may be restricted to , giving Eq. (8).
When , the recursion follows from the conventions of §2.1 and the definition of when . If is a cylinder, then it is a member and both sides of Eq. (8) equal one. Otherwise, both sides equal .
It remains to prove Eq. (9). For , the definition of the optimal twist gives
If , every extension has , so both sides of Eq. (9) are zero.
Finally, setting in Eq. (9) gives
by Eq. (3).
Lemma 3.2 (Pruning preserves the unpruned pool weights in expectation). Fix a target string y and run beam_summing (Fig. 1), with some prune function satisfying Eq. (13). Then, at every iteration i and every source prefix x,
Proof. We induct on . For each , we first establish the claim for the initial pools at , then induct on the iterations within that call.
Initial pools. For , , both runs start with aggregate weight one at the empty prefix and zero at every other prefix. Now let and assume the result for the recursive call on . The pool is exactly the quotient returned by the recursive call on , while contains the corresponding prune-free quotient weights. Fix a source prefix . Because the starting pool is prefix-free, can extend at most one of its entries. Since each iteration appends one source symbol, can be added to the call's quotient at most once. The outer induction hypothesis therefore implies that that quotient has the same expected weight at every source prefix as its prune-free counterpart, so
Together with the case N = 0, this establishes the within-call induction base i = 1 for every N.
Within-call induction. Fix N and assume the identity holds at iteration i for every source prefix. The full extension step obeys
A cylinder prefix produces no children, while every other particle produces one child for each symbol admitted by the twist. For every prefix x and symbol , we therefore have
Since each iteration appends one source symbol, every prefix in either next pool is nonempty and has the form . This proves the claim at iteration for every source prefix. Thus the within-call induction proves the claim at every iteration, completing the outer induction on .
Theorem 3.3 (Unbiasedness). Fix a nonempty target string y and run beam_summing (Fig. 1) with a twist (§3.1). Suppose that
(1) every prune preserves the pool's expected weight at every prefix (Eq. (13)), and
(2) the run halts almost surely.
Then .
Proof. By hypothesis (2), every recursive call returns almost surely, so the contributions below and the final estimator are well defined. For each and each source prefix , let be the contribution assigned to by the deterministic prune-free reference enumeration at position , as in Eq. (5). The twist only gates the extension step in beam_summing. By definition it gates off no child source prefix with positive covering mass and does not alter particle weights.
The exactness of prune-free beam_summing (§3.1) therefore gives for , while for .
We first show that pruning preserves these contributions in expectation, for every and every , by induction on . Fix such a position and an element of its decomposition. Since , the element also belongs to the preceding precover. The preceding quotient–remainder split gives two alternatives. Either extends a unique , or (§2.2). When , and , so only the quotient alternative occurs. When , assume the identity holds at position . If is a remainder element at position and , the convention in Eq. (5) gives . Thus, if is a remainder element, only the case remains.
Extended from the quotient. Let denote the quotient prefix in the first alternative. The call at places the preceding quotient entries at in and appends one source symbol per iteration. Thus any entries at can occur only at iteration . At that iteration, Eq. (5) identifies the contribution assigned to with its aggregate pool weight, so and . Applying Lemma 3.2 gives
Retained from the remainder. In the second alternative, the target re-check passes every entry at unchanged because (§3). Hence and . The induction hypothesis therefore gives
The zero-EOS-probability observation and the two alternatives complete the induction. Set . Then
(23a, Eq. (6) and Tonelli)
(23b, the preservation above)
(23c, the prune-free identities above)
(23d, Eq. (4))
B.2 PROOF FOR ADAPTIVE-BUDGET SWOR
By Theorem 3.3, it is enough to show that every call to the adaptive-budget prune preserves the expected weight at each source prefix (Eq. (13)) and that the full run halts almost surely.
Proposition 3.4 (Adaptive-budget SWOR). Fix a positive integer , a twist , , and , and run beam_swor_adaptive using from Eq. (17). Then (I) each prune call satisfies Eq. (13). Under the live twist , (II) the full run halts almost surely. Consequently, under the live twist, at every position.
Proof. (I) To establish Eq. (13), consider a single prune call with and fixed. For particle , write and , as in Fig. 2. These inputs determine , , and the rounded value before the prune draws any randomness. So they determine which of the three cases below applies, even though the roulette case may subsequently change from zero to one. We consider the following three cases.
(1) Suppose . The extension step ensures for every particle in (§3). Since and , every . Because , this implies for every particle. Hence for every , which establishes Eq. (13).
(2) Suppose and . We split according to whether or . If , the prune keeps all particles in unchanged. For every , . Since , this implies . Removing those particles therefore leaves the weight at every source prefix unchanged, so Eq. (13) holds. If , the prune must select exactly particles. It computes their inclusion probabilities from the twisted weights with pps, draws the particles, and applies Horvitz–Thompson reweighting. Here for every . Taking in Eq. (10) gives
which is Eq. (13).
(3) Suppose and . Because , the definition of in Eq. (16) gives . Because , the rounding rule in the same equation gives . Thus the division by below is well defined. Returning the empty pool deterministically would discard positive weight and violate Eq. (13), so the prune instead uses this same as its roulette survival probability. It draws and returns the empty pool if . If , it sets and replaces every by before performing a one-particle SWOR prune. The resulting twisted weights are . This common rescaling leaves unchanged and, if pps is called, leaves its inclusion probabilities unchanged. The case above therefore gives
Averaging over B gives
Thus Eq. (13) also holds in the third case.
Together, the three cases establish (I). Multiplying Eq. (13) by and summing over source prefixes gives
This is the form needed in (II).
(II) We prove by induction on target-prefix length that every call made by beam_swor_adaptive halts almost surely. The empty-prefix call halts after one iteration. Fix a nonempty target prefix , let , and suppose the recursive call for has returned. Its quotient is a finite starting pool, which we write as
It is enough to prove halting conditional on this pool and on the preceding estimate , so we hold both fixed below.
If has no positive weight, the call halts immediately when the pool is empty or no later than its first prune by case (1) of (I). We may therefore assume that contains a positive weight. When , . When , every positive entry in was added to the quotient of the preceding call, and its weight was included in . Hence and, throughout the current call,
For , when the prune is reached, let be the child pool passed to it and define . If the current target-prefix call halts before this prune, define . Let and denote the capped count and its rounded value before roulette at the prune, defining both to be zero if that prune is not reached or if .
Part (I) preserves the expected weight at every source prefix through each adaptive prune. By (I) and iterated expectation, a length-n descendant has expected weight at most . Summing over the live descendants gives
The inner sum is the conditional probability of generating at least additional source symbols from . It tends to zero because is a distribution over finite strings (§2.1), and the outer sum has finitely many terms.
At the prune, write for its twisted particle weights, so . Then Eq. (16) and (24) and give
If this prune is not reached, the last inequality still holds because by definition. Taking expectations therefore gives
The rounding rule in Eq. (16) gives exactly when . Markov's inequality now gives
Let be the event that the call survives the prune. Write and . The events are decreasing, so converges to some . If and , roulette lets the pool survive with probability . If , the prune returns the empty pool. Conditioning on the state before the prune therefore gives
Taking and using Eq. (25) gives , so . The events are decreasing, and their intersection is the event that the call never halts. Therefore
Thus the current call halts almost surely for every realized finite starting pool. The induction proves that the full run halts almost surely. Applying Theorem 3.3 to each target prefix using (I) and (II) gives the final claim.
B.3 SEQUENTIAL MONTE CARLO
The sum we wish to estimate (Eq. (3)) is over source strings filtered by a membership test in the precover . A potential is a function that weights each source string (Doucet et al., 2001), and is its expectation under the source model,
For a transduced model, we take the potential to be the predicate is_member (§2.2), , for a fixed . The estimand is then the probability that a string drawn from the source model maps to a target string having as a prefix, i.e., .
The algorithm estimating Z with SMC is shown in Fig. 10, and we now describe it. The pool holds particles, each consisting of a source prefix and a particle weight, initialized at the empty string with weight ( A). At every iteration, a particle draws its next symbol by sequential importance sampling (Doucet et al., 2001), drawing from a conditional proposal distribution ( A) and correcting for it by multiplying its weight by the ratio of source to proposal conditionals ( A),
A particle that draws EOS is completed: it leaves the pool, and its weight, multiplied by the potential, is added to the estimate ( A). Assume for a moment that we do not call resample. Then, for a single particle, the factors of Eq. (27), the potential, and the initial 1/M multiply to , with the importance weight
Here . We further require that
to ensure that every string with positive potential–weighted mass can be sampled.
Without the resample call the particles are independent and the estimate is the average of draws of Eq. (28).
Without resampling, the particle weights can become increasingly unequal as source prefixes grow, until a single particle dominates (Doucet et al., 2001). The effective sample size
quantifies that imbalance. When it falls below ( A), for a fixed , resample redraws the pool with replacement proportionally to weight and resets every weight to the pool mean ( A), so the higher-weighted particles are duplicated and the lower ones discarded. When the support condition Eq. (29) holds and the run halts almost surely, the estimator is unbiased without resampling. Since multinomial resampling with replacement preserves weighted sums in conditional expectation, smc_simple remains unbiased.
B.4 INTERMEDIATE TARGETS AND THE smc_rb ALGORITHM
In §B.3, particles are extended until EOS is sampled and only then is the potential evaluated. beam_summing instead tests prefixes as they are extended and drops a prefix once it can no longer cover the target. smc_rb applies SMC within beam_summing's target recursion. Like beam_summing, smc_rb applies the is_cylinder and is_member checks to add quotient and remainder contributions. It samples one live next source symbol per particle instead of enumerating all of them. The recursion iterates over target prefixes while each call extends source prefixes. To express these updates as importance sampling, associate each target position t with the intermediate target
As in §3.1, we rely on the live twist , written when is clear. Sequential importance sampling requires each intermediate target to place mass only where the preceding target does (Del Moral et al., 2006; Naesseth et al., 2019). This holds because a prefix that can still cover can also cover .
Recall the live set of next source symbols ( ), taken here relative to , and define the twisted live mass
The proposal distribution draws the next symbol with probability proportional to ,
For the live twist, reduces to the raw conditional probability of the live set, so every particle stays live for by construction. smc_simple uses the same live-set restriction. The downside is that the live set carries no information about how much covering mass lies ahead, so a particle may look good early and carry little weight later (Fig. 11b). We accept the compromise because the live predicate is computable at every step ( ), whereas the full mass ahead is the optimal twist of Eq. (7), exactly the quantity we cannot compute.
(a)
(b)


Figure 11: (a) An example source string aligned to a target prefix under a function , the dashed lines marking the boundaries between target positions. A symbol may emit none or several target symbols, so the source spans between boundaries vary in length while the alignment stays monotone. At each step a source symbol is scanned, and at each boundary a target symbol is emitted. (b) When we sample by source mass (edge width) and never enter a dead branch (), so no draw is wasted. Since we only look at the current live symbols, we cannot tell a heavy branch with little mass ahead (top) from a light branch that carries it (bottom). Importance weighting corrects for the proposal, while resampling with replacement mitigates particle-weight degeneracy ( B.3 and B.5).
Importance sampling in the target recursion. smc_rb iterates over the target and source indices as shown in the example Fig. 11a. A target step occurs once when the recursion advances from target position to . At a fixed source prefix, the weight becomes
The source step advances by drawing one symbol from the twisted proposal. Its incremental importance weight is
Therefore,
with the proposal's normalizer of Eq. (33). At position , the target-step factor is combined with one source-step factor for every symbol sampled within the call. A particle that ends position at the prefix , , and takes source steps through position extends it to , drawing the symbol at step , and updates its weight by
the target step once and one source-step factor per symbol.
For the live twist, on every surviving particle. smc_rb marginalizes the EOS decision and conditions the proposal of Eq. (33) on drawing a live next source symbol. Substituting the conditional proposal into Eq. (27), the update simplifies to
The sampled particle’s weight therefore equals the sum of the weights of its parent’s live children.
For a quotient particle carried from position , the target-step factor is one if the prefix remains live at the new position and zero otherwise. It re-enters the pool unchanged when the factor is one. When the factor is zero, , so smc_rb drops it at its next source step. The recursive call also returns completed remainder entries. The membership re-check retains one exactly when its source string covers the longer target. Together, these operations implement the update from to (Fig. 12).
106 def smc_rb(y, M, , prune): 107 N |y| 108 if N = 0: 109 (Q', R'), ([(, )] , ), [] 110 else: 111 (Q', R'), smc_rb(y < N, M, , prune) 112 QUEUE(Q') 113 (Q, R), A ( , ), 0 114 for (x, w) R': 115 if is_member(x, y): 116 R.add((x, w)) 117 A += w 118 while | | > 0: 119 120 for x, w : 121 if is_cylinder(x, y): 122 Q.add((x, w)) 123 A += w 124 continue 125 if is_member(x, y): 126 R.add((x, w (EOS | x))) 127 A += w (EOS | x) 128 129 if : 130 continue 131 sample 132 .add((x x', )) 133 prune( , A) 134 .append(A) 135 return (Q, R),
136 def resample : 137 138 V 139 N | | 140 if : 141 return 142 j_1, ..., j_N Categorical( ) 143 return
Figure 12: The smc_rb algorithm and ESS-gated multinomial resampling under a twist.
B.5 UNBIASEDNESS OF smc_rb
We now show that smc_rb is unbiased. The proof follows §3.3 for beam_summing but with the sampled symbol extension instead of all live extensions.
Proposition B.1 (Unbiasedness of smc_rb). Fix a nonempty target string y and run smc_rb (Fig. 12) with a twist. Suppose that every prune preserves the pool's expected weight at every prefix (Eq. (13)) and that the run halts almost surely. Then .
Proof. We follow the nested induction used in Lemma 3.2, with an outer induction on target length and inner induction on the within call iterations. Write for the smc_rb pool at iteration and for the corresponding pool in the prune-free beam_summing run. In the outer base case, the copies of with weight in smc_rb have the same aggregate weight as the single copy of weight one in beam_summing. The recursive initial-pool argument is otherwise unchanged, so it remains to replace the extension identity Eq. (21).
Condition on the current pool and fix a non-cylinder particle at with weight . Write for its twisted live mass. When , let be drawn from the proposal of Eq. (33), conditioned on a live source symbol. For any next source symbol with , its conditional expected contribution is
A zero-twist child receives no contribution under either extension. If , both extensions assign every admitted child zero weight, and cylinder prefixes produce no children under either extension. Summing Eq. (39) over the particles at x gives the conditional-expectation version of Eq. (21). The tower rule and Eq. (13) then close the same within-call induction and give, for every iteration i and source prefix x,
Marginalizing the stop decision replaces its sampled contribution by its conditional expectation. At a member, the baseline proposal stops with probability and returns weight , so
(41) which is the remainder contribution added by smc_rb. smc_rb adds quotient contributions and re-queues prefixes exactly as beam_summing does. The same assembly argument as in Theorem 3.3 therefore applies to the pool identity above, and Eq. (23a, Eq. (6) and Tonelli) and (23d, Eq. (4)) give the result.
The ESS-gated multinomial resample of Fig. 12 satisfies Eq. (13) for every fixed input pool (Chopin & Papaspiliopoulos, 2020, Prop. 16.3).
B.6 A COMMON TAIL-ROULETTE PRUNE
Source-prefix enumeration can continue indefinitely even as the remaining particle weights tend to zero (§3.4). The decorator in Fig. 13 independently removes each sufficiently light particle with probability 1/2 and doubles its weight otherwise. For use with this decorator, we represent each particle as a triple . At the start of a target-prefix call, we set for every particle in . Each child and resampled copy inherits . The original pruning function acts on the source prefix and current weight while keeping unchanged. For , the decorator first applies the original pruning function, then applies the coin flip independently to each returned particle with .
Fix a finite starting pool , and an original pruning function that returns at most particles. We first show that the decorator preserves the particle weight in expectation whenever the original pruning function does. We then show that the algorithms with a fixed particle cap in Tab. 1 halt almost surely.
Expected-weight preservation. Conditional on the original pruning function’s output and the reference weights , a particle selected for the coin flip contributes 2w with probability 1/2 and zero otherwise, giving expected contribution w. The coin flip therefore preserves every prefix weight in conditional expectation. Averaging over the original pruning function’s output, the decorated pruning function satisfies Eq. (13) whenever the original does.
Almost-sure halting. Let be the pool returned by the original pruning function at iteration , immediately before the coin flips, and define its total particle weight by
By Eq. (13) and Lemma 3.2, equals the total weight in the corresponding prune-free pool after source extensions for beam_summing and hence beam_swor. The sampled-extension identity Eq. (39) gives the same result for smc_rb, and the importance-weight identity Eq. (27) and (28) gives it for smc_simple. For prune , the expected total is no larger because its prune only removes particles. In every case,
The inner sum is the conditional probability of generating at least additional source symbols from . Because is a distribution over finite strings, this probability tends to zero as (§2.1). Since the outer sum has finitely many terms, the displayed limit follows.
Discard zero-weight particles from . If none remain, the call halts immediately. Otherwise, set
Because descendants inherit , every descendant's coin-flip threshold is at least .
For , write for the pool after the coin flips at iteration . If , every particle in is selected for a coin flip. The original pruning function returns at most particles, so the independent coin flips empty the pool with conditional probability at least . Since is def with_tail_roulette(prune, ): def decorated( , ...): for : if : continue if : continue b Bernoulli(1/2) if b = 1: return return decorated
Figure 13: Tail-roulette decorator for a pruning function.
nonnegative, Markov's inequality and the coin-flip bound above give
Let be the event that the pool remains nonempty after iteration , and let . Because an empty pool remains empty, . Thus, is nonincreasing and bounded below by zero, so it converges to some . Taking in the recursion, with , , and , gives . Since , this forces . The intersection is the event that the pool remains nonempty at every iteration. For decreasing events, its probability is the limit of their probabilities, so . A call using the decorated prune thus halts almost surely. For the recursive algorithms, the target string has finitely many positions, so the complete run also halts almost surely. Any gives the halting guarantee.
Settings. The threshold determines when roulette begins. We choose it small so that roulette is delayed until a particle's current weight is small relative to its reference weight. We use for the WikiText experiments and for the DNA and MECO experiments. beam_swor_adaptive does not require the decorator because its adaptive prune uses to ensure almost-sure halting (Proposition 3.4).
C SENSITIVITY TO PRUNING PARAMETERS
The experiments use . For each fixed target prefix, the finite-context source models and finite-state transducers give finitely many live configurations. Full support gives a positive lower bound on the probability of reaching a member or cylinder from any such configuration, so becomes positive almost surely. The proof of Proposition 3.4 then applies with . Besides , the adaptive-budget prune uses ( ), and the ESS-gated multinomial prune uses ( ). We vary both on the ten-paragraph bigram corpus of , using eight seeds (Fig. 14).
Smaller retains more particles. At nominal , reducing from 1 to 0.02 lowers the standard deviation from 0.711 to 0.073 nats and raises the time per seed from 349 to 1551 seconds. The default gives a standard deviation of 0.200 nats at 623 seconds. Plain beam_swor at gives 0.170 nats at 3432 seconds. With 149 seeds, the standard deviation at the default is 0.163 with CI [0.146, 0.184], consistent with the fixed-M beam_swor result at less CPU time. At , the between-seed standard deviation rises from 0.632 nats at to 4.815 at and 5.283 at . At , the mean live count is 18, and most log estimates are several nats low.
Increasing causes more frequent resampling, while CPU time changes little across the tested values. At , the survivor-conditioned standard deviation rises from 5.1 nats at , where seven of eight corpus seeds survive, to 7.86 at the default and 9.8 at . At , every seed has at least one zero paragraph estimate. The same holds at for every tested value of , despite some nonzero individual paragraph estimates.
D EXACT GROUND TRUTH FOR BIGRAM MODELS
The bigram model can be represented as a weighted finite-state acceptor. Composing it with and projecting onto the target labels gives a weighted automaton defining . In the representation used here, the functional transducer admits at most one accepting path for each source string, so path sums do not double-count source strings.
For each state , let be its backward weight, the sum of the weights of all paths starting at , including the final weight at the end of each path. Let be the transition-weight matrix and the final-weight vector. From each state, a path either stops there with its final weight or takes a transition and then continues. The backward weights therefore satisfy (Mohri, 2009)
Because the composed automaton has no cycle that can be traversed without consuming a source symbol, the number of consumed source symbols tends to infinity with the number of transitions. The probability of generating at least k source symbols tends to zero as , so the series converges.
For each position and state , let be the sum of the weights of all paths that start at the initial state, emit , and end in immediately after emitting . Summing over the states reached after emitting gives
The backward weights are computed once for all states, while is updated after each target symbol. The composed state space is finite for an n-gram source, but not for a neural language model whose next-symbol probabilities depend on the complete source prefix.
E THE GENETIC-CODE WORST CASE
This appendix analyzes a worst case for the DNA setting in §4.3. Standard beam search captures an exponentially vanishing share of the target mass, while smc_simple, smc_rb, and fixed-M beam_swor are exact for any M. Consider a uniform source model over source strings of length 3T on a four-symbol alphabet, and a target of length T where each target symbol is the image of d length-three source blocks (“codons”). Assume that the live proposal samples each of the d codons with probability 1/d. This holds, for example, for repeated isoleucine, where and the three codons differ only in their final base. Exactly strings in the source model’s support belong to the precover, so .
Standard beam search. beam_summing with prune retains at most M of these source strings, yielding
This ratio vanishes exponentially in . For and , the smallest beam that recovers all the mass has . The estimate is biased for any , systematically underestimating .
Importance-weighted estimators. Each valid codon has source probability and proposal probability , so its importance weight gains the factor under both smc_simple and smc_rb (Eq. (27) and (38)). After T amino acids every particle carries
(a) beam_swor_adaptive dial

CPU time / seed (s)
(b) smc_rb resample threshold

resample threshold
Figure 14: Sensitivity to the pruning parameters on the ten-paragraph bigram corpus (eight seeds). (a) Between-seed standard deviation of the corpus log against CPU time per seed as varies for beam_swor_adaptive at nominal . Labels give , and plain beam_swor at is the fixed-M reference. (b) Survivor-conditioned standard deviation as the ESS threshold varies for smc_rb at . A corpus seed survives when all ten paragraph estimates are nonzero. Annotations mark settings with fewer surviving seeds and note that none survives at .
so exactly. The factor emerges in the importance weights, letting particles represent covering source strings. Thus smc_simple and smc_rb both have zero variance. Fixed-M beam_swor is also exact. At every branch its child weights are equal, and its without-replacement reweighting preserves their total on every draw.
This is an extreme case, a uniform source and a constant alias count . In practice, non-uniform DNA models introduce variance across particles. The example does not distinguish among the stochastic estimators, whose variance differences are measured in the non-uniform experiments.
F DETAILS OF THE MECO RERUN
We compare contextual surprisals computed by beam summing with prune and swor_adaptive on the same 2,264 PTB units in the 12 MECO trials (individually read paragraphs). We use the generalized additive mixed models (GAMMs) of Kiegeland et al. (2026), which model reading times with a log-normal distribution. The baseline includes unit length and unigram surprisal for the current unit and the two preceding units. The target model adds contextual surprisal at the same three positions. Both models include a participant random intercept and by-participant random slopes for every predictor. We use 12-fold leave-one-trial-out cross-validation and report per-observation held-out LL. Confidence intervals come from a 1,000-resample trial-level bootstrap, and significance is assessed with one-sided paired sign-flip tests. We change only the pruning function used to compute contextual surprisal and rerun the fits on the same observations (n=33,472). The prune values are the telescoping estimates reported by Kiegeland et al. (2026), computed with a threshold of . For swor_adaptive, we use and nominal , and average each prefix-probability estimate over 10 runs before taking logarithms. The reported GAMM fits use the resulting surprisals without a jackknife correction. The analysis below shows that applying the correction changes no conclusion.
Jackknife check. Averaging the prefix-probability estimates preserves unbiasedness, but taking the logarithm of an average introduces bias. To estimate it, we recompute each unit's surprisal ten times, omitting one run each time. If is one unit's surprisal from all ten runs and is its surprisal with run omitted, the jackknife estimates the bias as , which we subtract from .
The correction raises the corpus log probability by 1.55 nats, equivalently lowering its surprisal by the same amount. It changes the 106-nat uncorrected difference reported in §4.5 to approximately
107 nats. Refitting with the corrected surprisals moves every held-out LL by at most nats and changes neither the results in Tab. 3 nor the matched comparison below.
Matched fit comparison. Under the experimental setup of Kiegeland et al. (2026), one-sided paired sign-flip tests show no evidence of a predictive difference between the matched PTB-word fits ( in both directions for every measure).
G ADDITIONAL BYTE-TO-WORD RESULTS
Figs. 15 and 16 extend the exact bigram validation of Fig. 6 to every byte position in all ten paragraphs. Tab. 4 reports the additional per-paragraph GPT-2 estimates and runtimes.
---- beam_summing () ---- beam_summing () —— beam_swor —— beam_swor_adaptive () —— exact ground truth


Figure 15: Per-position ratio for all ten paragraphs at , averaged over 256 runs. Paragraphs 0–5 are shown here and 6–9 in Fig. 16. The beam_swor and beam_swor_adaptive averages remain close to one with sampling variation. Threshold-pruned beam summing at and falls below one where pruning discards positive covering mass.


Figure 16: Per-position validation, paragraphs 6–9 (continued from Fig. 15), with the same methods and axes.
Table 4: Per-paragraph log-prefix probabilities in nats and wall time in seconds under . beam_summing uses . beam_swor_adaptive uses , nominal , and thirty-two runs. Parentheses give the between-run standard deviation, and wall times are per run. The column is beam_summing minus beam_swor_adaptive. The total row sums the per-paragraph log estimates. The corpus panel of Fig. 7 instead averages the per-run corpus estimates before taking the logarithm, hence its .
| para | beam_summing | beam_swor_adaptive | |||
|---|---|---|---|---|---|
| 0 | |||||
| 1 | |||||
| 2 | |||||
| 3 | |||||
| 4 | |||||
| 5 | |||||
| 6 | |||||
| 7 | |||||
| 8 | |||||
| 9 | |||||
| total |