In traditional generative modeling, researchers often face a rigid choice: either generate sequences one step at a time (autoregressive) or predict everything at once (non-autoregressive). Both approaches have long been haunted by the "fixed-length" problem. Autoregressive models can wander into infinite loops, while non-autoregressive and diffusion models typically require an external, often inaccurate, module to guess the output length before generation even begins.
A growing body of research is moving toward learned termination mechanisms, where the model itself decides when a task is complete. By treating "stopping" as a semantic action rather than a structural constraint, these models achieve greater flexibility across domains ranging from text and code to molecular chemistry and human motion.
The Problem with Fixed Canvas Generation
Most parallel generative models, such as standard Non-Autoregressive Transformers (NAT) or Diffusion models, operate on a fixed-size canvas. To generate a sentence or a molecule, you must first tell the model how many "slots" to fill. If the guess is too short, information is lost; if it is too long, the model produces "word salad" or repetitive artifacts.
Xingdi Yuan and colleagues highlighted this in One Size Does Not Fit All, noting that forcing a model to generate a "Top 10" list of keyphrases when only three are relevant leads to irrelevant noise. Similarly, in the realm of computer vision, Amine Kechaou and the team behind Detective argued that traditional object detectors rely on complex post-processing to handle varying object counts, whereas a model that can "stop" naturally treats detection as a simple sequential counting task.
Termination as a Semantic Action
The core intuition behind this research direction is that the end of a sequence is just another piece of information. Instead of using an external length predictor, models are trained to emit a dedicated End-of-Sequence (EOS) token or a "stop" signal within the same vocabulary as the data itself.
This approach has been successfully integrated into diverse architectures:
- Parallel Generation: Weizhen Qi and the authors of BANG demonstrated that by incorporating an EOS token into a parallel generation framework, a single model can bridge the gap between slow autoregressive and fast non-autoregressive generation without needing a separate length module.
- Reinforcement Learning: In MemSum, Elliott Ash treats extractive summarization as a sequential decision process where the model "remembers" its history and chooses a stopping action once the information density of the summary is sufficient.
- Continuous Latents: For modalities like 3D motion, Zekun Li and the LLaMo team use a binary classifier head on top of continuous tokens to signal termination, allowing the model to end an animation naturally based on the movement's context.
Dynamic Resizing via Edit Operations
Perhaps the most sophisticated evolution of this idea is moving away from "filling slots" entirely and toward edit-based generation. Instead of predicting a static grid, models like the Insertion Transformer by Mitchell Stern generate by inserting tokens into gaps. The process stops organically when the model predicts a "termination" signal for every available gap.
This concept has been extended to diffusion models, which are traditionally the most "fixed-canvas" of all architectures. Marton Havasi and Ricky T. Q. Chen introduced Edit Flows, which uses fundamental edit operations—insertions and deletions—to adaptively determine sequence length during sampling. Similarly, Zirui Wu and the DreamOn team added [expand] and [delete] tokens to the diffusion vocabulary, allowing the model to literally resize its own generation canvas as it refines a piece of code.
Why It Works: Coupling Content and Duration
The reason learned termination outperforms fixed-length estimation is coupling. When a model predicts length before generating content, it is making a blind guess. When a model predicts a stop signal during generation, it is making a decision based on the evidence it has already produced.
In Next-Sentence Prediction for Summarization, Jackie Chi Kit Cheung shows that a model can learn the internal "discourse structure" of a summary. It stops not because it hit a word limit, but because it recognizes that the semantic relationship between the current summary and the source document has reached a point of diminishing returns.
This mechanism is particularly vital in high-stakes fields like chemistry. In tt DiffER, Sean Current and colleagues use learned padding tokens to allow a retrosynthesis model to dynamically adjust the length of a predicted molecular sequence. This ensures that the chemical reaction is described with exactly the number of components it needs—no more, no less.
Conclusion
By internalizing the "horizon" of generation—as explored by Hantian Ding in Horizon-Length Prediction—modern AI is moving toward a more autonomous understanding of task completion. Whether it is a robot deciding a motion is finished or a summarizer deciding it has captured the main point, learned termination allows models to adapt their output volume to the inherent complexity of the problem, finally breaking free from the constraints of the fixed-size canvas.