BANG: Bridging Autoregressive and Non-autoregressive Generation with Large Scale Pretraining

Weizhen Qi, Yeyun Gong, Jian Jiao, Yu Yan, Weizhu Chen, Dayiheng Liu, Kewen Tang, Houqiang Li, Jiusheng Chen, Ruofei Zhang, Ming Zhou, Nan Duan

TL;DR

BANG (Bridging Autoregressive and Non-autoregressive Generation) is a large-scale pretraining framework that unifies fast, parallel text generation with high-quality, sequential generation. By using a novel multi-stream attention mechanism, it allows a single model to achieve near-state-of-the-art quality while running up to 10x faster than traditional models.

The Problem: The AR vs. NAR Trade-off

In the world of Natural Language Generation (NLG), researchers face a classic trade-off between Autoregressive (AR) and Non-autoregressive (NAR) models.

  • AR models (like GPT or BART) predict one token at a time, using every previous word to decide the next. This results in high-quality, coherent text, but it is inherently slow because it cannot be parallelized during inference.
  • NAR models attempt to predict all tokens simultaneously. They are incredibly fast but often produce "mushy" or repetitive results because they lack the context of what other words are being generated at the exact same moment.

While large-scale pretraining has revolutionized AR models, NAR models have lagged behind, often relying on smaller datasets or "knowledge distillation" from AR models. BANG addresses this by creating a pretraining objective that explicitly bridges the gap between these two paradigms.

Methods: Cross-Stream Visible N-Stream Self-Attention

The core innovation of BANG is its cross-stream visible n-stream self-attention mechanism.

Standard Transformers use a single stream of data. BANG, however, processes multiple "streams" in parallel during pretraining:

  1. Main Stream: Uses "golden" (correct) tokens as context, similar to standard teacher-forcing in AR models.
  2. Predicting Streams: BANG creates $n$ different predicting streams. In the $i$-th stream, the model is asked to predict a token where $i-1$ previous tokens have been replaced by a [MASK] symbol.
BANG Pretraining Framework

By training on all these streams simultaneously, the model learns a spectrum of generation: from full context (AR) to partial context (Semi-NAR) to zero context (NAR). The loss function is a composite of these three parts, effectively acting as a curriculum learning path where the high-accuracy AR task helps the model learn the much harder NAR task.

Datasets and Evaluation

  • Pretraining: The model was pretrained from scratch on a 16GB English corpus consisting of Wikipedia and BookCorpus.
  • Evaluation: The authors tested BANG on three diverse NLG benchmarks:
  • SQuAD 1.1: Question generation.
  • XSum: Extreme abstractive summarization.
  • PersonaChat: Multi-turn dialogue generation with specific personas.

Key Insights and Ideas

  • Generation as a Continuum: The authors argue that AR and NAR aren't entirely different species of models, but rather points on a spectrum defined by "how much previous context is visible." BANG treats this visibility as a tunable parameter.
  • The "Bridging" Loss: The most interesting part of the training is the "bridging" loss. By training the model to predict tokens with some missing context, it learns to handle the uncertainty inherent in fast generation without completely losing coherence.
  • One Model, Three Modes: After pretraining, a single BANG model can be finetuned for AR, NAR, or Semi-NAR. In Semi-NAR mode, it generates the first few words sequentially to set the "style" or context, and then finishes the sentence in one parallel burst.
Semi-NAR Inference Mode

Key Results

BANG significantly outperforms previous non-autoregressive baselines while remaining highly competitive with top-tier autoregressive models:

  • Massive NAR Improvements: On SQuAD 1.1, BANG's NAR performance improved overall scores by 11.01 points over the best previous NAR baseline. On XSum, it saw a 7.13 point absolute improvement.
  • Speedup: BANG’s NAR mode achieved a 10.2x speedup compared to a standard AR Transformer, with a latency of only ~15ms per sample versus ~160ms.
  • AR Parity: When used in AR mode, BANG achieved performance comparable to specialized AR-only pretrained models like MASS and ProphetNet, proving that training for NAR doesn't have to "dilute" the model's sequential reasoning abilities.
  • Diversity in Dialogue: In PersonaChat, BANG showed much higher "Distinct-1/2" scores than baselines, meaning it produces more varied and interesting responses rather than repeating safe, generic phrases.

Limitations and Future Work

  • Translation Tasks: While NAR is a staple of Machine Translation, this paper focused on general NLG (summarization, dialogue). Testing BANG's cross-lingual capabilities remains a future step.
  • Semi-NAR Heuristics: The "Semi-NAR" strategy currently uses a fixed number of AR tokens before switching to NAR. The authors suggest that more flexible, adaptive combinations of sequential and parallel generation could be explored.
  • Computational Overhead: While inference is fast, the n-stream attention mechanism adds complexity to the pretraining phase, though the authors mitigated this with block-wise attention calculations.

Summary updated

BibTeX
@inproceedings{qi2021bang,
  author = {Weizhen Qi and Yeyun Gong and Jian Jiao and Yu Yan and Weizhu Chen and Dayiheng Liu and Kewen Tang and Houqiang Li and Jiusheng Chen and Ruofei Zhang and Ming Zhou and Nan Duan},
  title = {{BANG: Bridging Autoregressive and Non-autoregressive Generation with Large Scale Pretraining}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=QDiB2IrKpHE},
}
Figure