papluca_xlm-roberta-base-language-detection
papluca · View on Hugging Face ↗
Model card
The complete upstream card, rendered from this payload's README.md — the same hash-verified bytes the torrent distributes. Images and off-site links are removed; the original card on Hugging Face carries them.
language:
- multilingual
- ar
- bg
- de
- el
- en
- es
- fr
- hi
- it
- ja
- nl
- pl
- pt
- ru
- sw
- th
- tr
- ur
- vi
- zh license: mit tags:
- generated_from_trainer datasets: papluca/language-identification metrics:
- accuracy
- f1 base_model: xlm-roberta-base model-index:
- name: xlm-roberta-base-language-detection results: []
xlm-roberta-base-language-detection
This model is a fine-tuned version of xlm-roberta-base on the Language Identification dataset.
Model description
This model is an XLM-RoBERTa transformer model with a classification head on top (i.e. a linear layer on top of the pooled output). For additional information please refer to the xlm-roberta-base model card or to the paper Unsupervised Cross-lingual Representation Learning at Scale by Conneau et al.
Intended uses & limitations
You can directly use this model as a language detector, i.e. for sequence classification tasks. Currently, it supports the following 20 languages:
arabic (ar), bulgarian (bg), german (de), modern greek (el), english (en), spanish (es), french (fr), hindi (hi), italian (it), japanese (ja), dutch (nl), polish (pl), portuguese (pt), russian (ru), swahili (sw), thai (th), turkish (tr), urdu (ur), vietnamese (vi), and chinese (zh)
Training and evaluation data
The model was fine-tuned on the Language Identification dataset, which consists of text sequences in 20 languages. The training set contains 70k samples, while the validation and test sets 10k each. The average accuracy on the test set is 99.6% (this matches the average macro/weighted F1-score being the test set perfectly balanced). A more detailed evaluation is provided by the following table.
| Language | Precision | Recall | F1-score | support |
|---|---|---|---|---|
| ar | 0.998 | 0.996 | 0.997 | 500 |
| bg | 0.998 | 0.964 | 0.981 | 500 |
| de | 0.998 | 0.996 | 0.997 | 500 |
| el | 0.996 | 1.000 | 0.998 | 500 |
| en | 1.000 | 1.000 | 1.000 | 500 |
| es | 0.967 | 1.000 | 0.983 | 500 |
| fr | 1.000 | 1.000 | 1.000 | 500 |
| hi | 0.994 | 0.992 | 0.993 | 500 |
| it | 1.000 | 0.992 | 0.996 | 500 |
| ja | 0.996 | 0.996 | 0.996 | 500 |
| nl | 1.000 | 1.000 | 1.000 | 500 |
| pl | 1.000 | 1.000 | 1.000 | 500 |
| pt | 0.988 | 1.000 | 0.994 | 500 |
| ru | 1.000 | 0.994 | 0.997 | 500 |
| sw | 1.000 | 1.000 | 1.000 | 500 |
| th | 1.000 | 0.998 | 0.999 | 500 |
| tr | 0.994 | 0.992 | 0.993 | 500 |
| ur | 1.000 | 1.000 | 1.000 | 500 |
| vi | 0.992 | 1.000 | 0.996 | 500 |
| zh | 1.000 | 1.000 | 1.000 | 500 |
Benchmarks
As a baseline to compare xlm-roberta-base-language-detection against, we have used the Python langid library. Since it comes pre-trained on 97 languages, we have used its .set_languages() method to constrain the language set to our 20 languages. The average accuracy of langid on the test set is 98.5%. More details are provided by the table below.
| Language | Precision | Recall | F1-score | support |
|---|---|---|---|---|
| ar | 0.990 | 0.970 | 0.980 | 500 |
| bg | 0.998 | 0.964 | 0.981 | 500 |
| de | 0.992 | 0.944 | 0.967 | 500 |
| el | 1.000 | 0.998 | 0.999 | 500 |
| en | 1.000 | 1.000 | 1.000 | 500 |
| es | 1.000 | 0.968 | 0.984 | 500 |
| fr | 0.996 | 1.000 | 0.998 | 500 |
| hi | 0.949 | 0.976 | 0.963 | 500 |
| it | 0.990 | 0.980 | 0.985 | 500 |
| ja | 0.927 | 0.988 | 0.956 | 500 |
| nl | 0.980 | 1.000 | 0.990 | 500 |
| pl | 0.986 | 0.996 | 0.991 | 500 |
| pt | 0.950 | 0.996 | 0.973 | 500 |
| ru | 0.996 | 0.974 | 0.985 | 500 |
| sw | 1.000 | 1.000 | 1.000 | 500 |
| th | 1.000 | 0.996 | 0.998 | 500 |
| tr | 0.990 | 0.968 | 0.979 | 500 |
| ur | 0.998 | 0.996 | 0.997 | 500 |
| vi | 0.971 | 0.990 | 0.980 | 500 |
| zh | 1.000 | 1.000 | 1.000 | 500 |
How to get started with the model
The easiest way to use the model is via the high-level pipeline API:
from transformers import pipeline
text = [
"Brevity is the soul of wit.",
"Amor, ch'a nullo amato amar perdona."
]
model_ckpt = "papluca/xlm-roberta-base-language-detection"
pipe = pipeline("text-classification", model=model_ckpt)
pipe(text, top_k=1, truncation=True)
Or one can proceed with the tokenizer and model separately:
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
text = [
"Brevity is the soul of wit.",
"Amor, ch'a nullo amato amar perdona."
]
model_ckpt = "papluca/xlm-roberta-base-language-detection"
tokenizer = AutoTokenizer.from_pretrained(model_ckpt)
model = AutoModelForSequenceClassification.from_pretrained(model_ckpt)
inputs = tokenizer(text, padding=True, truncation=True, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
preds = torch.softmax(logits, dim=-1)
# Map raw predictions to languages
id2lang = model.config.id2label
vals, idxs = torch.max(preds, dim=1)
{id2lang[k.item()]: v.item() for k, v in zip(idxs, vals)}
Training procedure
Fine-tuning was done via the Trainer API. Here is the Colab notebook with the training code.
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 2e-05
- train_batch_size: 64
- eval_batch_size: 128
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 2
- mixed_precision_training: Native AMP
Training results
The validation results on the valid split of the Language Identification dataset are summarised here below.
| Training Loss | Epoch | Step | Validation Loss | Accuracy | F1 |
|---|---|---|---|---|---|
| 0.2492 | 1.0 | 1094 | 0.0149 | 0.9969 | 0.9969 |
| 0.0101 | 2.0 | 2188 | 0.0103 | 0.9977 | 0.9977 |
In short, it achieves the following results on the validation set:
- Loss: 0.0101
- Accuracy: 0.9977
- F1: 0.9977
Framework versions
- Transformers 4.12.5
- Pytorch 1.10.0+cu111
- Datasets 1.15.1
- Tokenizers 0.10.3
Magnet link
Opens the swarm directly in your torrent client — no file download needed. Copy-paste works too:
magnet:?xt=urn:btih:c009a73e289164d755fe3200bb37cf6a0d0c3423&dn=papluca_xlm-roberta-base-language-detectionOpen magnet in torrent client · infohash c009a73e289164d755fe3200bb37cf6a0d0c3423
Files & hashes
| Path | Size | sha1 | sha256 |
|---|---|---|---|
| README.md | 7.0 KB (7,184 B) | 7b9a1e22306ac3ab7ce19e3886752ee379833b01 | 312753546a1e6fe30c9adb3ba51feed9163d00dca06f4d2042cc438f6dbf9cea |
| config.json | 1.4 KB (1,417 B) | c99fbb09b11673f64aa2f6f1541eddae009e9383 | c853c935230721240f2fc06acb72fb086cecea3cec99b62d843ac4678b7daba9 |
| model.safetensors | 1.04 GB (1,112,264,584 B) | 802c60bbfbe5cfe11d945fabd51c135b16ba635a | a835d6e8ed50ef6b3c180db87446a83ee5ac437e981c932c8e1e239aacbe08b7 |
| pytorch_model.bin | 1.04 GB (1,112,318,701 B) | 85941dbcc146447b970705031c325d80e1533d01 | eb6bded160fdd712245e1bd19c4de417e1508094a9f69d92ae287f32a8732888 |
| sentencepiece.bpe.model | 4.8 MB (5,069,051 B) | 7e88c49faff6c6c136fdf4a3402d0cb534c6ab10 | cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865 |
| special_tokens_map.json | 239 B (239 B) | 2ea7ad0e45a9d1d1591782ba7e29a703d0758831 | 378eb3bf733eb16e65792d7e3fda5b8a4631387ca04d2015199c4d4f22ae554d |
| tokenizer.json | 8.7 MB (9,081,351 B) | 73d26c2db619660133c51e34733c7c476bba195e | 2a0d7366dd7780ea36cc42431dd74cd79289b783ab01acd33013fcc96865a8e9 |
| tokenizer_config.json | 502 B (502 B) | 204f50a86b69d8bb24c3c5e1a19056ef39e5598c | 0606f1a769dcea369f11010642c030cbd0a0a545ac21b11f2f86e9ae975dac3f |
Cite this release
- Canonical URL
- https://aiseedbank.org/models/papluca_xlm-roberta-base-language-detection/
- Slug
- papluca_xlm-roberta-base-language-detection
- Infohash
- c009a73e289164d755fe3200bb37cf6a0d0c3423
- License
- mit
- Signing key fingerprint
- 85a3b32c3712427b
Every file carries a locally computed sha256 — verify a download against the signed sums: papluca_xlm-roberta-base-language-detection.SHA256SUMS (+ minisign signature).
Provenance
| Upstream repository | papluca/xlm-roberta-base-language-detection |
|---|---|
| Revision (pinned) | 9865598389ca9d95637462f743f683b51d75b87b |
| Fetched at | 2026-09-04T05:17:43Z |
| License at fetch | mit |
| Snapshot tool | huggingface · seedbank 0.1.0 |
Trackers
- udp://announce.aitorrent.org:6969/announce
- http://announce.aitorrent.org:7070/announce
- udp://announce2.aitorrent.org:6970/announce
- http://announce2.aitorrent.org:7071/announce
- udp://tracker.opentrackr.org:1337/announce
- udp://open.demonii.com:1337/announce
- udp://open.stealth.si:80/announce
- udp://exodus.desync.com:6969/announce
- udp://tracker.torrent.eu.org:451/announce
✓ verified · rehash-vs-hf-metadata at 2026-09-04T05:18:06Z
mit2.08 GB (2,238,743,029 bytes)transformerspytorchsafetensorsxlm-robertatext-classificationgenerated_from_trainermultilingualtext-embeddings-inferenceendpoints_compatible21 languages (tf, ar, bg …)paper: 1911.02116