TL;DR
NeoBERT is a modernized, 250M-parameter encoder that brings the architectural innovations of the LLaMA era (RoPE, SwiGLU, RMSNorm) to the BERT family. By optimizing the depth-to-width ratio and training on 2.1 trillion tokens of modern web data, it achieves state-of-the-art results on the MTEB benchmark, outperforming models significantly larger than itself while maintaining a plug-and-play 768-dimension hidden size.
What Problem Does This Paper Address?
While auto-regressive "decoder" models like LLaMA and DeepSeek have advanced rapidly, bidirectional "encoder" models have largely stagnated. The community still relies heavily on BERT and RoBERTa—models that are over five years old—for critical tasks like retrieval-augmented generation (RAG), text classification, and embedding generation.
These older encoders suffer from outdated knowledge, limited context windows (usually 512 tokens), and architectural inefficiencies. The authors introduce NeoBERT to bridge this gap, integrating modern best practices in architecture, data scaling, and pre-training to create a high-performance, efficient backbone for downstream NLP applications.
Methods
The authors systematically modernized the BERT architecture through a series of ten cumulative ablations (M0 through M10). Key changes include:
- Architecture Overhaul: NeoBERT adopts Rotary Position Embeddings (RoPE) for better length extrapolation, SwiGLU activation functions, and Pre-RMSNorm for improved training stability.
- Optimal Depth-to-Width Ratio: Moving away from the "width-inefficiency" of traditional BERT, NeoBERT uses a deeper architecture (28 layers) while maintaining the standard 768 hidden dimension to ensure it remains a drop-in replacement for existing pipelines.
- Two-Stage Pre-training: To handle long contexts efficiently, the model was first trained on 1,024-token sequences and then extended to 4,096 tokens in a second stage using a mix of short and long-sequence data.
- Training Recipes: The model uses a 20% masking rate (up from BERT's 15%), the AdamW optimizer with a cosine decay scheduler, and FlashAttention for computational efficiency.
Datasets
- Pre-training: NeoBERT was trained on RefinedWeb, a massive 2.8TB dataset containing 2.1 trillion tokens. This is nearly 18 times larger than the corpus used for RoBERTa.
- Evaluation: The model was rigorously tested on the GLUE (General Language Understanding Evaluation) benchmark for classification and the MTEB (Massive Text Embedding Benchmark) for retrieval and embedding tasks.
Key Insights and Ideas
- Scale and Data are King: The largest performance jumps in their ablation study came from switching to the RefinedWeb dataset (+3.6%) and increasing the parameter count to 250M (+2.9%).
- Depth Matters: Adjusting the depth-to-width ratio (moving from 16 layers of width 1056 to 28 layers of width 768) provided a significant boost, confirming that encoders benefit more from depth than width at this scale.
- Tokenizer Surprises: Interestingly, the authors found that the LLaMA BPE tokenizer actually caused a performance drop compared to the traditional Google WordPiece tokenizer for encoder tasks, leading them to stick with WordPiece.
- Efficiency at Length: Despite having 100M more parameters than ModernBERT-base, NeoBERT is faster at long context lengths (4,096 tokens), achieving a 46.7% speedup due to optimized implementation and architectural choices.
Key Results
NeoBERT establishes a new Pareto frontier for encoder models:
- GLUE: It achieves an average score of 89.0%, outperforming BERT-large and NomicBERT, and matching the performance of much larger models (340M+ parameters).
- MTEB: When fine-tuned with Contextual Document Embeddings (CDE), NeoBERT ranks #1 for models under 400M parameters as of April 2025, with an average score of 66.60.
- Context Handling: The model generalizes natively to sequences up to 6,000 tokens, well beyond its 4,096 training limit, thanks to the robustness of RoPE.
Limitations and Future Work
The authors acknowledge that NeoBERT inherits the inherent biases of its web-scraped pre-training data (RefinedWeb). Furthermore, while the model performs exceptionally well, the authors suggest that even greater gains could be achieved by retraining as even larger and higher-quality datasets become available. They also advocate for the development of more standardized, affordable fine-tuning protocols to ensure fair comparisons across the growing field of encoder-only models.
Summary updated