GPT or BERT: why not both?
Lucas Georges Gabriel Charpentier, David Samuel
TL;DR
GPT-BERT presents a simple, unified approach to combine masked language modeling and causal language modeling within a single transformer. By shifting MLM outputs to align with next-token predictions, the model can operate in MLM, CLM, or prefix modes without architectural changes. Across BabyLM benchmarks, the hybrid objective improves performance relative to single-objective baselines and enables in-context learning signals in compact models. The work demonstrates that a 1:15 causal-to-masked data ratio, along with targeted modifications (attention gate, layer weighting, and scheduling strategies), yields robust, versatile language representations with efficient training. This suggests that merging modeling paradigms can enhance generalization and practical applicability in low-resource settings.
Abstract
We present a simple way to merge masked language modeling with causal language modeling. This hybrid training objective results in a model that combines the strengths of both modeling paradigms within a single transformer stack: GPT-BERT can be transparently used like any standard causal or masked language model. We test the pretraining process that enables this flexible behavior on the BabyLM Challenge 2024. The results show that the hybrid pretraining outperforms masked-only or causal-only models. We openly release the models, training corpora and code.
