ImageNet classification with deep convolutional neural networks
Alex Krizhevsky, Ilya Sutskever et al.
0
Citations
0
Influential Citations
—
Venue
2024
Year
Modernized encoder-only transformer model trained on 2 trillion tokens with a native 8192 sequence length, incorporating architectural improvements like GeGLU activations, RoPE embeddings, alternating attention, and unpadding, resulting in state-of-the-art performance across diverse classification and retrieval tasks (including code) and superior inference speed and memory efficiency compared to existing encoder models.
Encoder-only models like BERT have been foundational for NLP tasks such as classification, retrieval, and question answering. However, they have seen less architectural innovation compared to decoder-only models in recent years. ModernBERT addresses this gap by introducing a suite of modern techniques—GeGLU activations, RoPE embeddings, alternating attention, and hardware-aware design—to create a more efficient and performant encoder. Its ability to handle long contexts (8192 tokens natively) and code data makes it particularly relevant for retrieval-augmented generation (RAG) and code search applications. The paper demonstrates that encoder-only models can still achieve Pareto improvements over older architectures, offering practitioners a drop-in replacement that is faster and more memory-efficient.

ModernBERT is a deep-and-narrow transformer with 22 or 28 layers (base and large versions). Key architectural changes include:
Efficiency improvements are central to ModernBERT:

The model design balances depth and width for hardware efficiency. Base model has hidden size 768 with GLU expansion 2304, while large has hidden size 1024 with expansion 5248. These ratios are chosen for optimal tiling on GPU tensor cores.
Training uses a modified OLMo tokenizer with vocabulary size 50,368 (multiple of 64) and includes 83 unused tokens for downstream tasks. The data mixture includes web documents, code, and scientific literature (2 trillion tokens). Training follows a three-phase schedule: 1.7 trillion tokens at 1024 sequence length with RoPE theta 10,000, then context extension to 8192 tokens by increasing global attention RoPE theta to 160,000 for 300 billion tokens, and finally a decay phase with upsampled high-quality sources. Masked language modeling uses a 30% masking rate (higher than the original 15%) and no next-sentence prediction.

ModernBERT achieves state-of-the-art results across multiple benchmarks:
Efficiency benchmarks on an NVIDIA RTX 4090 show:

ModernBERT represents a significant step forward for encoder-only models, demonstrating that careful architectural modernization can yield substantial gains in both performance and efficiency. For practitioners, it offers a practical upgrade path from older BERT variants, especially for tasks requiring long-context understanding or code processing. The model's efficiency improvements—particularly unpadding and alternating attention—make it suitable for deployment in latency-sensitive applications like real-time search and RAG pipelines. The open-source release on HuggingFace further lowers the barrier for adoption. Future work could explore fine-tuning strategies for specific domains or extending the approach to multilingual settings.
Alex Krizhevsky, Ilya Sutskever et al.
Ashish Vaswani, Noam Shazeer et al.
Douglas M. Bates, Martin Mächler et al.
Diederik P. Kingma, Jimmy Ba