GLM: General Language Model Pretraining with Autoregressive Blank Infilling

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

Introduction

The landscape of Natural Language Processing (NLP) has long been fragmented by architectural specialization. Models like BERT excel at Natural Language Understanding (NLU) through bidirectional context, while GPT-style models dominate unconditional text generation via autoregressive processing. Meanwhile, encoder-decoder architectures like T5 attempt to bridge these worlds for conditional generation. GLM (General Language Model) introduces a unified framework that harmonizes these paradigms into a single architecture using a novel "autoregressive blank infilling" objective.

The Challenge of Architectural Silos

Historically, choosing a model meant accepting trade-offs. BERT’s bidirectional nature makes it a powerhouse for classification but leaves it ill-equipped for fluid text generation. Conversely, GPT’s left-to-right constraint prevents it from fully capturing context in NLU tasks. While encoder-decoder models like BART or T5 offer a middle ground, they often require significantly more parameters to match the NLU performance of a dedicated encoder. GLM addresses this by creating a flexible architecture that adapts its attention mechanism to the task at hand.

Methodology: Autoregressive Blank Infilling

The core of GLM is its unique pretraining objective. Unlike BERT, which masks individual tokens, GLM masks continuous spans of text.

The GLM pretraining workflow: from span sampling to autoregressive generation with 2D positional encoding and self-attention masking.

The process involves three key components:

  1. Part A and Part B Division: The input is split into a corrupted sequence (Part A) and the masked spans (Part B). Part A uses bidirectional attention, allowing the model to see the full context of the "blanks." Part B is generated autoregressively, using unidirectional attention to predict tokens one by one.
  2. 2D Positional Encoding: To handle variable-length spans without knowing their length in advance, GLM employs two positional IDs. Position 1 represents the index of the [MASK] token in the original text, while Position 2 tracks the internal index within the missing span.
  3. Span Shuffling: The model randomly permutes the order in which it predicts multiple blanks, forcing it to learn complex interdependencies between different parts of the sentence.

Key Insights: NLU as Generation

A pivotal shift in GLM is treating NLU tasks as generative "cloze" questions. Instead of adding a task-specific classification layer, GLM transforms inputs into a format aligned with its pretraining.

Reformulating NLU tasks as generative cloze questions allows GLM to leverage its pretraining objective for classification.

For example, a sentiment analysis task is reframed: "The movie was great. It's really [MASK]." The model then predicts tokens like "good" or "bad." This alignment ensures that the knowledge gained during pretraining translates directly to downstream performance, making the model highly parameter-efficient.

Performance and Results

GLM demonstrates superior performance across a wide array of benchmarks:

  • NLU Superiority: On the SuperGLUE benchmark, GLM-Large outperformed BERT-Large by 5.0%, showcasing the power of its unified objective.
  • Generative Excellence: GLM matched or exceeded specialized models like BART and T5 on summarization (Gigaword) and question generation (SQuAD).
  • Zero-Shot Capabilities: In the LAMBADA zero-shot setting, GLM-Large outperformed GPT-Large, proving that bidirectional context in Part A provides a significant advantage over purely unidirectional models.

Conclusion

GLM represents a significant step toward a truly general-purpose language model. By unifying autoencoding and autoregressive objectives, it achieves state-of-the-art results in both understanding and generation. While current implementations rely on some manual pattern design for cloze tasks, the efficiency and versatility of the GLM architecture suggest a promising path forward for unified pretraining in NLP.

Summary updated

BibTeX
@inproceedings{du2022glm,
  author = {Zhengxiao Du and Yujie Qian and Xiao Liu and Ming Ding and Jiezhong Qiu and Zhilin Yang and Jie Tang},
  title = {{GLM: General Language Model Pretraining with Autoregressive Blank Infilling}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.acl-long.26},
}
Figure