BERTs are Generative In-Context Learners

David Samuel
2/3/2026

No official code found. Best implementation: ltgoslo/bert-in-context (32 stars, Apache-2.0, last commit 2025-03-14).

Abstract

While in-context learning is commonly associated with causal language models, such as GPT, we demonstrate that this capability also 'emerges' in masked language models. Through an embarrassingly simple inference technique, we enable an existing masked model, DeBERTa, to perform generative tasks without additional training or architectural changes. Our evaluation reveals that the masked and causal language models behave very differently, as they clearly outperform each other on different categories of tasks. These complementary strengths suggest that the field's focus on causal models for in-context learning may be limiting - both architectures can develop these capabilities, but with distinct advantages; pointing toward promising hybrid approaches that combine the strengths of both objectives.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Official implementation of "BERTs are Generative In-Context Learners"

320Shell, PythonMay 29, 20241 years agoApache-2.0

Similar Papers

Cite this paper

@article{samuel2026berts,
  title  = {BERTs are Generative In-Context Learners},
  author = {David Samuel},
  year   = {2026},
  eprint = {2406.04823},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2406.04823},
  url    = {https://arxiv.org/abs/2406.04823},
  journal = {NEURIPS 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2406.04823.svg)](https://codeofpaper.com/paper/2406.04823)

Discussion