AI Pulse by Inblix

ModernBERT drops: A 6-year BERT reign ends with 8K context and 2x speed gains

Hugging Face Blog · Dec 19, 2024 · 2 min read · Read original article →

Curated by the Inblix editorial team


Featured image for article: ModernBERT drops: A 6-year BERT reign ends with 8K context and 2x speed gains

BERT has been the unkillable workhorse of practical AI since 2018—68 million monthly downloads doesn’t lie. But today, Answer.AI and LightOn are finally shipping a genuine replacement. Meet ModernBERT, an encoder-only model family that takes the architectural and training advances poured into massive generative models over the last few years and ports them back to the lean, mean BERT paradigm.

What you actually get: a base model at 149 million parameters and a large at 395 million, both with an 8,192 token context length. That’s 16 times what most existing encoders can handle. The speed difference is equally stark—ModernBERT is designed for Flash Attention 2 and processes sequences much faster than its predecessors, all while delivering better downstream performance on tasks like classification and retrieval.

This isn’t an academic exercise. The model is a slot-in replacement for any BERT-like pipeline, and it’s landing in Hugging Face’s transformers library starting with version 4.48.0. One minor API shift: you can drop token_type_ids entirely. The real unlock here is what the extended context window makes possible. Suddenly, full-document retrieval for RAG pipelines goes from a multi-step hack to a straightforward operation. Code search across entire files is viable. The training data itself includes a significant amount of code—a first for any open encoder model.

I’m most curious whether the 8K context length holds up in real-world retrieval benchmarks, or if we’ll see the same degradation patterns that plague long-context decoders. But for anyone running classification, content moderation, or entity extraction at scale, this is the first credible upgrade path in half a decade. The old BERT checkpoints aren’t going anywhere, but the performance gap just got wide enough to matter.

💡 Key Takeaways

  1. ModernBERT offers an 8,192 token context window, a 16x increase over the 512 tokens common in most encoder models, enabling full-document retrieval.
  2. The model is a drop-in replacement for existing BERT pipelines but does not use `token_type_ids`, so downstream fine-tuning code needs that minor adjustment.
  3. By incorporating architectural advances from recent large language models, ModernBERT achieves both higher accuracy and significantly faster processing than its predecessors.
  4. It is the first open encoder-only model to include a substantial amount of code in its training data, expanding its utility for code search and IDE applications.

Keep reading: See related articles below for more coverage on this topic.

Get smarter about AI

The sharpest AI news, curated daily. Delivered free to your inbox.

Learn more

Glossary terms

← Back to all articles