dewdev/language_detection
This is a clone of https://huggingface.co/alexneakameni/language_detection with onnx format
Language Detection Model
A BERT-based language detection model trained on hac541309/open-lid-dataset, which includes 121 million sentences across 200 languages. This model is optimized for fast and accurate language identification in text classification tasks.
Model Details
- Architecture: BertForSequenceClassification
- Hidden Size: 384
- Number of Layers: 4
- Attention Heads: 6
- Max Sequence Length: 512
- Dropout: 0.1
- Vocabulary Size: 50,257
Training Process
- Dataset:
- Used the open-lid-dataset
- Split into train (90%) and test (10%)
- Tokenizer: A custom
BertTokenizerFastwith special tokens for[UNK],[CLS],[SEP],[PAD],[MASK] - Hyperparameters:
- Learning Rate: 2e-5
- Batch Size: 256 (training) / 512 (testing)
- Epochs: 1
- Scheduler: Cosine
- Trainer: Leveraged the Hugging Face Trainer API with Weights & Biases for logging
Evaluation
The model was evaluated on the test split. Below are the overall metrics:
- Accuracy: 0.969466
- Precision: 0.969586
- Recall: 0.969466
- F1 Score: 0.969417
Detailled evaluation (Size is the number of languages supported)
A detailed per-script classification report is also provided in the repository for further analysis.
How to Use
You can quickly load and run inference with this model using the Transformers pipeline:
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
tokenizer = AutoTokenizer.from_pretrained("alexneakameni/language_detection")
model = AutoModelForSequenceClassification.from_pretrained("alexneakameni/language_detection")
language_detection = pipeline("text-classification", model=model, tokenizer=tokenizer)
text = "Hello world!"
predictions = language_detection(text)
print(predictions)This will output the predicted language code or label with the corresponding confidence score.
Note: The model’s performance may vary depending on text length, language variety, and domain-specific vocabulary. Always validate results against your own datasets for critical applications.
For more information, see the repository documentation.
Thank you for using this model—feedback and contributions are welcome!
