ModernBERT 레시피를 디코더 전용 모델에 적용하면 어떤 일이 일어날까요? 결과적으로 Llama 3.2 1B 와 SmolLM2 를 능가하는 최상위 수준 (SoTA) 디코더 언어 모델을 만들었습니다!
우리는 새로운 오픈데이터 훈련 레시피를 소개합니다. 이 레시피로 엔코더 전용 ModernBERT 모델 (그리고 실제로는 이를 능가하여!) 을 재현할 수 있습니다. 우리는 동일한 레시피를 디코더 전용 모델에 적용합니다. 이제야 두 가지 다른 훈련 목표 (masked language modeling (MLM) 와 causal language modeling (CLM)) 를 가진 동일한 설정에서 훈련된 두 개의 최상위 수준 모델을 보유하게 되었습니다.
이 블로그 포스트는 Ettin 을 소개합니다. Ettin 은 첫 번째 SoTA paired encoder-only and decoder-only models (17M-1B params) 입니다. 이 모델들은 동일한 데이터 (2T tokens), 아키텍처, 및 훈련 레시피로 훈련되었습니다. Ettin 은 아키텍처 간 진정한 apples-to-apples 비교를 가능하게 하며, 두 카테고리 모두에서 state-of-the-art performance for open-data models 를 제공합니다. 우리는 이제 디코더에서 시작하여 경쟁력 있는 엔코더를 얻는 것이 가능한지, 그리고 그 반대의 경우를 더 탐구합니다.
모델을 테스트해 보려는 분들에게 이 블로그 포스트의 끝부분에 일부 boilerplates 가 있습니다!
LLM 커뮤니티는 GPT, Llama, Qwen 와 같은 디코더 전용 모델에 크게 수렴했습니다. 그들의 생성 능력은 놀랍습니다만, 이러한 집중은 BERT 와 같은 엔코더 전용 모델을 포함한 다른 카테고리에서 주목을 빼앗고 있습니다.
그러나 엔코더 BERT-like 모델은 분류, 검색, 임베딩 작업의 프로덕션 시스템의 일등공신입니다. 그들은 더 빠르고, 메모리 효율성이 높으며, 판별적 (discriminative) 작업에서는 종종 더 정확합니다. 핵심 차이는 attention 패턴에 있습니다:
Encoder models는 bidirectional attention 을 사용하여 각 토큰이 시퀀스 내 모든 다른 토큰을 "보게" 됩니다 (fully visible).
Decoder models는 causal attention 을 사용하여, autoregressive generation 을 가능하게 하기 위해 이전 토큰만 볼 수 있습니다.
디코더 모델은 빠른 혁신을 보였지만, 엔코더 모델 개발은 최근 ModernBERT 와 같은 노력까지도 제외하고 고착화되어 있었습니다. 그러나 어떤 아키텍처가 더 나은가요? 이전의 엔코더와 디코더 비교는 다른 데이터셋, 아키텍처, 및 훈련 레시피를 사용했기 때문에 판단하기 어려웠습니다.
Ettin 은 두 개의 노스 신화 거인 이름에서 유래되었으며, 동일한 데이터, 동일한 모델 모양 (model shapes), 및 동일한 훈련 레시피로 두 가지 아키텍처로 훈련함으로써 controlled comparison 를 제공합니다. 그들은 attention 패턴과 훈련 목표에서만 다릅니다!
우리는 디코더 전용 모델의 현대적 기법을 차용하여 엔코더 훈련에 가져온 ModernBERT 레시피를 기반으로 합니다. 이는 두 아키텍처를 훈련하는 강력한 기반을 제공합니다.
우리는 17M 에서 1B 파라미터까지 다양한 6 가지 크기를 훈련합니다. 이는 규모의 효과를 테스트할 수 있게 하며, 여러분이 사용할 수 있는 다양한 모델을 제공합니다! 당신이 빠른 on-device 모델이 필요하든, 강력하지만 느린 모델이 필요하든, 우리는 모두 커버해 드립니다!
우리는 성능을 극대화하기 위해 포괄적인 세 단계 훈련 방식을 사용합니다:
Phase 1 - Pre-training (1.7T tokens): 우리는 다양한 고품질 데이터 소스의 혼합으로 시작하며, 짧은 컨텍스트 (1024 tokens) 에서 훈련하여 강력한 기초 지식을 확립합니다.
Phase 2 - Context Extension (250B tokens): 우리는 더 높은 품질의 필터링된 데이터를 사용하여 컨텍스트 길이를 8K 토큰으로 늘립니다. 이를 통해 모델이 더 긴 문서와 복잡한 관계를 이해할 수 있습니다.
Phase 3 - Decay (100B tokens): 과학 논문, 교재 및 큐레이션된 콘텐츠와 같은 프리미엄 데이터 소스를 포함하여 학습률을 점진적으로 감소시키면서 마무리합니다.
Our encoder models gain all the benefits of ModernBERT's speed, allowing them to be significantly faster than the previous generations of encoders. (ModernBERT 의 속도상의 모든 혜택을 얻어 이전 세대 엔코더보다 훨씬 빠르게 작동할 수 있습니다.)
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!
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:
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.
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:
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!
We switched the objective and continued to train our models with the opposite objective for 50B additional tokens. This is what we found:
Encoder-from-decoder: Still generally trails native encoders on classification/retrievalDecoder-from-encoder: Are significantly worse than native decoders, especially at larger scales. This may be because the encoders were trained with MLM instead of MNTP (masked next token prediction) as proposed by LLM2Vec (and used in our encoder from decoder recipe).
This suggests the architecture choice matters fundamentally, not just the training objective.
With identical training data, we can study how different objectives affect learning. For example, analyzing gender bias using the WinoGender benchmark reveals:
Encoder modelsprefer gender-neutral pronouns more often (60%+ neutral vs 30%+ for decoders)Both architecturesshow male bias, but decoders slightly more soCross-objective trainingaffects bias patterns in measurable ways
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!
from transformers import AutoTokenizer, AutoModel
분류/임베딩 임베딩을 위한 인코더 로드
tokenizer = AutoTokenizer.from_pretrained("jhu-clsp/ettin-encoder-150m")
...
분류 및 검색 작업을 위해 인코더 모델을 사용하세요: 이러한 작업에 대해 세밀 조정된 버전을 사용하시길 원할 수 있습니다.
텍스트 생성 작업을 위해 디코더 모델을 사용하세요:
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("jhu-clsp/ettin-decoder-150m")
...
import argparse
from datasets import load_dataset
from sentence_transformers import (
...
PyLate 를 사용하여 이를 다중 벡터 임베딩 모델로 세밀 조정하는 방법을 확인하려면 클릭하세요
from datasets import load_dataset
from pylate import losses, models, utils
from sentence_transformers import (
...
import logging
from datasets import load_dataset
from sentence_transformers import (
...
import logging
import traceback
import torch
...
디코더 학습 코드를 펼치기 위해 클릭하세요
python trl/scripts/sft.py \
--model_name_or_path jhu-clsp/ettin-decoder-17m \
--dataset_name trl-lib/Capybara \
...
python trl/scripts/sft.py \
--model_name_or_path jhu-clsp/ettin-decoder-17m \
--dataset_name trl-lib/Capybara \
...
sft.py 와 함께:
import argparse
from datasets import load_dataset
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
...
완전한 Ettin suite 는 인코더 및 디코더 모두에 대해 6 가지 다른 규모 (scale) 의 모델을 포함합니다:
표준 모델:
- ettin-encoder-17m / ettin-decoder-17m (17M 파라미터)
- ettin-encoder-32m / ettin-decoder-32m (32M 파라미터)
- ettin-encoder-68m / ettin-decoder-68m (68M 파라미터)
- ettin-encoder-150m / ettin-decoder-150m (150M 파라미터)
- ettin-encoder-400m / ettin-decoder-400m (400M 파라미터)
- ettin-encoder-1b / ettin-decoder-1b (1B 파라미터)
연구 리소스:
- 🤗 Ettin Model Collection
- 📝 Paper
- 🗂️ Training Data (2T+ 토큰, 완전 오픈)
- 💻 GitHub Repository
- 📊 250+ 학습 체크포인트를 통해 학습 동역학 또는 지식 학습을 연구하기 위한 것