Abstract
As the AI field shifts toward generative decoder models trained via Causal Language Modeling (CLM), the optimal strategy for training high-quality text encoders is being re-evaluated. This study presents a large-scale, controlled "apples-to-apples" comparison of pretraining objectives, revealing that while CLM is highly data-efficient in early training stages, Masked Language Modeling (MLM) remains essential for capturing the bidirectional context required for superior representation learning. We introduce a biphasic training strategy—starting with CLM and finishing with MLM—that achieves state-of-the-art encoder performance more efficiently than traditional methods.
Introduction: The Encoder Dilemma
For years, the standard recipe for building a text encoder like BERT was Masked Language Modeling (MLM), where models learn by filling in the blanks. Recently, however, massive decoder models (like GPT) trained on Causal Language Modeling (CLM) have been repurposed as encoders, sometimes outperforming traditional BERT-style models. This raised a fundamental question: Is CLM inherently better for learning representations, or are these newer models winning simply due to scale and data volume? To find out, we conducted a controlled study of 38 models with identical architectures and data to isolate the impact of the pretraining objective itself.
Methodology
We systematically compared three pretraining paradigms across three model sizes (210M, 610M, and 1B parameters):
- CLM (Causal): Predicting the next token (standard for GPT).
- MLM (Masked): Reconstructing hidden tokens using bidirectional context (standard for BERT).
- Biphasic (CLM+MLM): A two-stage approach where the model is first trained with CLM and then switched to MLM.
The models were trained on 100 billion tokens from the FineWeb-Edu dataset. We explored both Pretraining From Scratch (PFS) and Continued Pretraining (CPT), where an existing model's training is extended with a new objective. To ensure robust results, we conducted over 15,000 fine-tuning runs across 12 datasets in four core NLP categories: Sequence Classification (SC), Token Classification (TC), Question Answering (QA), and Information Retrieval (IR).
Key Results and Insights
Bidirectionality is the "Secret Sauce"
Our results confirm that bidirectionality is critical for representation quality. MLM consistently outperforms CLM on tasks requiring deep contextual understanding, such as Question Answering and Sequence Classification. CLM’s "left-to-right" constraint acts as a bottleneck for learning high-quality representations.
The Biphasic Advantage
A striking finding is the efficiency of the biphasic approach. CLM is a "sprint" learner; in the first 10k–20k steps, CLM-trained models learn faster and perform better than MLM models. However, CLM saturates sooner. By starting with CLM and finishing with MLM, we leverage CLM's initial efficiency and MLM's superior final representation quality. This strategy reliably surpasses the MLM-only baseline under fixed compute budgets.
Stability and Continued Pretraining
Models initialized with CLM pretraining were significantly more stable during fine-tuning and less sensitive to learning rate choices. Furthermore, adapting an existing CLM-pretrained decoder into an encoder using MLM (CPT) is more effective than simply training an MLM model for longer. This suggests that the most efficient path to a "best-in-class" encoder is to leverage existing open-source decoders and perform a short burst of MLM training.
Optimal Masking Ratios
The study also confirmed that the traditional 15% masking ratio is often too low for larger models; a 40% masking ratio provided a better performance compromise across all tasks.
Limitations and Future Work
While comprehensive, this study focused on English and capped model size at 1B parameters. Future work should explore if these trends hold at the 7B+ scale and how biphasic strategies interact with contrastive post-training for embedding optimization. Additionally, more complex curriculum learning schedules—perhaps alternating between CLM and MLM multiple times—could further push the boundaries of encoder performance.
Summary updated