Yoruba diacritic restoration: a small CPU model that puts the marks back
# ami
A Yoruba diacritic restoration model, trained on a 2014 laptop, published on
the Hugging Face Hub.
**The model:
huggingface.co
*àmì* is Yoruba for "mark". This is the most personal project in my portfolio.
I grew up speaking Yoruba in a village in southwestern Nigeria, and written
Yoruba depends on marks that most keyboards drop: the dotted letters ẹ, ọ, ṣ
are different letters entirely, and the tone marks separate words that are
otherwise spelled the same. Type `oko` and you have collapsed oko (farm), ọkọ
(husband) and ọkọ̀ (vehicle) into one string. Most Yoruba text on the internet
lives in that collapsed state.
This model puts the marks back: 1.29 million parameters, running at 9,600
characters per second on a twelve-year-old CPU, because a tool for restoring
text messages should not need a GPU.
```
in: bawo ni oko re se n lo
out: báwo ni ọkọ rẹ̀ ṣe ń lọ (how is your husband doing)
```
It chose *husband*, not *farm* or *vehicle*, from context. That choice is the
entire project.
## Results
Evaluated on the test split of MENYO-20k (Adelani et al. 2021), the
professionally translated and diacritized benchmark: 6,573 sentences never
seen during training or model selection.
| system | char accuracy | word accuracy | ambiguous words | sentence exact |
|---|---|---|---|---|
| leave text unmarked | 39.2% | 15.5% | 12.2% | 0.1% |
| word lookup (most frequent form) | 77.1% | 69.2% | 78.6% | 3.8% |
| **ami** | **92.4%** | **86.0%** | **88.2%** | **10.6%** |
Char accuracy is scored only on positions that can legally carry marks, so
nobody gets credit for copying consonants. The margin over the lookup table
lives where it should: on the ambiguous words, where the same spelling has
several attested forms and only context can decide.
## The information story
Before training anything, I measured what the marks actually carry.
Knowing only the base letter, a mark costs **1.64 bits per character** to
guess; *e* and …