Abstract
Traditional neural sequence models generate text autoregressively from left to right, a process that is inherently slow and lacks the flexibility of human-like revision. We present the Levenshtein Transformer (LevT), a novel non-autoregressive model that generates sequences through iterative refinement using two basic edit operations: insertion and deletion. By decoupling generation from a fixed order, LevT achieves significant speedups—up to 5x over standard Transformers—while maintaining competitive translation quality and enabling unique capabilities like zero-shot text editing.
Introduction
Most state-of-the-art sequence-to-sequence models are autoregressive, producing one token at a time. While effective, this linear dependency results in generation times that scale with sentence length. Conversely, fully non-autoregressive models, which attempt to generate all tokens simultaneously, often suffer from poor quality due to their inability to correct errors or dynamically adjust output length.
The Levenshtein Transformer bridges this gap by mimicking the human writing process: drafting, deleting, and inserting. This framework treats sequence generation as an iterative refinement task, allowing for parallelized operations and dynamic length control.
Architecture and Methods
The LevT is built upon the standard Transformer architecture, augmented with three specialized policy classifiers that share a common Transformer backbone:
- Deletion Classifier: Evaluates each token in the current sequence to decide whether it should be kept or removed.
- Placeholder Classifier: Analyzes the gaps between existing tokens to predict the number of new tokens (placeholders) required at each position.
- Token Classifier: Replaces predicted placeholders with actual vocabulary tokens.
Dual-Policy Learning
Training the LevT involves imitation learning through a "dual-policy" approach. The insertion and deletion policies are trained to mimic an "expert"—typically a ground-truth oracle or a high-performing pre-trained teacher model. During training, the model learns to reconstruct clean sequences from noisy or incomplete drafts, effectively learning how to fix errors and fill in gaps simultaneously.
Inference
During inference, the model starts with an initial sequence (e.g., an empty string for generation or a rough draft for refinement). It enters a loop, alternating between deletion and insertion phases. The process terminates when the sequence reaches a steady state (no further changes) or a predefined iteration limit is met. Most sequences stabilize within 1 to 4 iterations.
Experimental Results
The authors evaluated the LevT across Machine Translation (MT), Text Summarization (TS), and Automatic Post-Editing (APE) tasks.
Quality and Speed
As shown in the results table, the LevT remains highly competitive with autoregressive baselines. On the WMT’16 Romanian-English (Ro-En) task, the LevT distillation model achieved a BLEU score of 33.26, surpassing the standard Transformer's 32.30. Crucially, the LevT offers a dramatic reduction in latency, achieving up to a 5x speedup in wall-clock time.
Zero-Shot Capability
A standout feature of the LevT is its "zero-shot" post-editing capability. A model trained solely for translation can refine drafts produced by entirely different systems without any task-specific fine-tuning. This flexibility stems from the model's fundamental design as an editor rather than a simple generator.
Discussion and Conclusion
The Levenshtein Transformer unifies sequence generation and refinement into a single, efficient framework. By leveraging parallel edit operations, it overcomes the speed bottlenecks of autoregressive models and the quality limitations of previous non-autoregressive approaches.
While the model occasionally faces challenges such as termination loops or unreliable log-probability metrics for beam search, its controllability makes it an ideal candidate for human-in-the-loop applications. Future work may explore more robust termination criteria and the application of LevT to broader document-level editing tasks.
Summary updated