Instructions to use MTSAIR/RuModernBertSmall with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MTSAIR/RuModernBertSmall with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="MTSAIR/RuModernBertSmall")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("MTSAIR/RuModernBertSmall") model = AutoModel.from_pretrained("MTSAIR/RuModernBertSmall", device_map="auto") - Notebooks
- Google Colab
- Kaggle
RuModernBertSmall
RuModernBertSmall is a compact Russian–English ModernBERT encoder from MTS AI. It was pretrained from scratch and distilled from the MTS AI Base model in its final training stage.
Intended use
Use the encoder as a backbone for supervised text classification, token classification, or ranking. It also exposes contextual token representations for frozen-feature experiments and as a starting point for training a retrieval model. The release contains encoder weights. Applications that require label predictions or masked-token prediction need a corresponding trained head.
Model details
| Property | Value |
|---|---|
| Architecture | ModernBertModel |
| Encoder parameters | 34,409,920 |
| Transformer layers | 21 |
| Hidden size | 320 |
| Intermediate size | 480 |
| Attention heads | 8 |
| Vocabulary size | 50,368 tokens |
| Configured maximum sequence length | 8,192 tokens |
| Weight format | FP32 Safetensors |
Quick start
Install PyTorch and Transformers. The checkpoint configuration was exported with Transformers 5.24.1.
import torch
from transformers import AutoModel, AutoTokenizer
model_id = "MTSAIR/RuModernBertSmall"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModel.from_pretrained(model_id).eval()
texts = ["Как изменить тариф?", "Как перейти на другой тарифный план?"]
inputs = tokenizer(texts, padding=True, truncation=True, return_tensors="pt")
with torch.inference_mode():
token_embeddings = model(**inputs).last_hidden_state
# Mean pooling over non-padding tokens as a simple starting point.
mask = inputs["attention_mask"].unsqueeze(-1).to(token_embeddings.dtype)
text_embeddings = (token_embeddings * mask).sum(dim=1) / mask.sum(dim=1).clamp_min(1)
Training
We trained Small from scratch with masked language modeling (MLM) on approximately 128B tokens from Russian FineWeb-2. In the final 12B-token stage, we trained with MLM and a KL distillation loss from the Base model with a coefficient of 0.5. The final data mix added English FineWeb, Russian and English Wikipedia, and code. We increased the training sequence length from 1,024 to 2,048 tokens and reduced the masking rate from 30% to 15% in that stage.
The tokenizer uses a 50,368-token BPE vocabulary. Its training sample contained about 10M documents, with an 80/10/10 mix of Russian FineWeb-2, English FineWeb, and code. Text preprocessing follows ruRoberta. The distillation teacher was the RuModernBertBase line.
Evaluation
| MTS AI checkpoint | RussianSuperGLUE accuracy | Encodechka score |
|---|---|---|
| RuModernBertSmall | 66.61% | 60.8 |
| RuModernBertSmallTripleMerge | 67.07% | 60.4 |
| RuModernBertBase | 71.29% | 64.2 |
| RuModernBertBaseTripleMerge | 72.40% | 65.7 |
Within the Small pair, the original checkpoint scored higher on frozen representations (60.8 vs. 60.4). Its Triple-Merge counterpart averaged 0.46 percentage points higher after RussianSuperGLUE fine-tuning.
RussianSuperGLUE
We fine-tuned the encoder and a task-specific head on each of seven RussianSuperGLUE tasks. We selected hyperparameters from 27 combinations using five seeds per combination, then ran the selected configuration on ten fresh seeds. The table shows validation accuracy in percent, with standard deviation across those ten seeds. The aggregate weights all seven tasks equally.
| Task | Validation accuracy (%) |
|---|---|
| RCB | 54.05 ± 1.06 |
| PARus | 55.90 ± 1.45 |
| MuSeRC | 75.86 ± 0.56 |
| TERRa | 63.36 ± 1.59 |
| RUSSE | 92.79 ± 0.59 |
| RWSD | 56.27 ± 0.69 |
| DaNetQA | 68.04 ± 2.40 |
| Mean | 66.61% |
Encodechka
For Encodechka, we froze the encoder and evaluated its representations directly or with a lightweight classifier, depending on the task. Scores use each task's own metric, scaled by 100. The aggregate weights all ten tasks equally.
| Task | Score (0–100 scale) |
|---|---|
| STS-B | 68.3 |
| Paraphraser | 57.1 |
| XNLI | 33.1 |
| Sentiment | 75.2 |
| Toxicity | 94.3 |
| Inappropr. | 75.5 |
| Intents | 74.7 |
| IntentsX | 48.2 |
| FactRu | 43.7 |
| RuDReC | 38.4 |
| Mean | 60.8 |
Limitations
- We report evaluation results on Russian benchmarks. Training also included English data.
- The original Small model's final distillation stage used sequences of up to 2,048 tokens. The model and tokenizer configuration allow up to 8,192 tokens. Quality at the configured maximum sequence length remains to be evaluated.
- For retrieval, validate pooling and ranking quality on your own data. The mean pooling example demonstrates feature extraction.
- A data audit found three English STS-B validation pairs, with similarity labels, in the post-training corpus. Encodechka contains their Russian translations. The table reports the full 10-task aggregate.
References
- Downloads last month
- 42