| Task | Sentence-level sentiment classification of Sindhi text: negative, neutral, positive |
| Main model | xlmr_mixed: xlm-roberta-base fine-tuned for sequence classification |
| Reference model | baseline_natural: TF-IDF (word 1-2 grams) + LinearSVC |
| Hugging Face | alinawazmahar/sindhi-sentiment-xlmr |
| Framework | PyTorch, Hugging Face Transformers; scikit-learn for the baseline |
| Seed | 42 |
| Author | Ali Nawaz |
| Contact | alinawaz.code@gmail.com |
| License | Model weights are free to use under the MIT License, the same license as the base model xlm-roberta-base. The natural dataset is not included. |
| Version | 0.1.0 |
clean_text (Unicode NFKC, invisible characters removed, whitespace normalized) before prediction.Natural dataset (human-labeled). 4,420 Sindhi sentences with three labels (1,500 negative, 1,419 neutral, 1,501 positive). Sentences are 2 to 54 words long (mean 13.3) with a vocabulary of 9,060 words. Split with a fixed seed, grouped so near-duplicates stay together: 3,094 train, 442 validation, 884 test (locked until the final evaluation). Source and labeling: the sentences were collected from Awaz and other articles and newspapers, and labeled by a single human annotator. No second annotator reviewed the labels, so agreement between annotators was not measured. A formal definition of the neutral class is not documented here. The dataset is available separately on Kaggle: https://www.kaggle.com/datasets/alinawaz06/sindhi-sentiment-analysis-dataset (check the dataset page for its terms, since the text comes from published sources).
Synthetic dataset. 150,000 machine-generated sentences (50,000 per class), split 120,000 / 15,000 / 15,000 with duplicates and weekday variants of the same sentence kept within one split. The text is built from sentence templates with a small vocabulary (about 2,400 words in the training split). It is useful for testing the pipeline but not representative of real Sindhi: a baseline trained on it scores 0.9998 on its own validation set and only 0.6002 on the natural validation set.
xlmr_mixed)artifacts/models/xlmr_mixed/training_config.json.The baseline was trained on the natural training split only, in under one second on CPU.
Scored on the natural dataset. Test results were produced once, after all choices were fixed.
| Model | Validation macro-F1 | Test macro-F1 | Test accuracy |
|---|---|---|---|
| TF-IDF + LinearSVC, trained on synthetic data | 0.6002 | not run | not run |
| TF-IDF + LinearSVC, trained on natural data | 0.8665 | 0.8695 | 0.8688 |
| XLM-RoBERTa, natural data only | 0.8663 | not run | not run |
XLM-RoBERTa, synthetic + natural (xlmr_mixed) |
0.8872 | 0.8906 | 0.8903 |
Notes:
artifacts/metrics/compare_baseline_natural_vs_xlmr_mixed_external_test.json) found that on the 884 test sentences both models were right on 712 and wrong on 41. The baseline alone was wrong on 75 and XLM-R alone on 56, giving p = 0.116. The difference between the two models is therefore not statistically significant at this test size: XLM-R scored higher, but the result could plausibly be chance. When compute is limited, the lightweight baseline is a reasonable choice.artifacts/metrics/.The trained model weights in this repository are free to use, including for commercial work, under the MIT License. Please keep the author credit (Ali Nawaz). The base model, xlm-roberta-base, is also MIT licensed. The 4,420-sentence human-labeled dataset is not part of this model release and is not covered by this license; it is published separately on Kaggle (link above) under its own terms.
Sentiment labels are a coarse and subjective summary of text. Predictions can be wrong, and errors may not be evenly distributed across topics, dialects, or communities. Use human review for anything consequential. The natural dataset contains sentences taken from newspapers and articles, so check its terms before reusing or redistributing it.
With plain Transformers (no extra package needed):
from transformers import pipeline
classifier = pipeline("text-classification", model="alinawazmahar/sindhi-sentiment-xlmr")
print(classifier("اڄ جو ڏينهن تمام سٺو آهي", truncation=True, max_length=128))
The model was trained on text cleaned with Unicode NFKC normalization, removal of zero-width and bidirectional control characters and tatweel, and whitespace normalization. The Transformers pipeline does not apply this cleaning. For results that match the evaluation, use the project's sindhi-nlp package, which cleans the text for you and also returns the probability of every class:
from sindhi_nlp import SentimentPredictor
predictor = SentimentPredictor.from_pretrained("alinawazmahar/sindhi-sentiment-xlmr")
result = predictor.predict("اڄ جو ڏينهن تمام سٺو آهي")
print(result.label, result.confidence, result.probabilities)
The probabilities are overconfident (see Limitations), so use them as a ranking score rather than as calibrated probabilities. Install the package with pip install "sindhi-nlp[transformers]".
| File | Purpose |
|---|---|
model.safetensors, config.json |
XLM-RoBERTa weights and architecture, with the labels negative, neutral, positive |
tokenizer.json, tokenizer_config.json |
Tokenizer |
label_mapping.json |
Label to class-id mapping |
preprocessing.json |
Text-cleaning settings used in training |
training_config.json |
Training settings, seed, data file hashes, library versions |
metrics.json |
Validation metrics |
FacebookAI/xlm-roberta-base