Token Classification
Transformers
PyTorch
ONNX
Safetensors
xlm-roberta
fill-mask
punctuation-restoration
capitalization
truecasing
asr-post-processing
text-to-speech
tts-prosody
afrispeech
Instructions to use AfriSpeech/afri-punct-cap with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AfriSpeech/afri-punct-cap with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="AfriSpeech/afri-punct-cap")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("AfriSpeech/afri-punct-cap") model = AutoModelForMaskedLM.from_pretrained("AfriSpeech/afri-punct-cap", device_map="auto") - Notebooks
- Google Colab
- Kaggle
AfriPunctCap: Pan-African Punctuation & Capitalization Restoration Model
A fast, lightweight multilingual model fine-tuned on 3.3 Million multi-sentence passages across 751 African languages and dialects to restore commas, sentence-ending periods, and capitalization in unpunctuated ASR transcripts and text.
Part of the AfriSpeech open-source speech initiative.
๐ Precision Comparison: INT8 Quantized (Default CPU) vs. FP16 (GPU)
We evaluated the exact same held-out test sets using the dynamic quantized CPU engine (INT8 ONNX) and the full precision GPU model (bfloat16 / FP16):
| Language | Language Family | INT8 Comma F1 (Default) | FP16 Comma F1 | INT8 Period F1 | FP16 Period F1 | Accuracy Retained |
|---|---|---|---|---|---|---|
| Swahili (swh) | Niger-Congo (Bantu) | 0.641 | 0.649 | 0.953 | 0.953 | 98.8% |
| Zulu (zul) | Niger-Congo (Bantu) | 0.609 | 0.628 | 0.860 | 0.886 | 97.0% |
| Hausa (hau) | Afroasiatic (Chadic) | 0.579 | 0.611 | 0.899 | 0.908 | 94.8% |
| Yoruba (yor) | Niger-Congo (Defoid) | 0.562 | 0.503 | 0.847 | 0.842 | 100.0% |
| Akan / Twi (aka) | Niger-Congo (Kwa) | 0.540 | 0.543 | 0.899 | 0.870 | 99.4% |
| Ewe (ewe) | Niger-Congo (Gbe) | 0.561 | 0.597 | 0.711 | 0.747 | 94.0% |
| Lingala (lin) | Niger-Congo (Bantu) | 0.448 | 0.438 | 0.846 | 0.843 | 100.0% |
| Kinyarwanda (kin) | Niger-Congo (Bantu) | 0.496 | 0.504 | 0.836 | 0.871 | 98.4% |
| Wolof (wol) | Niger-Congo (Senegambian) | 0.568 | 0.570 | 0.752 | 0.734 | 99.6% |
| Somali (som) | Afroasiatic (Cushitic) | 0.468 | 0.438 | 0.798 | 0.790 | 100.0% |
| Average (Core) | Pan-African Benchmark | 0.547 | 0.548 | 0.840 | 0.844 | 99.8% Retained |
Key Benchmark Takeaways:
- INT8 is the Recommended Default: INT8 dynamic quantization retains 99.8% of the full FP16 accuracy while cutting memory footprint in half to 278 MB.
- Sub-30ms CPU Latency: Single-sentence inference runs in 15โ25 ms on standard commodity CPUs without needing a GPU.
- Zero Language Tags Required: Operates in pure text mode across all languages without requiring language specification.
๐๏ธ Restoring Omitted Punctuation for African Text-to-Speech (TTS)
Across African languages, writers conventionally omit commas, despite native speakers making clear, audible pauses in normal speech:
- Written Habits: Commas are routinely skipped before conjunctions (like ne in Akan, ร ti in Yoruba, na in Swahili), complementizers, appositives, and compound titles.
- The TTS Bottleneck: For Text-to-Speech (TTS) models, punctuation is the single most critical signal for breath pauses and prosodic rhythm. Without commas, TTS engines rush through clauses unnaturally without breathing.
- Syntactic Restoration: Fine-tuned on 3.3 Million multi-sentence passages, this model systematically compensates for commas conventionally ignored in writing, matching natural spoken rhythm.
Model Formats Available
onnx/model_quantized.onnx(278 MB, Default INT8 quantized for ultra-fast CPU inference)onnx/model.onnx(1.1 GB, full precision ONNX)model_fp16.safetensors(540 MB, Optional half-precision weights for GPU)model.safetensors&pytorch_model.bin(Full precision PyTorch)- Complete SentencePiece tokenizer files
Live Interactive Demo
Try the model online: AfriSpeech/afri-punct-cap-demo
GitHub Repository
Code, pipelines, and data preparation: AfriSpeech/afri-punct-cap
- Downloads last month
- 24