Finally, a Replacement for BERT: Introducing ModernBERT — screenshot of huggingface.co

Finally, a Replacement for BERT: Introducing ModernBERT

ModernBERT is a new encoder-only model family, offering significant improvements over BERT in speed, accuracy, and context length. It's a strong replacement for existing encoder-based NLP applications.

Visit huggingface.co →

Questions & Answers

What is ModernBERT?
ModernBERT is a new family of state-of-the-art encoder-only models designed as a replacement for older generation BERT-like models. It integrates modern LLM advances into an encoder architecture, improving performance and efficiency.
Who should use ModernBERT?
ModernBERT is intended for developers and researchers working on applications that benefit from efficient, non-generative models, such as Retrieval Augmented Generation (RAG) pipelines, classification, entity extraction, and recommendation systems.
How does ModernBERT improve upon traditional BERT models?
ModernBERT offers improvements across the board, including better downstream performance, faster processing, and a significantly larger 8192 sequence length compared to BERT's typical 512. It also includes code in its training data.
When is ModernBERT the ideal choice for an NLP task?
ModernBERT is ideal for tasks requiring high-performance encoder-only models where long context is beneficial, such as large-scale code search or full document retrieval, and for situations where decoder-only models are too large or slow.
What are the implementation details for using ModernBERT with Hugging Face Transformers?
ModernBERT is available in base (149M params) and large (395M params) sizes and can be used as a slot-in replacement for BERT-like models via AutoModelForMaskedLM. It's recommended to install Flash Attention 2 for maximum efficiency, and it does not use token type IDs.