Downloads · 30 days
7
7% of all-time downloads
lyle49/xlmr-vinli-finetune-true-6k
xlmr-vinli-finetune-true-6k is a text classification model from lyle49. Use it when you need a label for a piece of text. It is set up for transformers.
A Vietnamese Natural Language Inference (NLI) model that predicts the relation between a premise and a hypothesis as one of: - c (contradiction) - n (neutral) - e (entailment)
Downloads · 30 days
7
7% of all-time downloads
All-time downloads
99
Public
Parameters
278M
1.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.1 GB · 98%
From the Hugging Face model README
A Vietnamese Natural Language Inference (NLI) model that predicts the relation between a premise and a hypothesis as one of:
c (contradiction)n (neutral)e (entailment)This model fine-tunes xlm-roberta-base using a stratified 80/10/10 split, optimized to run on a single GPU (Kaggle T4/P100).
xlm-roberta-baseRecommendations: Evaluate on your target domain; monitor confusion between n vs e/c; consider calibration or thresholding if used in pipelines.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_id = "YOUR_USERNAME/xlmr-vinli-finetune" # replace with your repo id
tok = AutoTokenizer.from_pretrained(model_id)
mdl = AutoModelForSequenceClassification.from_pretrained(model_id)
id2label = mdl.config.id2label # {0:'c',1:'n',2:'e'}
text = {"premise": "Trời đang mưa rất to.", "hypothesis": "Bên ngoài khô ráo và không có mưa."}
enc = tok(text["premise"], text["hypothesis"], return_tensors="pt", truncation=True, max_length=256)
with torch.no_grad():
logits = mdl(**enc).logits
pred = logits.softmax(-1).argmax(-1).item()
print("Prediction:", id2label[pred])
/kaggle/input/nli-vietnam/full_data_true.json{"c":0, "n":1, "e":2}Ensure JSON has fields: id, premise, hypothesis, label (labels in {c,n,e}).
Preprocessing
XLMRobertaTokenizerFast (max_length=256, truncation)Hyperparameters
per_device_train_batch_size=8, per_device_eval_batch_size=32bf16 if available (Ampere+), else fp16save_safetensors=True, load_best_model_at_end=True on f1_macrodataloader_num_workers=2, pin_memory=Truexlm-roberta-base head (+classifier)Accuracy: 0.9901
Macro F1: 0.9878
Support: 1113 samples (c=429, n=108, e=576)
Classification Report:
precision recall f1-score support
c 0.9930 0.9883 0.9907 429
n 0.9815 0.9815 0.9815 108
e 0.9896 0.9931 0.9913 576
weighted avg 0.9901 0.9901 0.9901 1113
Confusion Matrix:
[ 1 106 1],
[ 2 2 572]]
Note: Replicate numbers may vary slightly due to randomness/hardware.
transformers==4.43.3datasets==2.21.0accelerate==0.33.0evaluate==0.4.2scikit-learn==1.5.1torch (CUDA)@inproceedings{conneau2020unsupervised,
title={Unsupervised Cross-lingual Representation Learning at Scale},
author={Conneau, Alexis and Khandelwal, Kartikay and Goyal, Naman and Chaudhary, Vishrav and Wenzek, Guillaume and Guzm{\'a}n, Francisco and Grave, Edouard and Ott, Myle and Zettlemoyer, Luke and Stoyanov, Veselin},
booktitle={ACL},
year={2020}
}
Author: Lê Lý