Views
No views yet
| Property | Value |
|---|---|
| Base model | Davlan/afro-xlmr-mini |
| Language | Swahili (sw) |
| Task | Multi-class text classification |
| Dataset | MasakhaNEWS Swahili |
| Training samples | 1,658 |
| Validation samples | 237 |
| Test samples | 476 |
| Epochs | 5 |
| Best F1 | 0.4736 |
| Best Accuracy | 59.49% |
| Epoch | Train Loss | Val Loss | Accuracy | F1 |
|---|---|---|---|---|
| 1 | 1.9317 | 1.8947 | 32.49% | 0.2068 |
| 2 | 1.8470 | 1.8108 | 41.35% | 0.2943 |
| 3 | 1.7536 | 1.7107 | 55.27% | 0.4362 |
| 4 | 1.6792 | 1.6551 | 59.49% | 0.4705 |
| 5 | 1.6402 | 1.6337 | 59.49% | 0.4736 |
1from transformers import pipeline
2
3classifier = pipeline(
4 'text-classification',
5 model = 'katoernest/afro-xlmr-swahili-news-classifier',
6 tokenizer = 'katoernest/afro-xlmr-swahili-news-classifier'
7)
8
9result = classifier("mafuriko makubwa yameharibu mazao shambani")
10print(result)
11# [{'label': 'environment', 'score': 0.62}]1from transformers import pipeline
2from langdetect import detect
3import re
4
5classifier = pipeline(
6 'text-classification',
7 model = 'katoernest/afro-xlmr-swahili-news-classifier'
8)
9
10def classify_report(text):
11 # Step 1: detect language
12 language = detect(text)
13
14 # Step 2: clean text
15 clean = re.sub(r'http\S+|@\w+', '', text)
16 clean = re.sub(r'\s+', ' ', clean).strip()
17
18 # Step 3: classify
19 result = classifier(clean)[0]
20
21 return {
22 'text' : text,
23 'language' : language,
24 'category' : result['label'],
25 'confidence': round(result['score'] * 100, 1)
26 }
27
28# Test
29reports = [
30 'mafuriko makubwa yameharibu mazao shambani mashariki',
31 'wapigakura wanakataliwa kupiga kura kituo namba nne',
32 'mlipuko wa ugonjwa umethibitishwa kaskazini mwa nchi',
33]
34
35for r in reports:
36 print(classify_report(r))Community report (SMS / WhatsApp / voice note)
↓
Whisper transcription
↓
Language detection
↓
Text cleaning
↓
[This model] — category classification
↓
Confidence routing
> 0.80 → auto-approve
0.50–0.80 → human review
< 0.50 → flag for manual classification
↓
Dashboard