Luganda Translator V1
High-performance English → Luganda translation. Outperforms Google Translate. 918 MB. Fully offline.
| Benchmark (FLORES-200 devtest) | chrF++ | spBLEU |
|---|---|---|
| Google Translate | 41.29 | 14.45 |
| Luganda Translator V1 | 45.01 | 17.70 |
Results: Statistically significant lead over Google Translate (paired bootstrap, p ≤ 0.001). Zero dependencies on APIs, internet, or GPUs. Optimized for CPU and Android (arm64).
Technical Specifications
- Performance: Superior to Google Translate on FLORES-200 benchmarks.
- Efficiency: 909M parameters (int8). 1.6× faster than the 1.37B source model.
- Dataset: Trained on a proprietary 200k-pair synthetic dataset luganda-synthetic-200k.
- Reproducibility: All benchmarks, significance tests, and scripts are hosted in this repository.
Engineering Pipeline
- Architecture Optimization: Decoder pruned from 24 to 14 layers; vocabulary trimmed from 256k to 51k tokens to eliminate noise and reduce footprint.
- Data Synthesis: 200,000 English pairs sourced from Wikinews/Wikivoyage with strict FLORES-200 overlap exclusion. Used MBR selection for the primary 100k set.
- Knowledge Distillation: Retrained via word-level distillation (top-16 distribution + label-smoothed cross-entropy) on A100 hardware.
- Optimization: Checkpoint averaging applied to the final 8 iterations for stability.
- Inference: MBR decoding (beam-4 + 4 samples) utilized to maximize translation accuracy via chrF++ consensus.
Implementation
pip install ctranslate2 transformers sentencepiece huggingface_hub
import ctranslate2
from huggingface_hub import snapshot_download
from transformers import AutoTokenizer
path = snapshot_download("kyleparrratt/luganda-translator-v1")
tok = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-600M", src_lang="eng_Latn")
translator = ctranslate2.Translator(path, device="cpu", compute_type="int8")
def translate(text, beam_size=4):
tokens = tok.convert_ids_to_tokens(tok.encode(text))
result = translator.translate_batch([tokens], target_prefix=[["lug_Latn"]], beam_size=beam_size)
return tok.decode(tok.convert_tokens_to_ids(result[0].hypotheses[0][1:]), skip_special_tokens=True)
print(translate("Where is the nearest hospital?"))
# Eddwaliro eriri okumpi liri ludda wa?