image

Fine-tuned xlm-roberta-base for sentence-level language tagging across 100 languages. The model predicts BIO-style language tags over tokens, which makes it useful for language identification, code-switch detection, and multilingual document analysis.

Model description

Introducing Polyglot Tagger, 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.

Note that Romanized versions of any language may only have minor representation in the training set, such as Romanized Russian, and Hindi.

Training and Evaluation Data

A synthetic training row consists of 1-4 individual and mostly independent sentences extracted from various sources. The actual training and evaluation data, as well as coverage is found in DerivedFunction/lang-ner-v2.

This model is a fine-tuned version of xlm-roberta-base on an unknown dataset. It achieves the following results on the evaluation set:

  • Loss: 0.0320
  • Precision: 0.9504
  • Recall: 0.9654
  • F1: 0.9579
  • Accuracy: 0.9918

Training procedure

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 5e-05
  • train_batch_size: 8
  • eval_batch_size: 8
  • seed: 42
  • gradient_accumulation_steps: 18
  • 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.7227 0.0804 2500 0.1120 0.7901 0.8797 0.8325 0.9723
0.5850 0.1609 5000 0.0982 0.8418 0.9035 0.8716 0.9777
0.5535 0.2413 7500 0.0808 0.8588 0.9160 0.8865 0.9808
0.4680 0.3218 10000 0.0714 0.8758 0.9240 0.8992 0.9818
0.4853 0.4022 12500 0.0619 0.8905 0.9327 0.9111 0.9839
0.4519 0.4827 15000 0.0559 0.8954 0.9359 0.9152 0.9849
0.4386 0.5631 17500 0.0530 0.8987 0.9385 0.9181 0.9858
0.3982 0.6436 20000 0.0521 0.9043 0.9419 0.9227 0.9866
0.3936 0.7240 22500 0.0496 0.9102 0.9447 0.9271 0.9862
0.3740 0.8045 25000 0.0461 0.9214 0.9482 0.9346 0.9882
0.3405 0.8849 27500 0.0462 0.9232 0.9504 0.9366 0.9878
0.3473 0.9654 30000 0.0421 0.9225 0.9525 0.9373 0.9888
0.2723 1.0458 32500 0.0448 0.9272 0.9538 0.9403 0.9888
0.2616 1.1262 35000 0.0397 0.9342 0.9566 0.9453 0.9896
0.2794 1.2067 37500 0.0414 0.9329 0.9570 0.9448 0.9896
0.2431 1.2871 40000 0.0379 0.9423 0.9602 0.9512 0.9903
0.2577 1.3676 42500 0.0373 0.9371 0.9594 0.9482 0.9902
0.2628 1.4480 45000 0.0362 0.9369 0.9607 0.9486 0.9903
0.2684 1.5285 47500 0.0355 0.9430 0.9613 0.9520 0.9907
0.2592 1.6089 50000 0.0362 0.9467 0.9623 0.9544 0.9908
0.2150 1.6894 52500 0.0340 0.9441 0.9632 0.9535 0.9912
0.2187 1.7698 55000 0.0336 0.9487 0.9639 0.9563 0.9914
0.2074 1.8503 57500 0.0332 0.9482 0.9642 0.9562 0.9916
0.2390 1.9307 60000 0.0320 0.9504 0.9654 0.9579 0.9918

Framework versions

  • Transformers 5.0.0
  • Pytorch 2.10.0+cu128
  • Datasets 4.0.0
  • Tokenizers 0.22.2
Downloads last month
273
Safetensors
Model size
0.3B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for DerivedFunction/polyglot-tagger-v2.1

Finetuned
(3866)
this model

Datasets used to train DerivedFunction/polyglot-tagger-v2.1

Spaces using DerivedFunction/polyglot-tagger-v2.1 2

Collection including DerivedFunction/polyglot-tagger-v2.1