Feature Extraction
Transformers
Safetensors
English
Russian
modernbert
encoder
model-merging
text-embeddings-inference
Instructions to use MTSAIR/RuModernBertSmallTripleMerge with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MTSAIR/RuModernBertSmallTripleMerge with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="MTSAIR/RuModernBertSmallTripleMerge")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("MTSAIR/RuModernBertSmallTripleMerge") model = AutoModel.from_pretrained("MTSAIR/RuModernBertSmallTripleMerge", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from MTSAIR/RuModernBertSmallTripleMerge: direct link, hf CLI and curl.
- Browser
- Download file 5.98 kB
-
https://huggingface.co/MTSAIR/RuModernBertSmallTripleMerge/resolve/main/README.md
- Command line
-
hf download hf://MTSAIR/RuModernBertSmallTripleMerge/README.md
-
curl -L -o README.md https://huggingface.co/MTSAIR/RuModernBertSmallTripleMerge/resolve/main/README.md
5.98 kB
| license: apache-2.0 | |
| language: | |
| - en | |
| - ru | |
| library_name: transformers | |
| pipeline_tag: feature-extraction | |
| tags: | |
| - modernbert | |
| - encoder | |
| - model-merging | |
| base_model: MTSAIR/RuModernBertSmall | |
| base_model_relation: finetune | |
| datasets: | |
| - ZeroAgency/ru-big-russian-dataset | |
| # RuModernBertSmallTripleMerge | |
| **RuModernBertSmallTripleMerge** is the post-trained variant of MTS AI's compact Russian–English ModernBERT encoder. It combines three training branches initialized from [RuModernBertSmall](https://huggingface.co/MTSAIR/RuModernBertSmall). | |
| ## 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. | |
| ```python | |
| import torch | |
| from transformers import AutoModel, AutoTokenizer | |
| model_id = "MTSAIR/RuModernBertSmallTripleMerge" | |
| 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 | |
| The branches start from [RuModernBertSmall](https://huggingface.co/MTSAIR/RuModernBertSmall). | |
| We post-trained three branches using dialogues from [ZeroAgency's Russian dataset](https://huggingface.co/datasets/ZeroAgency/ru-big-russian-dataset). | |
| 1. **CLM50** averages two checkpoints equally. The first follows causal language modeling on 90M assistant-response target tokens. The second follows a return to bidirectional attention and roughly 10M tokens of MLM training on natural text. | |
| 2. **Future-CLS** uses the context's `[CLS]` representation to help an auxiliary encoder recover a heavily masked continuation while the main encoder learns with MLM. The auxiliary encoder is discarded after training. | |
| 3. **Span injection** combines MLM with detecting a span replaced by a fragment from another dialogue and locating its boundaries. | |
| Triple-Merge averages the three branches with equal weight. The resulting checkpoint is a single bidirectional encoder with the same architecture and tokenizer as its starting checkpoint. | |
| ## Evaluation | |
| | MTS AI checkpoint | RussianSuperGLUE accuracy | Encodechka score | | |
| | --- | ---: | ---: | | |
| | [RuModernBertSmall](https://huggingface.co/MTSAIR/RuModernBertSmall) | 66.61% | 60.8 | | |
| | **RuModernBertSmallTripleMerge** | 67.07% | 60.4 | | |
| | [RuModernBertBase](https://huggingface.co/MTSAIR/RuModernBertBase) | 71.29% | 64.2 | | |
| | [RuModernBertBaseTripleMerge](https://huggingface.co/MTSAIR/RuModernBertBaseTripleMerge) | 72.40% | 65.7 | | |
| Relative to the original Small checkpoint, Triple-Merge improved mean RussianSuperGLUE accuracy by 0.46 percentage points and reduced the mean Encodechka score by 0.4 points. The original Small checkpoint scored higher on frozen representations. | |
| ### 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.55 ± 2.33 | | |
| | PARus | 55.90 ± 1.52 | | |
| | MuSeRC | 75.56 ± 0.63 | | |
| | TERRa | 64.66 ± 1.12 | | |
| | RUSSE | 94.17 ± 0.58 | | |
| | RWSD | 56.27 ± 0.45 | | |
| | DaNetQA | 70.41 ± 1.80 | | |
| | Mean | 67.07% | | |
| ### 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 | 67.4 | | |
| | Paraphraser | 56.2 | | |
| | XNLI | 35.2 | | |
| | Sentiment | 75.8 | | |
| | Toxicity | 94.0 | | |
| | Inappropr. | 74.7 | | |
| | Intents | 75.1 | | |
| | IntentsX | 45.9 | | |
| | FactRu | 41.0 | | |
| | RuDReC | 38.4 | | |
| | Mean | 60.4 | | |
| ## 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 | |
| - [ModernBERT paper](https://arxiv.org/abs/2412.13663) | |
| - [A Causal Language Modeling Detour Improves Encoder Continued Pretraining](https://arxiv.org/abs/2605.12438) | |