mclanorjeff/english-twi-nllb-lora
English to Twi NLLB LoRA Adapter
This repository contains a LoRA adapter fine-tuned for English to Twi translation. It was trained from facebook/nllb-200-distilled-600M using Ghana NLP's ENGLISH_TWI_PARALLEL_TEXT dataset.
Project Collaboration
This model was built and first published by McLanor Jeff under the personal repository mclanorjeff/english-twi-nllb-lora.
The shared collaboration version for the project team is available under the Lanor-and-Nick organization:
Lanor-and-Nick/english-twi-nllb-lora
That organization repository is used for collaborative access and team-facing updates while this personal repository remains the original author copy.
Model Details
- Task: English to Twi translation
- Base model:
facebook/nllb-200-distilled-600M - Adapter type: LoRA / PEFT
- Source language tag:
eng_Latn - Target language tag:
twi_Latn - Training hardware: NVIDIA RTX 2060, 6 GB VRAM
- Trainable parameters: 2,359,296 of 617,433,088 total parameters
Dataset
The training data comes from Ghana NLP:
- Dataset:
ENGLISH_TWI_PARALLEL_TEXT - Training examples: 5,475
- Validation examples: 608
- Source column: English text
- Target/reference column: Twi translation
The data was cleaned, encoding issues were repaired where possible, and a validation split was created before training.
Evaluation
Best validation checkpoint by BLEU: checkpoint-1000
Translation does not use ordinary classification accuracy because several Twi translations can be valid for the same English sentence.
Sample Outputs
Usage
from peft import PeftConfig, PeftModel
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
import torch
model_id = "mclanorjeff/english-twi-nllb-lora"
source_lang = "eng_Latn"
target_lang = "twi_Latn"
config = PeftConfig.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id, src_lang=source_lang, tgt_lang=target_lang)
base_model = AutoModelForSeq2SeqLM.from_pretrained(config.base_model_name_or_path)
model = PeftModel.from_pretrained(base_model, model_id)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
model.eval()
text = "Where are you?"
inputs = tokenizer(text, return_tensors="pt").to(device)
forced_bos_token_id = tokenizer.convert_tokens_to_ids(target_lang)
with torch.no_grad():
output = model.generate(
**inputs,
forced_bos_token_id=forced_bos_token_id,
max_new_tokens=192,
num_beams=5,
no_repeat_ngram_size=3,
)
print(tokenizer.batch_decode(output, skip_special_tokens=True)[0])Limitations
This model is useful for demos, learning support, and experimentation, but it is not a perfect translator. It may struggle with idioms, informal English, names, emotional nuance, rare Twi phrasing, or contexts far outside the Ghana NLP training data. Human review is recommended for high-stakes translation.
