CRFs for text generation: higher-order decoding, diffusion and candidate lattices
A conditional random field can generate text by making the output words its variables and decoding their joint sequence. Yuntian Deng and Alexander M. Rush developed higher-order CRF cascades in Cascaded Text Generation with Markov Transformers (NeurIPS 2020), then candidate-lattice generation with exact path search in Sequence-to-Lattice Models for Fast Translation (Findings of EMNLP 2021). These models connect parallel neural computation to dependent output decisions—the same coordination problem encountered when diffusion language models generate several tokens together.
Independent choices select a mismatched subject and verb.
Compatibility is 0.9 for matching number and 0.1 otherwise. Scores are unnormalized path products.
How does a CRF generate a sentence?
Let x be a source sentence and y₁, …, yₙ the target words to generate. Each yᵢ ranges over candidate output tokens. Potentials score combinations of neighboring words, conditioned on x; structured decoding chooses the output sequence. The predicted variables are the words of the translation itself.
Deng and Rush’s Cascaded Text Generation, first released on 1 June 2020, increases the Markov order across a cascade of CRFs. Higher-order factors score longer token spans, and a shared Markov Transformer computes their potentials. Their 2021 Sequence-to-Lattice model instead constructs a compact candidate lattice and scores first-order transitions before Viterbi path search. Both generate target sentences by modeling dependencies among output words.
Consider two valid continuations: “the dog runs” and “the dogs run.” Independent choices at each position also admit “the dog run.” Better representations help a network predict each marginal, but a product of marginals still cannot express that the noun and verb must agree. An explicit joint model assigns scores to combinations, making compatibility part of the output distribution and decoding procedure.
This separates two design choices: how expensive neural scores are computed, and how the final sequence is selected. Scores for many alternatives can be computed together, then combined by a small structured inference algorithm. Sun and colleagues’ Fast Structured Decoding for Sequence Models (NeurIPS 2019) combines non-autoregressive emissions with an approximate first-order CRF and dynamic transitions. Higher-order contexts, successive pruning, and candidate-lattice construction provide additional design choices.
Higher-order CRFs: Cascaded Text Generation with Markov Transformers
Cascaded Text Generation introduces a sequence of CRFs with increasing Markov order. It begins with independent token scores, then adds dependencies over progressively longer spans. A single Markov Transformer supplies the potentials at every order through controlled context windows. Max-marginals score a span by the best complete sequence containing it; pruning retains promising spans before the next, more expressive stage.
The contribution combines higher-order output dependencies, shared neural parameterization, and parallel structured inference. This is distinct from the first-order dynamic CRF in Sun et al. Its parallel dynamic-programming formulation has logarithmic depth in sequence length for fixed retained width.
How structured generation connects to joint diffusion decoding
Diffusion introduces a repeated version of the same coordination problem: several uncertain tokens are resolved during one denoising step. The connection to structured generation is a modeling principle: use a tractable joint distribution to couple those decisions while retaining parallel neural computation. A Markov order describes dependence across output positions; a diffusion timestep describes the progression from corrupted to recovered text. They are different axes.
CoDD, introduced in Breaking the Factorization Barrier in Diffusion Language Models (ICML 2026), combines factorized neural predictions with a probabilistic-circuit structural prior. Its experiments instantiate that prior with a hidden Markov model. The product supports joint inference without materializing a vocabulary-sized table for every possible token combination. This shares the structured-generation goal, while using latent-state structure and diffusion-conditioned inference rather than a cascade of increasing observed-token context orders.
DA-DLM (EMNLP 2026) makes the relationship to non-autoregressive translation explicit. It adapts directed-acyclic-graph modeling to iterative denoising: node groups correspond to output positions, and previously fixed tokens become anchors connected to unresolved candidates. Its graph changes as denoising proceeds. The earlier models apply structured output modeling to translation; DA-DLM places it inside diffusion denoising.
Candidate lattices: Sequence-to-Lattice Models for Fast Translation
Sequence-to-Lattice replaces a deep decoder with candidate lookup, neural edge scoring, and path search. A statistical alignment model proposes a small vocabulary at each output position. A deep encoder and a shallow scoring head evaluate transitions between candidates in parallel. Viterbi then selects the highest-scoring complete path.
The paper specifies a first-order conditional Markov model with locally normalized transition probabilities. Viterbi finds the exact optimum among the candidates retained in the constructed lattice. Candidate construction, edge scoring and path search are separate stages: build alternatives cheaply, score compatible neighbors together, and search the resulting graph.
From candidate lattices to coherent speculative drafts
Parallel speculative drafting creates a related setting: several candidates are available at each future position, but individually attractive choices need not form a useful draft. LiLiCorr keeps top-K candidates, computes incoming and outgoing vectors in a lightweight network, scores adjacent compatibility with batched operations, and performs a greedy walk. Its training objective targets accepted prefixes and co-adapts the drafter and scoring head.
The connection to Sequence-to-Lattice is the candidate–edge–path architecture. Translation candidates come from an alignment-based lookup model; LiLiCorr candidates come from a parallel drafter. Sequence-to-Lattice uses exact Viterbi for a complete path objective; LiLiCorr uses local normalization and greedy selection aligned with prefix acceptance.
DiffuSpec uses a diffusion model as a parallel drafter and introduces Causal-consistency Path Search over its token lattice, together with draft-length adaptation from acceptance feedback. Here the graph mediates between bidirectional draft proposals and an autoregressive verifier. A lattice describes the candidate organization; the scoring rule and verification procedure determine what selecting a path accomplishes.
Choose the inference objective before choosing the graph
Three operations over the same graph answer different questions. Maximization finds the best complete path under a score. Marginalization sums over alternatives to measure probability or train a latent model. Sampling draws a sequence according to a distribution. Replacing one operation with another changes the algorithm even when the nodes and edges are identical.
A small numerical example makes the distinction concrete. Suppose the first decision offers A with probability 0.6 and B with probability 0.4. The strongest continuation after A has conditional probability 0.5; after B it has probability 0.9. Greedy selection begins with A. Whole-path maximization chooses B because 0.4 × 0.9 exceeds 0.6 × 0.5. In speculative decoding, the target verifier introduces another objective: the useful quantity is the accepted prefix, together with the cost of producing it.
To compare implementations, identify the candidate set, the edge dependence, the normalization, and the inference operation. Then measure the work that dominates runtime: neural passes, candidate scoring, dynamic programming, and verification.
Download the self-contained joint-decoding notebook or Python script. A three-token compatibility factor changes the sequence selected from a small candidate lattice. Max-sum dynamic programming finds the best path, and sum-product computes the global normalizer.
A separate locally normalized example demonstrates why greedy token selection and whole-path Viterbi search choose different paths. The examples expose exact structured inference on fixed scores. The papers supply the neural scoring, higher-order cascade, pruning and candidate-construction methods described above.