Smarter, Better, Faster, Longer: A Modern Bidirectional Encoder for Fast, Memory Efficient, and Long Context Finetuning and Inference

Paper · arXiv 2412.13663
LLM Memory

Encoder-only transformer models such as BERT offer a great performance-size tradeoff for retrieval and classification tasks with respect to larger decoder-only models. Despite being the workhorse of numerous production pipelines, there have been limited Pareto improvements to BERT since its release. In this paper, we introduce ModernBERT, bringing modern model optimizations to encoder-only models and representing a major Pareto improvement over older encoders. Trained on 2 trillion tokens with a native 8192 sequence length, ModernBERT models exhibit state-ofthe-art results on a large pool of evaluations encompassing diverse classification tasks and both single and multi-vector retrieval on different domains (including code). In addition to strong downstream performance, Modern- BERT is also the most speed and memory efficient encoder and is designed for inference on common GPUs.

Introduction. After the release of BERT (Devlin et al., 2019), encoder-only transformer-based (Vaswani et al., 2017) language models dominated most applications of modern Natural Language Processing (NLP). Despite the rising popularity of Large Language Models (LLMs) such as GPT (Radford et al., 2018, 2019; Brown et al., 2020), Llama (Touvron et al., 2023; Dubey et al., 2024), and Qwen (Bai et al., 2023; Yang et al., 2024), encoder-only models remain widely used in a variety of nongenerative downstream applications. The encoder’s popularity is largely due to their modest inference requirements, enabling them to efficiently process corpora of documents at scale for retrieval and quickly perform discriminative tasks. Encoder models offer a compelling tradeoff in quality versus size, making them a popular option against encoder-decoder and decoder-only language models when dealing with substantial amounts of data (Penedo et al., 2024).

Discussion / Conclusion. We present ModernBERT, an open family of encoder-only models which set a new state of the art over existing encoder models on a wide range of classification and retrieval tasks. We show that encoders benefit from both recent pretraining data scales and architecture improvements from autoregressive LLMs. ModernBERT pushes the encoder state of the art forward across a wide range of benchmarks. On GLUE, ModernBERT-base is the first encoder to beat DeBERTaV3-base since its release in 2021. ModernBERT is in a class of its own in code and ColBERT-style long-context retrieval benchmarks, scoring at least 6.85 and 9.1 percentage points higher than the closest model, respectively, while remaining state-of-the-art on short-context retrieval in both single and multi-vector settings. At the same time, ModernBERT processes short context inputs twice as fast as DeBERTaV3 and long-context inputs two times faster than the next fastest model with best-in-class memory efficiency.

Lines of inquiry this paper opens 24

Research framings built by reading the notes related to this paper — the questions it feeds into.

How should retrieval systems optimize for multi-step reasoning during inference? Why do semantic similarity and task relevance diverge in vector embeddings? Which computational strategies best support reasoning in language models? How do adversarial and manipulative prompts attack reasoning models? What structural advantages do diffusion language models offer over autoregressive methods? How do transformer attention mechanisms implement memory and algorithmic functions? What articulatory information do speech signals carry that text cannot? Why does finetuning cause catastrophic forgetting of model capabilities? How does example difficulty affect learning efficiency in language models? When does architectural design matter more than raw model capacity? How do knowledge injection methods compare across cost and effectiveness? Can next-token prediction alone produce genuine language understanding? How should inference compute be adaptively allocated based on prompt difficulty? Should GUI agents use structured representations instead of raw pixels? What drives capability and cost efficiency in agent systems? Does tokenized intelligence retain genuine value through exchange-based systems? How do prompt structure and constraints affect model instruction reliability?