Twi Punctuation and Capitalization Restoration Model
A fast, lightweight CPU model specifically fine-tuned for Akan/Twi to simultaneously restore capitalization (lowercase, Title Case, ALL CAPS) and punctuation (commas, sentence-ending periods, question marks).
🎙️ Why This Model is Essential for Twi Text-to-Speech (TTS)
In written Twi orthography, commas are routinely omitted, even though they represent essential, audible pauses in normal spoken Twi:
- Written Habits: Writers conventionally omit commas before conjunctions (
ne,anaa), complementizers (sɛ), appositives, and long noun phrases. - The TTS Bottleneck: For Text-to-Speech (TTS) models, punctuation is the single most critical signal for breath pauses and prosodic rhythm. When Twi text lacks commas, synthesized speech rushes through clauses unnaturally without taking breath.
- Acoustic Grounding: This model was fine-tuned on data where speech pauses (>=350ms) were acoustically identified with forced alignment. It directly compensates for commas that are conventionally ignored when writing Twi, matching the natural rhythm of spoken Twi for high-quality TTS applications.
Highlights
- Backbone:
Ghana-NLP/distilabena-base-v2-akuapem-twi-cased(Ghana NLP Twi DistilBERT, 6 layers, 768 hidden). - Multi-Task Architecture: Dual classification heads for simultaneous token-level Capitalization (3 classes) and Punctuation (5 classes).
- Fast CPU Inference:
- PyTorch CPU: ~110 ms
- ONNX INT8 Quantized: ~11–28 ms per sentence (runs on standard CPU).
- Zero Hallucination Guarantee: Non-autoregressive token classification preserves all input words in their original order.
Model Formats Available
model_quantized.onnx(135 MB, INT8 quantized for ultra-fast CPU inference)model.onnx(537 MB)model.safetensors(539 MB)pytorch_model.bin(539 MB)- Complete tokenizer files (
vocab.txt,tokenizer.json,tokenizer_config.json)
Performance Metrics
- Capitalization Macro F1: 0.8725
- Comma Precision: 0.669 | Comma Recall: 0.806 | Comma F1: 0.731
- Period Precision: 0.925 | Period Recall: 0.964
Live Interactive Demo
Try the model online: ghananlpcommunity/twi-punct-cap-restorer
GitHub Repository
Code, pipelines, and data preparation: GhanaNLP/twi-comma-fix