Downloads · 30 days
14
14% of all-time downloads
FarazAbdulMuqtader/roman-urdu-sentiment-xlmr
roman-urdu-sentiment-xlmr is a text classification model from FarazAbdulMuqtader. Use it when you need a label for a piece of text. The card lists the license as mit.
Fine-tuned XLM-RoBERTa model for sentiment analysis on Roman Urdu (Urdu written in Latin script) — the informal script most commonly used across Pakistani social media, messaging, and reviews.
Downloads · 30 days
14
14% of all-time downloads
All-time downloads
97
Public
Parameters
278M
2.2 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors1.1 GB · 99%
From the Hugging Face model README
Fine-tuned XLM-RoBERTa model for sentiment analysis on Roman Urdu (Urdu written in Latin script) — the informal script most commonly used across Pakistani social media, messaging, and reviews.
📦 GitHub repo (full pipeline: preprocessing, training, evaluation scripts)
This model classifies Roman Urdu text into one of three sentiment classes: Positive, Negative, or Neutral. It's built on xlm-roberta-base, fine-tuned on a large Roman Urdu sentiment corpus to handle the inconsistent spelling and English code-mixing typical of informal Roman Urdu text.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_id = "FarazAbdulMuqtader/roman-urdu-sentiment-xlmr"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
label_names = ["Positive", "Negative", "Neutral"]
def predict_sentiment(text):
encoding = tokenizer(text, padding="max_length", truncation=True, max_length=128, return_tensors="pt")
with torch.no_grad():
logits = model(**encoding).logits
probs = torch.softmax(logits, dim=1).squeeze()
predicted_id = torch.argmax(probs).item()
return label_names[predicted_id], probs[predicted_id].item()
label, confidence = predict_sentiment("wah kya baat hai zabardast")
print(f"{label} ({confidence*100:.1f}%)")
Khubaib01/RomanUrdu-NLP-Sentiment-Corpusxlm-roberta-baseEvaluated on the 25,876-row held-out test set.
Overall accuracy: 81%
| Label | Precision | Recall | F1-score | Support |
|---|---|---|---|---|
| Positive | 0.81 | 0.82 | 0.82 | 7,252 |
| Negative | 0.84 | 0.85 | 0.85 | 10,504 |
| Neutral | 0.78 | 0.76 | 0.77 | 8,120 |
| Accuracy | 0.81 | 25,876 | ||
| Macro avg | 0.81 | 0.81 | 0.81 | 25,876 |
| Weighted avg | 0.81 | 0.81 | 0.81 | 25,876 |
Confusion matrix (rows = actual, columns = predicted):
| Positive | Negative | Neutral | |
|---|---|---|---|
| Positive | 5,977 | 508 | 767 |
| Negative | 588 | 8,920 | 996 |
| Neutral | 802 | 1,177 | 6,141 |
Built to address a low-resource, code-mixed language largely underserved by mainstream NLP tooling. Suitable for sentiment tagging of Roman Urdu social media posts, reviews, and messages. Not intended for high-stakes decision-making without human review.