Introduction
Modern language models (LMs) are incredibly powerful, but they typically define probability distributions over specific subword strings, such as Byte-Pair Encoding (BPE) tokens. However, downstream tasks often require entirely different output formats. A psycholinguist might need word-level probabilities, a software developer might want raw byte-level control, or a computational biologist might want to use a DNA-trained model to predict amino acid sequences.
This paper introduces a formal framework for Transduced Language Models, which allows pretrained models to output formats they weren't originally trained for. By composing a language model with a Finite-State Transducer (FST), the authors develop algorithms to rigorously calculate probabilities for these transformed outputs at inference time—without requiring any model retraining.
The String Mismatch Problem
The core challenge addressed by this paper is the string mismatch problem. Currently, practitioners often rely on ad-hoc post-processing to convert model outputs into desired formats. Unfortunately, this breaks the underlying probability math.
Because tokenization often involves many-to-one mappings, multiple different token sequences can map to the exact same target output. For example, the word "hello" could be generated as a single token hello, or as a combination of hell + o, or he + llo. To find the true probability of the target word, you cannot simply pick the most likely token sequence; you must marginalize (sum) over all possible source sequences that produce that target.
Doing this exact marginalization is often computationally intractable because the number of possible sequences grows exponentially with the length of the string.
Methods: Transducers and Decomposition
To solve this, the researchers treat the transformation as a formal function $f(X)$, where $f$ is represented by a Finite-State Transducer (FST)—a type of state machine that maps one string to another.
The paper's core contribution is a Decomposition Algorithm that breaks the set of all possible source strings (the "precover") into two manageable parts:
- The Quotient: A set of prefixes that are "safe" because every possible valid extension of them will eventually cover the target string.
- The Remainder: Specific strings that currently match the target but might fail to match if extended further.
To make this framework viable with heavy, modern LMs, the authors introduce several key optimizations:
- Frontier-Based Checks: Instead of building a massive new state machine, the algorithm lazily tracks "frontiers" (sets of possible states) as it processes strings.
- Probability Mass Pruning: To keep the search space manageable, the system discards low-probability paths that contribute negligible mass to the final sum.
- All-Universal Fast Path: For simple mappings (like BPE to bytes), the authors identified conditions where the math simplifies significantly, allowing for much higher throughput.
Key Insights and Results
The authors evaluated their framework across three distinct domains: Natural Language (converting tokens to bytes/words using Wikitext-2-raw-v1), Proteomics (converting DNA to amino acids using 65 human proteins), and across various models including GPT-2 Large, Llama 3.2-1B, Llama 3.1-8B, and Phi-4.
Key takeaways include: * Inference-Time Adaptation: You do not need to fine-tune a model to change its output format. If you can describe the transformation as a state machine, you can "wrap" the model in that machine. * High Accuracy: Using a pruning threshold of $1e-4$, the transduced models achieved extremely low Jensen-Shannon Divergence (JSD) compared to exact distributions, meaning the approximations are nearly perfect. * Throughput: For the "Tokens to Bytes" task, the optimized "fast path" achieved throughputs of 40–80 bytes per second on Llama and GPT-2 models. * Handling Complexity: The system successfully handled the DNA-to-amino-acid conversion, a notoriously difficult task involving a three-to-one mapping (codons) where the number of possible source sequences grows rapidly. It also successfully converted BPE-based models to follow complex Penn Treebank (PTB) word segmentation guidelines. * Interoperability: By providing a standard autoregressive interface (next-symbol distributions and prefix probabilities), these transduced models can be dropped directly into existing search algorithms like beam search or top-p sampling.
Limitations and Future Work
While the framework is highly effective, it does come with computational overhead. A throughput of 80 bytes/sec is functional but significantly slower than raw LM inference, as obtaining a full distribution for every step is computationally expensive.
Furthermore, the current study focuses on functional FSTs (deterministic mappings). Future work could explore stochastic transducers, where one input might map to multiple outputs with different probabilities (useful for machine translation or transliteration). Finally, in cases where the probability mass is widely dispersed across many possible source strings (like the DNA task), pruning becomes less effective. The authors suggest importance sampling as a potential future solution for these "high-entropy" mappings.
Summary updated