File size: 6,427 Bytes
6429374 625667b 6429374 625667b 6429374 625667b 99a0b1d 625667b efce9dd 625667b 6429374 625667b 6429374 625667b 6429374 625667b 6429374 efce9dd 625667b 6429374 625667b 6429374 625667b 6429374 625667b 6429374 625667b 6429374 99a0b1d | 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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | ---
library_name: transformers
license: mit
base_model: xlm-roberta-base
tags:
- language-detection
- language-identification
metrics:
- precision
- recall
- f1
- accuracy
model-index:
- name: polyglot-tagger
results: []
datasets:
- wikimedia/wikipedia
- HuggingFaceFW/finetranslations
- google/smol
- DerivedFunction/nlp-noise-snippets
- DerivedFunction/wikipedia-language-snippets-filtered
- DerivedFunction/finetranslations-filtered
- DerivedFunction/additional-language-snippets
pipeline_tag: token-classification
language:
- en
- es
- fr
- de
- it
- pt
- nl
- vi
- tr
- la
- id
- ms
- af
- sq
- is
- no
- sv
- da
- fi
- hu
- pl
- cs
- ro
- ru
- bg
- uk
- sr
- be
- kk
- mk
- mn
- zh
- ja
- ko
- hi
- ur
- bn
- ta
- te
- mr
- gu
- kn
- ml
- pa
- as
- or
- ar
- fa
- ps
- sd
- ug
- el
- he
- hy
- ka
- am
- km
- lo
- my
- th
- si
- bo
- dv
- ti
- sw
- eu
---
# Polyglot Tagger: 67L (Experimental)
This model is a fine-tuned version of [xlm-roberta-base](https://huggingface.co/xlm-roberta-base).
It achieves the following results on the evaluation set:
- Loss: 0.0404
- Precision: 0.8848
- Recall: 0.9012
- F1: 0.8929
- Accuracy: 0.9909
## Model description
Introducing Polyglot Tagger 66L, a new way to classify multi-lingual documents. By training specifically on token classification on individual sentences, the model
generalizes well on a variety of languages, while also behaves as a multi-label classifier, and extracts sentences based on its language.
## Intended uses & limitations
This model can be treated as a base model for further fine-tuning on specific language identification extraction tasks.
Note that as a general language tagging model, it can potentially get confused from shared language families or from short texts. For example, English and German, Spanish and Portuguese, and Russian and Ukrainian.
The model is trained on a sentence with a minimum of four tokens, so it may not accurately classify very short and ambigous statements. Note that this model is experimental
and may produce unexpected results compared to generic text classifiers. It is trained on cleaned text, therefore, "messy" text may unexpectedly produce different results.
### Training and Evaluation Data
The model was trained on a synthetic dataset of roughly **3 million samples**, covering 67 languages across diverse script families
(Latin, Cyrillic, Indic, Arabic, Han, etc.), from `wikimedia/wikipedia` (up to 200,000 individual sentences, 120,000 reserve from up to 100,000 unique articles,
by taking the first half of Wikipedia after filtering for stubs), `google/smol` (up to 1000 individual sentences), `HuggingFaceFW/finetranslations` (up to 50,000 sentences, 30,000 reserve from up to 50,000 unique rows),
and additional sentences from various sources for major languages (`en`, `es`, `pt`, `ru`, `hi`, `de`, `fr`, etc) (up to 50,000 sentences, 30,000 reserve from up to 100,000 unique rows).
in which it is split into a reserve set for pure documents, and a main set for everything else.
A synthetic training row consists of 1-4 individual and mostly independent sentences extracted from various sources.
The data composition follows a strategic curriculum:
* **60% Pure Documents:** Single-language sequences to establish strong baseline profiles for each language.
* **30% Homogenous Mixed:** Documents containing one main language, and clear transitions between two or more languages to train boundary detection.
* **10% Mixed with Noise:** Integration of "neutral" spans including code snippets, mathematical notation, emojis, symbols, and `rot_13` text tagged as `O` or their respective source to reduce hallucination.
### Supported Languages and Limitations (66)
The model supports the following ISO-coded languages:
`af, am, ar, as, be, bg, bn, bo, cs, da, de, dv, el, en, es, eu, fa, fi, fr, gu, he, hi,
hu, hy, id, is, it, ja, ka, kk, km, kn, ko, la, lo, ml, mk, mn, mr, ms, my, nl, no,
or, pa, pl, ps, pt, ro, ru, sd, si, sq, sr, sv, sw, ta, te, th, ti, tr, ug, uk, ur, vi, zh`
> Note that Romanized versions of any language is not included in the training set, such as Romanized Russian, and Hindi.
### Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 72
- eval_batch_size: 36
- seed: 42
- gradient_accumulation_steps: 2
- total_train_batch_size: 144
- optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
- lr_scheduler_type: linear
- num_epochs: 2
- mixed_precision_training: Native AMP
### Training results
| Training Loss | Epoch | Step | Validation Loss | Precision | Recall | F1 | Accuracy |
|:-------------:|:------:|:-----:|:---------------:|:---------:|:------:|:------:|:--------:|
| 0.0404 | 0.1206 | 2500 | 0.0649 | 0.7944 | 0.8616 | 0.8266 | 0.9868 |
| 0.0394 | 0.2412 | 5000 | 0.0538 | 0.8181 | 0.8696 | 0.8430 | 0.9893 |
| 0.0345 | 0.3618 | 7500 | 0.0456 | 0.8355 | 0.8781 | 0.8563 | 0.9906 |
| 0.0280 | 0.4824 | 10000 | 0.0493 | 0.8404 | 0.8836 | 0.8614 | 0.9897 |
| 0.0286 | 0.6030 | 12500 | 0.0515 | 0.8425 | 0.8805 | 0.8611 | 0.9889 |
| 0.0275 | 0.7236 | 15000 | 0.0423 | 0.8371 | 0.8852 | 0.8605 | 0.9905 |
| 0.0209 | 0.8442 | 17500 | 0.0429 | 0.8671 | 0.8908 | 0.8788 | 0.9911 |
| 0.0265 | 0.9648 | 20000 | 0.0379 | 0.8550 | 0.8881 | 0.8712 | 0.9919 |
| 0.0223 | 1.0854 | 22500 | 0.0371 | 0.8665 | 0.8967 | 0.8814 | 0.9918 |
| 0.0220 | 1.2060 | 25000 | 0.0344 | 0.8687 | 0.8954 | 0.8818 | 0.9926 |
| 0.0225 | 1.3266 | 27500 | 0.0332 | 0.8776 | 0.9011 | 0.8892 | 0.9928 |
| 0.0186 | 1.4472 | 30000 | 0.0390 | 0.8711 | 0.9018 | 0.8862 | 0.9920 |
| 0.0200 | 1.5678 | 32500 | 0.0315 | 0.8840 | 0.9046 | 0.8942 | 0.9931 |
| 0.0170 | 1.6884 | 35000 | 0.0313 | 0.8867 | 0.9066 | 0.8965 | 0.9932 |
| 0.0170 | 1.8090 | 37500 | 0.0305 | 0.8804 | 0.9034 | 0.8918 | 0.9933 |
| 0.0176 | 1.9296 | 40000 | 0.0305 | 0.8866 | 0.9058 | 0.8961 | 0.9935 |
### Framework versions
- Transformers 5.0.0
- Pytorch 2.10.0+cu128
- Datasets 4.0.0
- Tokenizers 0.22.2 |