BERTs are Generative In-Context Learners

David Samuel

Abstract

Since the advent of GPT-3, the field of Natural Language Processing has largely shifted toward Causal Language Models (CLMs), assuming that the emergent ability of in-context learning (ICL) is a unique byproduct of the next-token prediction objective. This paper challenges that assumption by demonstrating that Masked Language Models (MLMs), such as DeBERTa, are also capable of generative ICL. By employing a simple iterative masking technique at inference time, we show that a 1.5B parameter DeBERTa model not only performs generative tasks but often outperforms similarly sized GPT-3 models on language understanding benchmarks. Our findings suggest that ICL is a general phenomenon emerging from model scale and data quality rather than a specific training objective.

Introduction

The prevailing wisdom in NLP has increasingly viewed MLMs as "deprecated" tools, restricted to task-specific classification and fine-tuning. The ability to learn from a few examples in a prompt without parameter updates was thought to be the exclusive domain of CLMs. This paper investigates whether this "causal hegemony" is justified or if ICL is an objective-agnostic property of sufficiently large language models.

Methods

The authors introduce an "embarrassingly simple" inference technique to transform an off-the-shelf MLM into a generative, promptable model without additional training.

  1. Iterative Text Generation: To enable generation, the model appends a [MASK] token to a prompt, predicts it, and repeats the process. To prevent the model from prematurely ending sequences (a common issue with MLMs expecting a [SEP] token), multiple "padding" masks are appended to provide the model with sufficient generation "room."
  2. Improved Ranking (Pseudo-Log-Likelihood): For multiple-choice tasks, the authors refine the Pseudo-Log-Likelihood (PLL) scoring. By masking additional tokens in the right-hand context during scoring, they mitigate biases from local subword dependencies, forcing the model to rely on global context.
  3. Length Generalization: Utilizing DeBERTa’s relative positional embeddings, the model can process prompts significantly longer than its 512-token training window, a capability verified through "needle in a haystack" testing.
Iterative text generation and pseudo log-likelihood ranking for MLMs.

Key Results

The evaluation compared DeBERTa (up to 1.5B parameters) against GPT-3 variants. The results indicate that MLMs scale in a log-linear fashion similar to CLMs.

  • Language Understanding: On SuperGLUE (1-shot), DeBERTa-1.5B achieved an average score of 68.4, significantly outperforming the GPT-3-1.3B (57.8) and nearly matching the 175B parameter version.
  • Language Modeling: On HellaSwag, DeBERTa (62.4) outperformed GPT-3 (53.5) at comparable scales.
  • Knowledge Retrieval Weakness: DeBERTa struggled in Closed-book QA (e.g., scoring 2.6 on TriviaQA vs. GPT-3's 26.5), suggesting that bidirectional objectives may be less efficient at storing and retrieving specific factoid knowledge.
Performance scaling of DeBERTa vs. GPT-3 across various benchmarks.

Discussion and Insights

The study provides several critical insights into the nature of modern language models:

  • ICL is Objective-Agnostic: Prompt-based learning is a function of scale, not just the training objective. Had the community scaled BERT-style models as aggressively as GPT, generative emergent abilities might have been recognized much earlier.
  • Complementary Strengths: MLMs excel at deep linguistic understanding due to their bidirectional nature, while CLMs appear superior for knowledge-heavy retrieval tasks.
  • Efficiency Trade-offs: While capable of generation, MLMs are currently less efficient because their bidirectional architecture prevents the use of "KV caching," requiring a full re-pass of the sequence for every new token generated.

Limitations and Future Work

Future research should address the inference speed gap, perhaps through "prefix language modeling" architectures. Additionally, while DeBERTa showed high data efficiency, its poor translation performance—likely due to monolingual training—highlights the need to test these techniques on large-scale multilingual MLMs. The results ultimately point toward a potential hybrid architecture that combines bidirectional understanding with efficient causal generation.

Summary updated

BibTeX
@inproceedings{samuel2024berts,
  author = {David Samuel},
  title = {{BERTs are Generative In-Context Learners}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=BCA9NMZkLS},
}
Figure