XLM-RoBERTa Fine-Tuned for Vietnamese Natural Language Inference
This model is a fine-tuned version of the xlm-roberta-base model, specifically adapted for Natural Language Inference (NLI) tasks in Vietnamese. It classifies the relationship between a given premise and hypothesis into one of three categories: entailment, neutral, or contradiction.
Model and Training
The core of this model is XLM-RoBERTa, a multilingual masked language model pre-trained on text from 100 different languages. This powerful base is then fine-tuned on a Vietnamese NLI dataset. The fine-tuning process adapts the model to the specific nuances of Vietnamese language and the logical reasoning required for NLI.
The training was conducted for 4 epochs with a batch size of 16 for training and 32 for evaluation. It utilized the AdamW optimizer with a learning rate of 2e-5 and a linear scheduler with a 6% warmup. To accelerate the training, FP16 precision was used on a GPU P100.
Dataset
The model was trained and evaluated on a custom Vietnamese NLI dataset with the following splits:
- Train:
/kaggle/input/train-nli/train.json - Validation (dev):
/kaggle/input/train-nli/vinli_dev.json - Test:
/kaggle/input/train-nli/vinli_test.json
Each entry in the dataset consists of a premise, a hypothesis, and a corresponding label indicating their relationship.
Performance
The model demonstrates solid performance on the Vietnamese NLI task, achieving the following results:
Validation:
- Accuracy: 72.55%
- F1-macro: 72.54%
Test:
- Accuracy: 73.10%
- F1-macro: 73.00%
Classification Report (Test)
| Label | Precision | Recall | F1-score | Support |
|---|---|---|---|---|
| contradiction | 0.7061 | 0.6716 | 0.6885 | 737 |
| neutral | 0.7240 | 0.7799 | 0.7509 | 777 |
| entailment | 0.7631 | 0.7387 | 0.7507 | 750 |
| Accuracy | 0.7310 | 2264 | ||
| Macro avg | 0.7311 | 0.7301 | 0.7300 | 2264 |
Confusion Matrix (Test)
| Predicted C | Predicted N | Predicted E | |
|---|---|---|---|
| Gold C | 495 | 132 | 110 |
| Gold N | 109 | 606 | 62 |
| Gold E | 97 | 99 | 554 |
Usage
To use this model for your own Vietnamese NLI tasks, you can load it directly from the Hugging Face Hub using the transformers library.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "lyle49/xlmr-vinli-finetune"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
premise = "Một sào lúa non nuôi con nửa ngày"
hypothesis = "Lúa non chỉ nuôi được nửa ngày"
inputs = tokenizer(premise, hypothesis, return_tensors="pt", truncation=True, max_length=256)
with torch.no_grad():
logits = model(**inputs).logits
pred_id = logits.argmax(dim=-1).item()
id2label = model.config.id2label
print("Prediction:", id2label[pred_id])
Notes
- This model shows good performance on Vietnamese NLI tasks, including those that involve figurative or idiomatic reasoning.
- It can serve as a strong starting point for developing multilingual entailment models. The base checkpoint can be switched to
xlm-roberta-largefor potentially better performance, though this may require a smaller batch size to accommodate the larger model.
Citation
If you use this model in your research, please use the following citation:
@misc{xlmr_vinli_finetune,
author = {Lê Lý},
title = {XLM-RoBERTa fine-tuned on Vietnamese NLI},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/lyle49/xlmr-vinli-finetune}}
}
- Downloads last month
- 3