File size: 5,575 Bytes
8df0476
 
28006d3
 
 
0349fc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
license: apache-2.0
language:
- en
- ru
library_name: transformers
pipeline_tag: feature-extraction
tags:
- modernbert
- encoder
base_model: jhu-clsp/mmBERT-base
base_model_relation: finetune
---

# RuModernBertBase

**RuModernBertBase** is a Russian–English ModernBERT encoder from MTS AI. It was adapted from multilingual mmBERT-base with a new tokenizer and continued masked language modeling.

## 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 | 149,014,272 |
| Transformer layers | 22 |
| Hidden size | 768 |
| Intermediate size | 1,152 |
| Attention heads | 12 |
| 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.

```python
import torch
from transformers import AutoModel, AutoTokenizer

model_id = "MTSAIR/RuModernBertBase"
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 initialized Base from [jhu-clsp/mmBERT-base](https://huggingface.co/jhu-clsp/mmBERT-base) and replaced its vocabulary with a 50,368-token BPE vocabulary. We copied embeddings for matching tokens, summed the embeddings of the original subwords for new tokens, and mapped special tokens by role. The Transformer layers and normalization weights were carried over.

We continued MLM pretraining for approximately 88B tokens on Russian and English web text and code. The first stage processed roughly 76B tokens with a peak learning rate of `5e-4`. The second processed roughly 12B tokens with stricter text filtering and a learning rate of `1e-4`. Both stages used 15% masking and sequences of up to 1,024 tokens. The final-stage document mix was 73.2% Russian FineWeb-2, 24.4% English FineWeb, and 2.4% GitHub Code Clean.

## Evaluation

| MTS AI checkpoint | RussianSuperGLUE accuracy | Encodechka score |
| --- | ---: | ---: |
| [RuModernBertSmall](https://huggingface.co/MTSAIR/RuModernBertSmall) | 66.61% | 60.8 |
| [RuModernBertSmallTripleMerge](https://huggingface.co/MTSAIR/RuModernBertSmallTripleMerge) | 67.07% | 60.4 |
| **RuModernBertBase** | 71.29% | 64.2 |
| [RuModernBertBaseTripleMerge](https://huggingface.co/MTSAIR/RuModernBertBaseTripleMerge) | 72.40% | 65.7 |

The Base Triple-Merge variant improved mean RussianSuperGLUE accuracy by 1.11 percentage points and mean Encodechka score by 1.5 points in this evaluation.

### RussianSuperGLUE

We fine-tuned the encoder and a task-specific head on each of seven [RussianSuperGLUE](https://russiansuperglue.com/tasks/) 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 | 52.32 ± 1.61 |
| PARus | 58.50 ± 1.84 |
| MuSeRC | 87.49 ± 0.72 |
| TERRa | 76.87 ± 1.21 |
| RUSSE | 96.66 ± 0.13 |
| RWSD | 57.21 ± 2.04 |
| DaNetQA | 70.00 ± 2.62 |
| Mean | 71.29% |

### Encodechka

For [Encodechka](https://github.com/avidale/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.9 |
| Paraphraser | 56.7 |
| XNLI | 34.7 |
| Sentiment | 76.1 |
| Toxicity | 96.6 |
| Inappropr. | 76.9 |
| Intents | 77.7 |
| IntentsX | 61.2 |
| FactRu | 46.3 |
| RuDReC | 46.9 |
| Mean | 64.2 |

## Limitations

- We report evaluation results on Russian benchmarks. Training also included English data.
- The MTS AI adaptation stages used sequences of up to 1,024 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. Excluding STS-B, the Base variant's Triple-Merge gain remained 1.5 points across the other nine tasks.

## References

- [ModernBERT paper](https://arxiv.org/abs/2412.13663)
- [mmBERT paper](https://arxiv.org/abs/2509.06888)