Downloads · 30 days
4
4% of all-time downloads
Ujju33/nepali-sentiment-xlm-roberta
nepali-sentiment-xlm-roberta is a text classification model from Ujju33. Use it when you need a label for a piece of text. The card lists the license as apache-2.0.
Fine-tuned XLM-RoBERTa-base for binary sentiment classification on Nepali text (Devanagari script), achieving 88.5% accuracy and 0.88 F1 score — a +38 percentage point improvement over the zero-shot baseline.
Downloads · 30 days
4
4% of all-time downloads
All-time downloads
92
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
Fine-tuned XLM-RoBERTa-base for binary sentiment classification on Nepali text (Devanagari script), achieving 88.5% accuracy and 0.88 F1 score — a +38 percentage point improvement over the zero-shot baseline.
| Metric | Baseline (Zero-Shot) | Fine-Tuned | Improvement |
|---|---|---|---|
| Accuracy | 50.50% | 88.50% | +38.0pp |
| F1 Score | 0.00 | 0.88 | +0.88 |
| Error Rate | 49.50% | 11.50% | -38.0pp |
Evaluated on 200 random samples from the IRIIS-RESEARCH test set.
Confusion matrix: [[90, 11], [12, 87]] — balanced errors across classes.
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model_name = "Ujju33/nepali-sentiment-xlm-roberta"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
model.eval()
def predict_sentiment(text):
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.nn.functional.softmax(outputs.logits, dim=-1)
confidence, predicted_class = torch.max(probs, dim=1)
labels = {0: "negative", 1: "positive"}
return {
"sentiment": labels[predicted_class.item()],
"confidence": round(confidence.item(), 4)
}
# Example
result = predict_sentiment("यो फिल्म एकदमै राम्रो छ!")
print(result) # {'sentiment': 'positive', 'confidence': 0.9964}
Full training notebook available at: https://github.com/ujju1124/nepali-sentiment-finetuning
This model powers the Nepali News Intelligence Agent: https://huggingface.co/spaces/Ujju33/nepali-news-agent