Introduction
The Insertion Transformer presents a paradigm shift from the traditional "one-word-at-a-time, left-to-right" approach of sequence generation. By allowing tokens to be inserted anywhere in a sequence simultaneously, it achieves the high translation quality of standard autoregressive Transformers while drastically reducing decoding time from linear ($O(n)$) to logarithmic ($O(\log n)$) iterations.
The Autoregressive Bottleneck
Most neural sequence models, including the original Transformer and GPT architectures, are autoregressive. They generate text sequentially, one token at a time from left to right. While highly effective for quality, this creates a massive computational bottleneck: generating a 50-word sentence requires running the model 50 consecutive times.
Previous attempts at "non-autoregressive" models aimed to generate all words at once to save time. However, these approaches typically suffered from two major drawbacks:
- Fixed Lengths: They often require predicting the exact sentence length before generating any words.
- Poor Quality: They struggle with "multimodality"—the model might attempt to generate two different valid versions of a sentence simultaneously, resulting in a garbled output.
The Insertion Transformer addresses these issues by building a model that retains the flexibility and high quality of a standard Transformer but is designed from the ground up for parallel execution.
Methods: The Canvas and Parallel Insertion
The Insertion Transformer treats sequence generation as an iterative process on a dynamic "canvas."
- The Canvas: Instead of a fixed left-to-right buffer, the model maintains a sequence that starts empty and grows dynamically via insertions.
- Architecture Changes: The standard Transformer decoder is modified by removing the causal mask. This allows every token in the current sequence to attend to every other token, providing full bidirectional context for every insertion decision.
- Slot Representations: To decide what to insert between two existing words, the model produces "slot representations" by concatenating the hidden states of adjacent tokens. For a sequence of $n$ tokens, there are $n+1$ possible slots for new words.
- The Balanced Binary Tree Loss: During training, the model is incentivized to predict the middle token of any missing span. If the model consistently picks the middle word, it can build a sentence of length $N$ in just $\log_2 N$ steps.
- Parallel Decoding: During inference, the model evaluates every empty slot between its current words and can insert a new token into all of them simultaneously in a single forward pass.
Key Insights and Performance
Logarithmic Scaling
The primary triumph of the Insertion Transformer is the shift from $O(n)$ to $O(\log n)$ decoding steps. For a 32-word sentence, a standard autoregressive model takes 32 steps; the Insertion Transformer takes approximately 5.
Unlike other fast models that guess the length upfront, the Insertion Transformer grows naturally. It terminates only when every slot between words predicts an "End of Slot" (EOS) token.
Order Agnosticism
Because the model is trained to insert tokens anywhere, it is not locked into a left-to-right generation path. It can be trained to follow a binary tree, a left-to-right path, or even a completely random order, increasing its robustness and flexibility.
Empirical Results
The model was evaluated on the standard WMT 2014 English-German (En-De) machine translation benchmark, utilizing Knowledge Distillation from a standard Transformer teacher model to aid training.
- Quality: The Insertion Transformer achieved a 27.41 BLEU score, effectively matching the performance of the original, slower Transformer (27.3 BLEU).
- Speed: In parallel decoding mode, the model achieved a 4.19x latency improvement over the standard Transformer for single-sentence decoding on a GPU.
Limitations and Future Work
While highly efficient in step count, the Insertion Transformer has some trade-offs:
- Computational Overhead per Step: While it takes fewer steps, each step is slightly more computationally expensive because it must re-process the entire growing sequence (standard autoregressive Transformers can cache previous states).
- The EOS Penalty: The model occasionally attempts to terminate generation too early. The authors introduced a manually tuned "EOS penalty" to discourage premature termination.
- Training Complexity: Training requires exposing the model to many different partial "canvases" to learn how to fill them correctly, making the training process more complex than standard left-to-right models.
Ultimately, the Insertion Transformer proves that high-quality sequence generation does not strictly require left-to-right autoregression, opening the door for highly parallelized generation in text and potentially extending to spatial domains like image generation.
Summary updated