YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

🧠 XLM-RoBERTa for Vietnamese NLI — Full 6K Finetune

Fine-tuned XLM-RoBERTa-base model for Vietnamese Natural Language Inference (NLI) — trained on a manually curated and balanced dataset of ~6k premise–hypothesis pairs. The model predicts one of three labels:

  • c → Contradiction
  • n → Neutral
  • e → Entailment

🚀 Overview

Item Description
Base model xlm-roberta-base
Framework PyTorch + 🤗 Transformers (v4.43.3)
Dataset size 14,116 train / 1,765 val / 1,765 test
Sequence length 256
Task Vietnamese NLI (Entailment / Contradiction / Neutral)
Language Vietnamese 🇻🇳
License MIT (default HF sharing)
Author @lyle49

📚 Dataset

The dataset (full_data_true_conflict.json) includes Vietnamese NLI pairs with carefully normalized labels:

Split Size Label distribution
Train 14,116 c: 4,705 / n: 4,706 / e: 4,705
Validation 1,765 c: 589 / n: 588 / e: 588
Test 1,765 c: 588 / n: 588 / e: 589

Each record:

{
  "id": "example_001",
  "premise": "Anh ấy đang chơi bóng đá trên sân.",
  "hypothesis": "Anh ấy đang tham gia một môn thể thao.",
  "label": "e"
}

⚙️ Training Configuration

Setting Value
Epochs 4
Batch size 8 × 2 (gradient accumulation = 2)
Optimizer AdamW
Learning rate 2e-5
Warmup ratio 0.06
Weight decay 0.01
Precision fp16 (AMP)
Gradient checkpointing ✅ Enabled
Label smoothing 0.05
Early stopping patience = 2
Tokenizer max length 256
Save format .safetensors

Environment:

  • CUDA 12.4
  • Transformers 4.43.3
  • PyTorch 2.3.0+cu124
  • Kaggle P100 GPU

🧩 Model Performance

Split Accuracy F1 (macro) Loss
Validation 0.9807 0.9808 0.2278
Test 0.9796 0.9796 0.2354

Confusion Matrix (Test)

c n e
c 571 9 8
n 4 578 6
e 3 6 580

Classification Report (Test)

Label Precision Recall F1
c 0.9879 0.9711 0.9794
n 0.9747 0.9830 0.9788
e 0.9764 0.9847 0.9806
Macro avg 0.9797 0.9796 0.9796

🧪 Usage Example

from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model_name = "lyle49/xlmr-vinli-finetune-full-6k"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)

premise = "Anh ấy đang chơi bóng đá trên sân."
hypothesis = "Anh ấy đang tham gia một môn thể thao."
inputs = tokenizer(premise, hypothesis, return_tensors="pt", truncation=True, max_length=256)

with torch.no_grad():
    outputs = model(**inputs)
    probs = torch.softmax(outputs.logits, dim=-1)
    label = model.config.id2label[probs.argmax().item()]

print(f"Prediction: {label} ({probs.max().item():.3f})")

Output:

Prediction: e (0.980)

🧭 Notes

  • The model achieves ~98% accuracy on a balanced Vietnamese NLI test set.
  • It is robust for figurative / paraphrased sentence pairs and works well on both formal and informal text.
  • For extended use (e.g., paraphrase detection, contradiction filtering, or multi-lingual entailment), consider fine-tuning with domain data.
  • Model is saved as .safetensors for safety and compatibility.

🏷️ Citation

If you use this model in research or product, please cite:

@misc{lyle49_xlmr_vinli_2025,
  author = {Lê, Lý},
  title = {XLM-RoBERTa for Vietnamese NLI — Full 6K Finetune},
  year = {2025},
  publisher = {Hugging Face},
  howpublished = {\url{https://huggingface.co/lyle49/xlmr-vinli-finetune-full-6k}}
}

🧰 Files in Repository

File Description
config.json Model configuration
model.safetensors Finetuned model weights
tokenizer.json, tokenizer_config.json, special_tokens_map.json, sentencepiece.bpe.model Tokenizer files
README.md This documentation

⭐ Created by @lyle49 — part of the Vietnamese Figurative NLI Project (2025).

Downloads last month
1
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