Xhenifer commited on
Commit
63128ed
·
verified ·
1 Parent(s): b02cd04

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +72 -1
README.md CHANGED
@@ -15,4 +15,75 @@ tags:
15
  - african-nlp
16
  - cross-orthography
17
  - text-classification
18
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  - african-nlp
16
  - cross-orthography
17
  - text-classification
18
+ ---
19
+
20
+ # Sesotho Sentiment Analysis (AfriBERTa)
21
+
22
+ A fine-tuned sentiment classifier for Sesotho news headlines, built as part of the **Wale Lab R2I Fellowship (Cohort 3)**. Classifies text into **Positive**, **Negative**, or **Neutral**.
23
+
24
+ ## 🚀 Try it live
25
+
26
+ An interactive browser-based demo (no setup required, runs entirely client-side) is available here:
27
+ 👉 **[Sesotho Sentiment Analysis Space](https://huggingface.co/spaces/Xhenifer/sesotho-sentiment-afriberta)**
28
+
29
+ The demo runs this model directly in your browser via [Transformers.js](https://huggingface.co/docs/transformers.js) and WebAssembly — no server, no API calls, nothing sent off your device. It also includes an optional South African orthography converter, for testing cross-orthography generalization between Lesotho-standard and South African Sesotho spelling conventions.
30
+
31
+ ## Model description
32
+
33
+ This model is a fine-tuned version of [`castorini/afriberta_large`](https://huggingface.co/castorini/afriberta_large), adapted for 3-class sentiment classification on Sesotho news headlines.
34
+
35
+ - **Base model:** castorini/afriberta_large
36
+ - **Task:** Text classification (sentiment)
37
+ - **Labels:** `NEGATIVE`, `NEUTRAL`, `POSITIVE`
38
+ - **Language:** Sesotho (st)
39
+
40
+ ## Training data
41
+
42
+ Fine-tuned on a labeled dataset of 2,209 Sesotho news headlines. The source data is significantly imbalanced across classes:
43
+
44
+ | Label | Count | Proportion |
45
+ |---|---|---|
46
+ | Negative | 1,552 | 70.3% |
47
+ | Positive | 551 | 24.9% |
48
+ | Neutral | 106 | 4.8% |
49
+
50
+ To address this imbalance, training used a **class-weighted cross-entropy loss** (weights: Negative 1.0×, Neutral 6.0×, Positive 3.0×), which meaningfully improved the model's ability to recognize the minority Neutral class without a corresponding drop in Negative/Positive performance.
51
+
52
+ ## Training procedure
53
+
54
+ - 3 epochs, learning rate 2e-5, batch size 8, warmup ratio 0.1
55
+ - 80/20 stratified train/validation split, seed 43
56
+ - Full training script and data preprocessing available on request
57
+
58
+ ## Evaluation results
59
+
60
+ Evaluated on a held-out validation split (442 examples):
61
+
62
+ | Metric | Score |
63
+ |---|---|
64
+ | Macro F1 | 0.661 |
65
+ | Matthews Correlation Coefficient | 0.440 |
66
+ | Neutral-class F1 | 0.605 |
67
+ | Neutral-class recall | 0.619 |
68
+
69
+ ## Limitations
70
+
71
+ - The Neutral class remains the hardest to classify reliably, given only 106 examples in the source dataset — class weighting helps but cannot fully substitute for more labeled data.
72
+ - The model was trained primarily on standard-case text; performance may vary on ALL CAPS or heavily stylized input.
73
+ - As with any sentiment classifier trained on news headlines, performance on informal or conversational Sesotho text (social media, spoken transcription, etc.) has not been evaluated and may differ.
74
+
75
+ ## Usage
76
+
77
+ ```python
78
+ from transformers import pipeline
79
+
80
+ clf = pipeline("text-classification", model="Xhenifer/sesotho-sentiment-afriberta", top_k=None)
81
+ clf("TONAKHOLO O FETOLA NAHA KA BEKE")
82
+ ```
83
+
84
+ For browser-based / client-side usage via Transformers.js, see the [demo Space](https://huggingface.co/spaces/Xhenifer/sesotho-sentiment-afriberta) or its source for a working implementation.
85
+
86
+ ## Citation
87
+
88
+
89
+ Xhenifer. (2026). *Sesotho Sentiment Analysis (AfriBERTa)*. Wale Lab R2I Fellowship, Cohort 3. Hugging Face. https://huggingface.co/Xhenifer/sesotho-sentiment-afriberta