The paper behind ModernBERT
Makes encoder models fast and powerful again with smart architecture choices.
ModernBERT introduces efficient encoder-only transformers with modern optimizations, achieving state-of-the-art performance while maintaining fast inference and low memory usage.
-----
https://arxiv.org/abs/2412.13663
π€ Original Problem:
Encoder models like BERT, despite being widely used in production, haven't seen major improvements since release. They suffer from limited sequence lengths, suboptimal architecture, and inefficient training approaches.
-----
π§ Solution in this Paper:
β ModernBERT brings modern optimizations to encoder-only models with 8192 sequence length and 2 trillion training tokens
β Uses alternating global-local attention mechanism - global attention every third layer, local sliding window attention for others
β Implements advanced unpadding with Flash Attention for variable length sequences
β Adopts GeGLU activation and RoPE positional embeddings for better performance
β Removes bias terms in linear layers except final decoder for parameter efficiency
-----
π― Key Insights:
β Encoder models can match decoder performance with proper modernization
β Local-global attention mix provides optimal speed-quality tradeoff
β Hardware-aware model design significantly improves inference efficiency
β Modern tokenizers and large-scale training on diverse data is crucial
-----
π Results:
β First encoder to beat DeBERTaV3-base on GLUE since 2021
β Processes 8192-token sequences 2x faster than competitors
β Best-in-class memory efficiency with superior performance
β State-of-the-art results on code and long-context retrieval










