arXiv:2608.27428cs.CLAug 2026

Manuscript Offprint

arXiv:2608.27428

Stochastic Estimation of Transduced Language Models

Vésteinn Snæbjarnarson, Samuel Kiegeland, Manuel de Prada Corral, Ryan Cotterell, Tim Vieira

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).