NeoBERT: A Next Generation BERT

Lola Le Breton, Quentin Fournier, John Xavier Morris, Mariam El Mezouar, Sarath Chandar

Abstract

Recent innovations in architecture, pre-training, and fine-tuning have led to the remarkable in-context learning and reasoning abilities of large auto-regressive language models such as LLaMA and DeepSeek. In contrast, encoders like BERT and RoBERTa have not seen the same level of progress despite being foundational for many downstream NLP applications. To bridge this gap, we introduce NeoBERT, a next-generation encoder that redefines the capabilities of bidirectional models by integrating state-of-the-art advancements in architecture, modern data, and optimized pre-training methodologies. NeoBERT is designed for seamless adoption: it serves as a plug-and-play replacement for existing base models, relies on an optimal depth-to-width ratio, and leverages an extended context length of 4,096 tokens. Despite its compact 250M parameter footprint, it achieves state-of-the-art results on the massive MTEB benchmark, outperforming BERT${large}$, RoBERTa${large}$, NomicBERT, and ModernBERT under identical fine-tuning conditions. In addition, we rigorously evaluate the impact of each modification on GLUE and design a uniform fine-tuning and evaluation framework for MTEB. We release all code, data, checkpoints, and training scripts to accelerate research and real-world adoption.

Introduction

While auto-regressive "decoder" models (like LLaMA and GPT-4) have seen explosive growth in architecture and data scaling, "encoder" models—the workhorses of embeddings, retrieval, and classification—have largely stagnated. The industry still relies heavily on BERT and RoBERTa, models released over five years ago. These legacy models suffer from outdated knowledge, short context windows (typically 512 tokens), and architectural choices that haven't benefited from the "scaling laws" discovered in recent years. NeoBERT aims to provide a modern, high-performance, "plug-and-play" replacement for these aging backbones.

Methods: Architectural Modernization

The authors systematically upgraded the BERT architecture by adopting several state-of-the-art techniques common in modern decoders. Key architectural changes include:

  • Normalization and Activation: Replacing standard LayerNorm with Pre-RMSNorm and swapping GeLU for SwiGLU activations.
  • Positional Encoding: Integrating Rotary Position Embeddings (RoPE) to handle longer sequences and improve generalization.
  • Optimal Depth-to-Width Ratio: Moving away from the standard "base" (12 layers) or "large" (24 layers) configurations, NeoBERT uses 28 layers with a hidden size of 768. This "deeper but narrower" approach is more parameter-efficient.
  • Two-Stage Pre-training: To extend the context window to 4,096 tokens efficiently, a two-stage approach was used: initial training on 1,024-token sequences followed by a "long-context" phase using a sampling strategy that prioritized longer documents.
The cumulative impact of systematic modifications (M1-M10) on GLUE performance, leading to the final NeoBERT model.

Key Insights and Design Choices

  • The "Depth-Inefficiency" Fix: Traditional encoders are often "width-inefficient." By increasing depth while maintaining a hidden size of 768, NeoBERT remains a "plug-and-play" replacement for existing pipelines while delivering superior performance.
  • Tokenizer Selection: Interestingly, the LLaMA tokenizer (BPE) decreased performance on GLUE compared to the traditional WordPiece tokenizer. Consequently, NeoBERT retains WordPiece, highlighting the importance of tokenizer-task alignment.
  • Masking Rate: While BERT used a 15% masking rate, NeoBERT utilizes 20%. As models and datasets scale, a slightly more difficult pre-training task (MLM) yields better downstream performance.
  • Context Generalization: Thanks to RoPE, NeoBERT generalizes well beyond its 4,096 training limit, showing stable pseudo-perplexity on sequences up to 6,000 tokens.

Performance Evaluation

NeoBERT was rigorously evaluated on the GLUE and MTEB benchmarks. On MTEB, NeoBERT (250M parameters) achieved an average score of 51.3, outperforming BERT-large, RoBERTa-large, and ModernBERT. When combined with Contextual Document Embeddings (CDE), it reached a score of 66.60, ranking #1 for models under 400M parameters.

On the GLUE benchmark, NeoBERT achieved an average score of 89.0, matching or exceeding the performance of models with significantly larger parameter counts.

GLUE benchmark results comparing NeoBERT to baseline and modern encoders across various task categories.

Conclusion

NeoBERT represents a significant step forward for encoder models, bridging the gap with modern LLM advancements. While it achieves a massive leap in context length (4,096 tokens) and performance, future work may explore ultra-long-context techniques like YaRN or training on even larger, cleaner datasets to further push the boundaries of bidirectional language understanding.

Summary updated

BibTeX
@article{breton2025neobert,
  author = {Lola Le Breton and Quentin Fournier and John Xavier Morris and Mariam El Mezouar and Sarath Chandar},
  title = {{NeoBERT: A Next Generation BERT}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=TJRyDi7mwH},
}
Figure