What would happen if you took the ModernBERT recipe and applied it to a decoder-only model? Turns out, a state-of-the-art decoder language model that beats Llama 3.2 1B and SmolLM2!

In a recent development, we introduce a latest open-data training recipe to reproduce the encoder-only ModernBERT model (and actually beat it!). We then apply the exact same recipe to decoder-only models. For the first time, we have two state-of-the-art models trained in the same setup but with two different training objectives: masked language modeling (MLM), and causal language modeling (CLM). (Related: How to train a newly introduced language model from scr...)

In a recent development, this blog post introduces Ettin, the first suite of SoTA paired encoder-only and decoder-only models (17M-1B params) trained with identical data (2T tokens), architecture, and training recipes. Ettin enables true apples-to-apples comparisons between architectures and delivers state-of-the-art performance for open-data models in both categories. We then further explore whether it is possible to get a competitive encoder starting from the decoder and vice-versa. (Related: Block Sparse Matrices for Smaller and Faster Language M...)

If you are interested in trying out the models, some boilerplates are available at the end of this blogpost!

The LLM community has largely converged on decoder-only models like GPT, Llama, and Qwen. Their generative capabilities are impressive, but this focus is detracting attention from other categories, such as encoder-only models like BERT.

Industry observers note that however, encoder BERT-like models remain the workhorses of production systems for classification, retrieval, and embedding tasks. They're faster, more memory-efficient, and often more accurate for discriminative tasks. The key difference lies in their attention patterns:.

In a recent development, while decoder models have seen rapid innovation, encoder model development had stagnated – until recently, with efforts like ModernBERT modernizing them. But which architecture is better? Previous comparisons between encoders and decoders used different datasets, architectures, and training recipes, so it was hard to tell.

Named after the two-headed Norse giant, Ettin provides a controlled comparison by training with both architectures on identical data, identical model shapes, and identical training recipes. They only differ in attention patterns and training objectives!

We build on the ModernBERT recipe, which borrowed modern techniques from decoder-only models and brought them to encoder training. This provides a strong base for training both architectures.

We train six different sizes, ranging from 17M to 1B parameters. This allows us to test the effects of scale, and provides a wide variety of models for you to use! No matter if you need a blazing fast on-device model or a powerful but slower model, we got you covered!

We use a comprehensive three-phase training approach to maximize performance:.

Phase 1 - Pre-training (1.7T tokens): We start with a diverse mixture of high-quality data sources, training on shorter contexts (1024 tokens) to establish strong foundational knowledge.

Phase 2 - Context Extension (250B tokens): We increase context length to 8K tokens using higher-quality filtered data, allowing models to understand longer documents and more complex relationships.

Phase 3 - Decay (100B tokens): We finish with premium data sources including scientific papers, textbooks, and curated content while gradually reducing the learning rate.

Our encoder models gain all the benefits of ModernBERT's speed, allowing them to be significantly faster than the previous generations of encoders.

Unlike ModernBERT, all our training data is public and reproducible:.

You can continue to train these models on new data or propose a new recipe to further improve results!

It has been revealed that our encoder models outperform ModernBERT across all tasks and model sizes, while using completely open training data. Since we provide a large range of sizes, you can now use ModernBERT-style models in smaller sizes (great for on-device or for fast-inference), or power up with a 1B-sized encoder that crushes the competition.

Applying the same recipe to decoder models yields equally impressive results, with our models outperforming or matching established baselines such as Llama 3.2 and SmolLM2:.

Recent findings suggest that the gains are particularly strong on knowledge-intensive tasks like SciQ, reflecting the benefits of our high-quality training data mixture. These results demonstrate that our training recipe creates genuinely strong models in both architectural paradigms.

It has been revealed that for the first time, we can fairly compare encoder and decoder architectures trained with identical data and recipes. The results reveal fundamental architectural advantages that persist even when all other factors are controlled:.

The results show clear patterns:.

In a recent development, encoders dominate classification and retrieval: On MNLI classification, even a 150M encoder (89.2) outperforms a 400M decoder (88.2). For retrieval tasks, the gap is smaller but still noticeable - especially when decoders are not trained with MNTP.

Decoders excel at generation: On generative tasks, decoders maintain consistent advantages, with the performance gap actually widening at larger model sizes.

Size doesn't always matter: A 400M encoder beats a 1B decoder on classification tasks, while a 400M decoder beats a 1B encoder on generation tasks.

Due to the lack of new encoder models, works like LLM2Vec have proposed to continue pre-training decoders with MLM. We can now test the effectiveness of this strategy!

It has been revealed that we switched the objective and continued to train our models with the opposite objective for 50B additional tokens. This is what we found:.

This suggests the architecture choice matters fundamentally, not just the training objective.

It has been revealed that with identical training data, we can study how different objectives affect learning. For example, analyzing gender bias using the WinoGender benchmark reveals:.

This opens doors for systematic studies of how training objectives influence model behavior beyond just accuracy metrics.

You can use these models with just a few lines of code!

For classification and retrieval tasks, use encoder models: You may want to use a fine-tuned version for these tasks as well.

For text generation tasks, use decoder models:.

The complete Ettin suite includes models at six different scales (for both encoders and decoders):.

According to recent reports, any chance you can add the trained sentence transformer versions of these models? It'd be very useful (And I lack compute for training from scratch :)).

Yes, we’re working with some people to get some trained embeddings versions. Hopefully you won’t have to wait too long :).

Assim como aplicar uma receita de treino inovadora pode superar modelos de ponta, FondecranVIP redefine o visual do seu dispositivo com wallpapers exclusivos e de alta qualidade, levando sua personalização a um nível superior.

Thank you for an interesting study.

Do you have prepares to create encoder-decoder models from these?

→ Read original article