BioMike commited on
Commit
a3e581d
·
verified ·
1 Parent(s): 69fe0c8

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +222 -0
README.md ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - multilingual
5
+ - en
6
+ - ru
7
+ - zh
8
+ - es
9
+ - de
10
+ - fr
11
+ - ja
12
+ - it
13
+ - pt
14
+ - pl
15
+ - nl
16
+ - vi
17
+ - id
18
+ - ar
19
+ - cs
20
+ - tr
21
+ - hu
22
+ - sv
23
+ - ro
24
+ - uk
25
+ - ko
26
+ - el
27
+ - "no"
28
+ - da
29
+ - fi
30
+ - sk
31
+ - bg
32
+ - hi
33
+ - hr
34
+ - bs
35
+ - lt
36
+ - sl
37
+ - he
38
+ - bn
39
+ - sr
40
+ - lv
41
+ - et
42
+ - ms
43
+ - ur
44
+ - mk
45
+ - la
46
+ - be
47
+ - mt
48
+ - sw
49
+ - ga
50
+ - yi
51
+ library_name: transformers
52
+ pipeline_tag: feature-extraction
53
+ tags:
54
+ - deberta-v2
55
+ - electra
56
+ - replaced-token-detection
57
+ - encoder
58
+ - multilingual
59
+ - long-context
60
+ - flashdeberta
61
+ ---
62
+
63
+ ![banner-readme-light](https://cdn-uploads.huggingface.co/production/uploads/6405f62ba577649430be5124/YGt0hwZ_zTB5FaD4EOOwQ.png)
64
+
65
+ # EdgeCoder-Multilingual-61M
66
+
67
+ EdgeCoder-Multilingual-61M is a compact multilingual text encoder (61M parameters, 16 layers) for 46 languages, with a context of up to 8192 tokens. It is pre-trained with **ModernELECTRA**: replaced-token detection (RTD), as in ELECTRA and DeBERTaV3, plus a boundary-window reconstruction task.
68
+
69
+ RTD encoders are strong on classification but usually weak as backbones for embedding models. EdgeCoder-Multilingual-61M keeps the classification quality of RTD and can also be fine-tuned into an embedding model. It is about half the size of other small multilingual encoders (118M to 141M parameters).
70
+
71
+ - **Developed by:** [Knowledgator Engineering](https://knowledgator.com)
72
+ - **English version:** [EdgeCoder-31M](https://huggingface.co/knowledgator/EdgeCoder-31M)
73
+ - **Training and inference kernels:** [FlashDeBERTa](https://github.com/Knowledgator/FlashDeBERTa)
74
+ - **Paper:** *ModernELECTRA: Replaced-Token Detection with Boundary-Window Reconstruction for Compact Encoders that Classify and Embed* <!-- TODO: add link -->
75
+
76
+ ## Model details
77
+
78
+ | | |
79
+ |---|---|
80
+ | Architecture | DeBERTa-v2 (disentangled relative attention, no absolute positions) |
81
+ | Layers / hidden / FFN / heads | 16 / 384 / 1536 / 6 |
82
+ | Token embedding | factorized: 128-d table with a linear projection to 384 |
83
+ | Parameters | 61.0M (28.4M without the embedding table) |
84
+ | Maximum sequence length | 8192 tokens |
85
+ | Tokenizer | mDeBERTa-v3 SentencePiece (251,000 tokens) |
86
+ | Languages | 46 |
87
+
88
+ The repository contains the discriminator encoder. It has no masked-language-model head, so it is meant for fine-tuning and feature extraction, not for fill-mask.
89
+
90
+ ### Languages
91
+
92
+ Arabic, Belarusian, Bengali, Bosnian, Bulgarian, Chinese (Mandarin), Croatian, Czech, Danish, Dutch, English, Estonian, Finnish, French, German, Greek, Hebrew, Hindi, Hungarian, Indonesian, Irish, Italian, Japanese, Korean, Latin, Latvian, Lithuanian, Macedonian, Malay, Maltese, Norwegian Bokmål, Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovenian, Spanish, Swahili, Swedish, Turkish, Ukrainian, Urdu, Vietnamese, Yiddish.
93
+
94
+ English is the largest single language (about 47% of the pre-training tokens). The other languages are sampled with shares proportional to the square root of their available data.
95
+
96
+ ## Usage
97
+
98
+ The checkpoint is a standard DeBERTa-v2 model and loads with `transformers`:
99
+
100
+ ```python
101
+ from transformers import AutoTokenizer, AutoModel
102
+
103
+ tokenizer = AutoTokenizer.from_pretrained("knowledgator/EdgeCoder-Multilingual-61M")
104
+ model = AutoModel.from_pretrained("knowledgator/EdgeCoder-Multilingual-61M")
105
+
106
+ inputs = tokenizer("EdgeCoder — компактний багатомовний енкодер.", return_tensors="pt")
107
+ outputs = model(**inputs)
108
+ hidden = outputs.last_hidden_state # (batch, seq_len, 384)
109
+ ```
110
+
111
+ For fine-tuning, use the usual task heads, for example `AutoModelForSequenceClassification` or `AutoModelForTokenClassification`.
112
+
113
+ ### Long inputs and faster inference with FlashDeBERTa
114
+
115
+ The standard DeBERTa attention needs memory that grows quadratically with the sequence length. For long inputs, we recommend [FlashDeBERTa](https://github.com/Knowledgator/FlashDeBERTa), the implementation the model was trained with. It loads the same checkpoint:
116
+
117
+ ```bash
118
+ pip install flashdeberta -U
119
+ ```
120
+
121
+ ```python
122
+ import torch
123
+ from transformers import AutoTokenizer
124
+ from flashdeberta import FlashDebertaV2Model
125
+
126
+ tokenizer = AutoTokenizer.from_pretrained("knowledgator/EdgeCoder-Multilingual-61M")
127
+ model = FlashDebertaV2Model.from_pretrained("knowledgator/EdgeCoder-Multilingual-61M").to("cuda")
128
+
129
+ inputs = tokenizer(long_text, truncation=True, max_length=8192, return_tensors="pt").to("cuda")
130
+ with torch.no_grad():
131
+ outputs = model(**inputs)
132
+ ```
133
+
134
+ FlashDeBERTa also provides heads for sequence and token classification, question answering and multiple choice.
135
+
136
+ ## Evaluation
137
+
138
+ All numbers are from the paper. Baselines were run with the same protocols.
139
+
140
+ ### GLUE (dev, English)
141
+
142
+ Single seed, best run of a hyperparameter sweep that follows the Ettin protocol.
143
+
144
+ | Model | Params | CoLA | SST-2 | MRPC | STS-B | QQP | MNLI | QNLI | RTE | Avg |
145
+ |---|---|---|---|---|---|---|---|---|---|---|
146
+ | mDistilBERT | 134.7M | 34.7 | 89.4 | 90.5 | 87.5 | 86.6 | 79.0 | 87.5 | 73.3 | 77.5 |
147
+ | Multilingual MiniLM | 117.7M | 25.4 | 91.6 | 91.3 | 88.6 | 87.7 | 82.1 | 89.7 | 75.8 | 78.3 |
148
+ | mmBERT-small | 140.5M | 61.8 | 93.1 | 91.6 | 90.3 | 88.6 | 85.8 | 91.9 | 81.9 | 84.7 |
149
+ | **EdgeCoder-Multilingual-61M** | 61.0M | 58.3 | 91.4 | 92.1 | 90.2 | 91.5 | 84.8 | 91.2 | 81.6 | 85.1 |
150
+
151
+ ### XTREME (zero-shot cross-lingual transfer)
152
+
153
+ Models are fine-tuned on English and evaluated on the other languages. The learning rate and the checkpoint are selected on the English dev set only. Single seed.
154
+
155
+ On the 26 XTREME languages that the model was pre-trained on:
156
+
157
+ | Model | Params | XNLI | PAWS-X | XCOPA | XQuAD | MLQA | TyDiQA | WikiANN | UDPOS | Avg |
158
+ |---|---|---|---|---|---|---|---|---|---|---|
159
+ | mDistilBERT | 134.7M | 60.8 | 79.6 | 53.5 | 50.1 | 45.5 | 40.3 | 59.7 | 72.5 | 57.7 |
160
+ | Multilingual MiniLM | 117.7M | 71.1 | 83.2 | 58.8 | 67.2 | 61.1 | 58.5 | 58.9 | 79.4 | 67.3 |
161
+ | mmBERT-small | 140.5M | 73.8 | 85.4 | 62.8 | 73.0 | 66.2 | 66.8 | 59.4 | 72.4 | 70.0 |
162
+ | **EdgeCoder-Multilingual-61M** | 61.0M | 71.5 | 83.5 | 59.1 | 69.4 | 62.0 | 62.0 | 57.4 | 77.9 | 67.8 |
163
+
164
+ On all XTREME languages, including 16 that the model has never seen:
165
+
166
+ | Model | Params | XNLI | PAWS-X | XCOPA | XQuAD | MLQA | TyDiQA | WikiANN | UDPOS | Avg |
167
+ |---|---|---|---|---|---|---|---|---|---|---|
168
+ | mDistilBERT | 134.7M | 59.3 | 79.6 | 52.7 | 47.4 | 45.5 | 39.3 | 53.9 | 68.8 | 55.8 |
169
+ | Multilingual MiniLM | 117.7M | 70.9 | 83.2 | 58.3 | 66.3 | 61.1 | 58.3 | 55.2 | 77.8 | 66.4 |
170
+ | mmBERT-small | 140.5M | 73.6 | 85.4 | 60.3 | 71.6 | 66.2 | 66.3 | 52.0 | 69.5 | 68.1 |
171
+ | **EdgeCoder-Multilingual-61M** | 61.0M | 69.0 | 83.5 | 55.6 | 64.7 | 62.0 | 57.3 | 45.5 | 64.3 | 62.7 |
172
+
173
+ ### MTEB
174
+
175
+ Each backbone is fine-tuned once into a sentence embedding model on 1M English MS MARCO triplets (one epoch, mean pooling, contrastive loss) and then evaluated. The scores describe the backbone after this fine-tuning, not the checkpoint in this repository used as is.
176
+
177
+ MTEB English v2 (41 tasks):
178
+
179
+ | Model | Params | Class. | Clust. | PairCl. | Rerank. | Retr. | STS | Summ. | Mean (Type) |
180
+ |---|---|---|---|---|---|---|---|---|---|
181
+ | Multilingual MiniLM | 117.7M | 59.3 | 36.9 | 77.3 | 42.4 | 35.0 | 71.9 | 19.3 | 48.9 |
182
+ | mDistilBERT | 134.7M | 59.0 | 38.3 | 75.9 | 42.7 | 38.4 | 72.4 | 19.4 | 49.4 |
183
+ | mmBERT-small | 140.5M | 62.1 | 40.8 | 78.9 | 44.1 | 40.7 | 74.1 | 23.6 | 52.1 |
184
+ | **EdgeCoder-Multilingual-61M** | 61.0M | 63.8 | 38.6 | 76.8 | 43.0 | 37.9 | 72.1 | 20.6 | 50.4 |
185
+
186
+ MTEB Multilingual (131 tasks):
187
+
188
+ | Model | Params | Bitext | PairCl. | Class. | STS | Retr. | MultiLab. | Clust. | Rerank. | Avg |
189
+ |---|---|---|---|---|---|---|---|---|---|---|
190
+ | mDistilBERT | 134.7M | 37.2 | 76.6 | 50.3 | 62.1 | 36.7 | 14.6 | 37.5 | 62.2 | 47.1 |
191
+ | Multilingual MiniLM | 117.7M | 46.6 | 76.7 | 51.0 | 64.6 | 35.6 | 14.0 | 34.9 | 64.1 | 48.4 |
192
+ | mmBERT-small | 140.5M | 50.5 | 77.4 | 50.4 | 64.8 | 41.9 | 15.5 | 38.7 | 66.1 | 50.7 |
193
+ | **EdgeCoder-Multilingual-61M** | 61.0M | 25.0 | 71.9 | 48.3 | 58.5 | 41.3 | 15.3 | 35.4 | 54.5 | 43.8 |
194
+
195
+ On MTEB Multilingual the model is competitive on retrieval and multilabel classification but behind the baselines on average. The gap comes mostly from bitext mining and reranking. Both categories include many languages outside the 46 the model covers, and bitext mining also depends on cross-lingual alignment that the English-only MS MARCO fine-tuning does not provide.
196
+
197
+ ## Training
198
+
199
+ - **Objective.** Replaced-token detection on every position, plus boundary-window reconstruction: each token is predicted from the two hidden states at the borders of a random window (3 to 12 tokens) that contains it. The window loss has weight 0.003.
200
+ - **Generator.** A separate 8-layer generator is pre-trained with masked language modelling and then frozen. Replacements are sampled from it at a temperature that decreases from 1.5 to 0.93 during training. The masking rate is 30%.
201
+ - **Data.** About 1.1 trillion tokens in 46 languages: web pages and PDF documents in all languages, plus English news, scientific papers, books, legal text, source code, mathematics and Q&A forums.
202
+ - **Length curriculum.** 512 tokens for most of training, then a mix dominated by long documents of up to 8192 tokens.
203
+ - **Hardware.** One node with 8 × NVIDIA H100 GPUs, bf16 mixed precision.
204
+
205
+ ## Limitations
206
+
207
+ - The model supports 46 languages. Languages outside this set are not supported, in particular scripts that are absent from pre-training (for example Thai, Tamil, Telugu, Malayalam, Burmese, Georgian). On token-level tasks in such languages it is far behind models pre-trained on 100 or more languages.
208
+ - The model is a backbone. It needs fine-tuning for classification, token classification, retrieval or embedding tasks.
209
+ - After English-only embedding fine-tuning, it is weak on bitext mining and multilingual reranking (see the MTEB Multilingual table).
210
+ - Results are single runs with one seed, so differences below about one point should not be over-interpreted.
211
+ - The paper does not include an ablation that isolates the effect of the window objective.
212
+
213
+ ## Citation
214
+
215
+ ```bibtex
216
+ @techreport{shtopko2026modernelectra,
217
+ title = {{ModernELECTRA}: Replaced-Token Detection with Boundary-Window Reconstruction for Compact Encoders that Classify and Embed},
218
+ author = {Shtopko, Mykhailo and Stepanov, Ihor and Vodianytskyi, Dmytro and Lukashov, Oleksandr},
219
+ institution = {Knowledgator Engineering},
220
+ year = {2026}
221
+ }
222
+ ```