All NLP Tasks Are Generation Tasks: A General Pretraining Framework

Zhengxiao Du, Yujie Qian, Xiao Liu, Ming Ding, Jiezhong Qiu, Zhilin Yang, Jie Tang

Abstract

There have been various types of pretraining architectures including autoencoding models (e.g., BERT), autoregressive models (e.g., GPT), and encoder-decoder models (e.g., T5). However, none of the pretraining frameworks performs the best for all tasks of three main categories including natural language understanding (NLU), unconditional generation, and conditional generation. We propose a General Language Model (GLM) based on autoregressive blank infilling to address this challenge. GLM improves blank filling pretraining by adding 2D positional encodings and allowing an arbitrary order to predict spans, which results in performance gains over BERT and T5 on NLU tasks. Meanwhile, GLM can be pretrained for different types of tasks by varying the number and lengths of blanks. On a wide range of tasks across NLU, conditional and unconditional generation, GLM outperforms BERT, T5, and GPT given the same model sizes and data, and achieves the best performance from a single pretrained model with 1.25x parameters of BERT Large, demonstrating its generalizability to different downstream tasks.

The Fragmentation of Pretraining Paradigms

In the current NLP landscape, pretraining architectures are often fragmented by task type. Bidirectional autoencoding models like BERT excel at Natural Language Understanding (NLU) but struggle with text generation. Conversely, unidirectional autoregressive models like GPT are designed for generation but lack the bidirectional context necessary for deep understanding. While encoder-decoder models like T5 attempt to bridge this gap, they often require significantly more parameters to match the performance of specialized models.

The General Language Model (GLM) addresses this by unifying these paradigms into a single, flexible framework. By adopting a novel "autoregressive blank infilling" objective, GLM inherits the strengths of all three families without their inherent disadvantages.

Methodology: Autoregressive Blank Infilling

The core innovation of GLM is its pretraining objective. Instead of simple masking or next-token prediction, GLM randomly blanks out continuous spans of tokens and learns to reconstruct them autoregressively.

The GLM pretraining process: (a) sampling spans, (b) dividing input into Part A and Part B, (c) autoregressive generation, and (d) the resulting self-attention mask.

The process involves several key components:

  1. Input Division: The input is split into Part A (corrupted text with [MASK] tokens) and Part B (the original removed spans). Part A is processed with bidirectional attention, while Part B is generated autoregressively.
  2. 2D Positional Encoding: To handle variable-length blanks without "leaking" the answer length, GLM uses two positional IDs: one for the [MASK] position in the original text and another for the internal position within the generated span.
  3. Span Shuffling: The model is trained to predict multiple spans in a random order to capture dependencies between different missing segments.
  4. Multi-Task Flexibility: By varying the blanking strategy—short spans for NLU, and long spans or full sentences for generation—a single model can be optimized for both understanding and creation.

Key Insights: NLU as Generation

A major conceptual shift in GLM is the reformulation of NLU tasks as "cloze" questions. For example, a sentiment analysis task can be framed as predicting a missing word in a prompt: "The movie was [MASK]" $\rightarrow$ "good".

Reformulating NLU tasks as cloze-style generation allows GLM to bridge the gap between pretraining and finetuning.

This approach reduces the "pretrain-finetune inconsistency" that often affects models like BERT. Furthermore, GLM demonstrates that bidirectional context is vital even for language modeling; allowing bidirectional attention over the context (Part A) significantly improves performance over purely unidirectional models.

Experimental Results

GLM was evaluated across a wide range of benchmarks, demonstrating superior parameter efficiency and performance:

  • SuperGLUE: $GLM_{Large}$ outperformed $BERT_{Large}$ by an average of 5.0%, also surpassing RoBERTa and BART when trained on comparable data.
  • Summarization: On the XSum dataset, GLM matched the performance of the much larger BART model and outperformed T5 and UniLM.
  • Zero-shot Language Modeling: On the LAMBADA dataset, GLM outperformed GPT-Large in predicting the final word of passages.
  • Ablation Studies: Results confirmed that span shuffling is critical; its removal led to significant performance degradation on NLU tasks.

Conclusion and Future Directions

GLM provides a unified solution to the fragmentation of NLP pretraining. While the current models show state-of-the-art performance up to 515M parameters, the framework is naturally suited for scaling. Future work involves exploring GLM at multi-billion parameter scales, similar to GPT-3, to further unlock its potential for general-purpose language understanding and generation.

Summary updated

BibTeX
@inproceedings{du2022all,
  author = {Zhengxiao Du and Yujie Qian and Xiao Liu and Ming Ding and Jiezhong Qiu and Zhilin Yang and Jie Tang},
  title = {{All NLP Tasks Are Generation Tasks: A General Pretraining Framework}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.acl-long.26},
}
Figure