A complete library for training, evaluating, and serving Acoli (Acholi) β English translation models. Built on NLLB-200 with LoRA fine-tuning, optimized for low-resource settings.
# From source
git clone https://github.com/your-username/acoli-nmt.git
cd acoli-nmt
pip install -e ".[all]"
# Or just the core (no Gradio/COMET)
pip install -e .
Requirements: Python β₯3.9, PyTorch β₯2.1, CUDA recommended (runs on CPU but slow).
from acoli_nmt import Config, Trainer, Translator
# ββ Train from scratch ββββββββββββββββββββββββββββββββββββββββββββββ
cfg = Config(epochs=3, lr=1e-4, batch_size=16)
trainer = Trainer(cfg)
trainer.load_data() # downloads & merges 5 parallel corpora
trainer.train() # fine-tunes NLLB-200 with LoRA
metrics = trainer.evaluate() # bidirectional BLEU/chrF/COMET
trainer.save("./my-model")
# ββ Translate with a trained model ββββββββββββββββββββββββββββββββββ
t = Translator.from_pretrained("./my-model")
t.en_to_ach("How are you today?")
t.ach_to_en("Itye nining?")
t.translate_batch(["Hello", "Thank you"], direction="en2ach")
# Train (downloads data automatically)
acoli-train --epochs 5 --lr 1e-4 --save-dir ./my-model
# Evaluate a trained model
acoli-eval ./my-model
# Translate text
acoli-translate ./my-model "How are you today?"
acoli-translate ./my-model -d ach2en "Itye nining?"
# Pipe mode (one sentence per line)
cat sentences.txt | acoli-translate ./my-model
# Launch Gradio web UI
acoli-serve ./my-model --share
acoli-serve ./my-model --port 8080
After training, launch an interactive translation dashboard:
acoli-serve ./my-model --share
This gives you:
--share creates a public URL (works on Colab too).
All settings are in the Config dataclass. You can pass them as constructor args:
cfg = Config(
model_path="nllb", # "nllb" or "llm"
nllb_model="facebook/nllb-200-distilled-600M", # or 1.3B, 3.3B
epochs=5,
lr=1e-4,
batch_size=16,
grad_accum=4, # effective batch = 64
max_len=256,
use_lora=True,
lora_r=16,
nllb_bidirectional=True, # train both enβach and achβen
)
Or load from YAML:
import yaml
cfg = Config(**yaml.safe_load(open("configs/default.yaml")))
| Dataset | Size | License |
|---|---|---|
| MT560 EnglishβAcholi | ~73K pairs | CC-BY-4.0 |
| UgandaLex v1 | ~6.2K | CC-BY-4.0 |
| UgandaLex v2 | ~6.2K | CC-BY-4.0 |
| SALT (Sunbird) | ~25K | CC-BY-SA-4.0 |
| ugalang_0 | ~2.6K | See dataset card |
All downloaded automatically on first run.
ach_Latn added via NllbTokenizer(language_codes=...) with embedding initialized from related luo_Latn| Setup | GPU | Works? |
|---|---|---|
| NLLB-600M + LoRA | T4 (16GB) | β |
| NLLB-600M + LoRA | RTX 3090/4090 | β |
| NLLB-1.3B + LoRA | A10/A100 | β |
| Tower-7B + QLoRA | T4 (16GB) | β (tight) |
| CPU only | β | β οΈ Very slow |
If you hit OOM: reduce max_len β 192 or grad_accum β 3.
MIT. Training data has its own licenses (see table above).
Python
100.0%
A complete library for training, evaluating, and serving Acoli (Acholi) β English translation models. Built on NLLB-200 with LoRA fine-tuning, optimized for low-resource settings.
# From source
git clone https://github.com/your-username/acoli-nmt.git
cd acoli-nmt
pip install -e ".[all]"
# Or just the core (no Gradio/COMET)
pip install -e .
Requirements: Python β₯3.9, PyTorch β₯2.1, CUDA recommended (runs on CPU but slow).
from acoli_nmt import Config, Trainer, Translator
# ββ Train from scratch ββββββββββββββββββββββββββββββββββββββββββββββ
cfg = Config(epochs=3, lr=1e-4, batch_size=16)
trainer = Trainer(cfg)
trainer.load_data() # downloads & merges 5 parallel corpora
trainer.train() # fine-tunes NLLB-200 with LoRA
metrics = trainer.evaluate() # bidirectional BLEU/chrF/COMET
trainer.save("./my-model")
# ββ Translate with a trained model ββββββββββββββββββββββββββββββββββ
t = Translator.from_pretrained("./my-model")
t.en_to_ach("How are you today?")
t.ach_to_en("Itye nining?")
t.translate_batch(["Hello", "Thank you"], direction="en2ach")
# Train (downloads data automatically)
acoli-train --epochs 5 --lr 1e-4 --save-dir ./my-model
# Evaluate a trained model
acoli-eval ./my-model
# Translate text
acoli-translate ./my-model "How are you today?"
acoli-translate ./my-model -d ach2en "Itye nining?"
# Pipe mode (one sentence per line)
cat sentences.txt | acoli-translate ./my-model
# Launch Gradio web UI
acoli-serve ./my-model --share
acoli-serve ./my-model --port 8080
After training, launch an interactive translation dashboard:
acoli-serve ./my-model --share
This gives you:
--share creates a public URL (works on Colab too).
All settings are in the Config dataclass. You can pass them as constructor args:
cfg = Config(
model_path="nllb", # "nllb" or "llm"
nllb_model="facebook/nllb-200-distilled-600M", # or 1.3B, 3.3B
epochs=5,
lr=1e-4,
batch_size=16,
grad_accum=4, # effective batch = 64
max_len=256,
use_lora=True,
lora_r=16,
nllb_bidirectional=True, # train both enβach and achβen
)
Or load from YAML:
import yaml
cfg = Config(**yaml.safe_load(open("configs/default.yaml")))
| Dataset | Size | License |
|---|---|---|
| MT560 EnglishβAcholi | ~73K pairs | CC-BY-4.0 |
| UgandaLex v1 | ~6.2K | CC-BY-4.0 |
| UgandaLex v2 | ~6.2K | CC-BY-4.0 |
| SALT (Sunbird) | ~25K | CC-BY-SA-4.0 |
| ugalang_0 | ~2.6K | See dataset card |
All downloaded automatically on first run.
ach_Latn added via NllbTokenizer(language_codes=...) with embedding initialized from related luo_Latn| Setup | GPU | Works? |
|---|---|---|
| NLLB-600M + LoRA | T4 (16GB) | β |
| NLLB-600M + LoRA | RTX 3090/4090 | β |
| NLLB-1.3B + LoRA | A10/A100 | β |
| Tower-7B + QLoRA | T4 (16GB) | β (tight) |
| CPU only | β | β οΈ Very slow |
If you hit OOM: reduce max_len β 192 or grad_accum β 3.
MIT. Training data has its own licenses (see table above).
Python
100.0%