Model details
Table | |
|---|
| Base model | qvac/TranslatePsy-AfriSLM-2B (Qwen3.5-2B, loaded with AutoModelForMultimodalLM, used text-only) |
| Adapter type | LoRA (PEFT) |
| Directions | English → am, ha, sw, yo, zu (one multilingual adapter) |
| Domain | Health / public-health information |
| Input granularity | Single sentences and multi-sentence passages (trained on sentences + 5-sentence chunks) |
| Developed by | Yabsera Yemanberhan |
| Code | https://github.com/Yabsera-Haile/Afri-Health-MT |
How to use
The adapter must be used with the exact prompt format it was trained on, and with thinking disabled.
import torchfrom transformers import AutoProcessor, AutoModelForMultimodalLMfrom peft import PeftModel BASE = "qvac/TranslatePsy-AfriSLM-2B"ADAPTER = "<your-username>/<this-repo>" # this repository processor = AutoProcessor.from_pretrained(BASE)tok = processor.tokenizertok.padding_side = "left"model = AutoModelForMultimodalLM.from_pretrained(BASE, dtype=torch.bfloat16, device_map={"": 0})model = PeftModel.from_pretrained(model, ADAPTER).merge_and_unload() # merge for faster generationmodel.eval() LANG = {"am": "Amharic", "ha": "Hausa", "sw": "Swahili", "yo": "Yoruba", "zu": "Zulu"} def build_prompt(text, tgt, src="en"): s, t = "English", LANG[tgt] system = (f"You are a professional {s} to {t} translator. " f"Your goal is to accurately convey the meaning and nuances of the " f"original {s} text while adhering to {t} grammar, vocabulary, and " f"cultural sensitivities. Produce only the {t} translation, without " f"any additional explanations or commentary. ") user = f"Please translate the following {s} text into {t}: {text}.\n\nTranslation:" return tok.apply_chat_template( [{"role": "system", "content": system}, {"role": "user", "content": user}], tokenize=False, add_generation_prompt=True, enable_thinking=False) prompt = build_prompt("Take two tablets twice a day for five days.", "sw")enc = tok([prompt], return_tensors="pt", add_special_tokens=False).to(model.device)stop = [tok.convert_tokens_to_ids("<|im_end|>"), tok.eos_token_id]with torch.no_grad(): out = model.generate(**enc, max_new_tokens=320, do_sample=False, eos_token_id=stop, pad_token_id=tok.pad_token_id)print(tok.decode(out[0, enc["input_ids"].shape[1]:], skip_special_tokens=True).strip())
Notes:
- The user template appends
. after the source text (this matches training; keep it).
- Use greedy decoding. Amharic needs roughly 3× more tokens per word than the other languages with this tokenizer: use
max_new_tokens ≈ 512 for Amharic sentences (≈ 1,200 for 5-sentence passages) and ≈ 320 for the other languages (≈ 900 for passages).
- Long inputs: the model was trained on up to 5-sentence passages (≤ 2,048 tokens including the prompt). For longer documents, translate sentence by sentence or in short passages.
Training
Data. AFRIDOC-MT health domain, train split, English → 5 languages:
- 35,199 sentence pairs (
health config) and 7,530 five-sentence chunks (doc_health_5), mixed and shuffled (42,729 examples in total, ≈8.5k per language).
- Light cleaning: Unicode NFC, removal of zero-width/control characters, whitespace normalisation; pairs with an empty side or identical source/target removed; examples longer than 2,048 tokens (with the prompt) removed.
- Validation: the AFRIDOC-MT validation split (sentences + chunks), used for loss and checkpoint selection. The test split was not used for training or selection.
Objective. Supervised fine-tuning on the chat-formatted prompt; the loss is computed only on the translation and its end-of-turn token (prompt tokens masked).
Hyperparameters.
Table | |
|---|
| LoRA | r = 16, alpha = 32, dropout = 0.05, bias = none, all linear layers of the text model (vision encoder frozen) |
| Trainable parameters | 16.8 M (0.75% of 2.23 B) |
| Optimiser / LR | AdamW, 1e-4, cosine schedule, 3% warmup |
| Batch | 4 per device × 16 gradient accumulation = 64 |
| Epochs | 2 (≈1,336 steps) |
| Max length | 2,048 tokens |
| Precision | bf16, activation checkpointing, length-grouped batching |
| Hardware | 1× NVIDIA A100 (80 GB), ≈5 h |
| Checkpoint | selected by chrF++ on a fixed 300-sentence dev subset |
Evaluation
Test set: AFRIDOC-MT health test split (61 documents, 1,982 sentences per language), English → African.
Protocol (as in the AFRIDOC-MT paper): outputs are realigned into the 61 full documents and scored with SacreBLEU (d-chrF, d-BLEU; default settings; 95% bootstrap confidence intervals, n = 1,000). Greedy decoding. Hypotheses and references are NFC-normalised.
Table with columns: System, am, ha, sw, yo, zu, Avg| System | am | ha | sw | yo | zu | Avg |
|---|
| GPT-4o (AFRIDOC-MT paper) | 36.7 | 64.2 | 79.8 | 29.3 | 69.0 | 55.8 |
| NLLB-200 3.3B, not fine-tuned (paper) | 53.0 | 65.2 | 76.7 | 43.8 | 70.7 | 61.9 |
| NLLB-200 1.3B, fine-tuned (paper, previous best) | 55.9 | 67.4 | 81.3 | 61.5 | 73.7 | 68.0 |
| NLLB-200 600M, not fine-tuned (ours) | 48.7 | 63.1 | 74.5 | 46.8 | 68.4 | 60.3 |
| TranslatePsy-AfriSLM-2B, zero-shot (ours) | 54.5 | 67.1 | 79.7 | 50.5 | 71.6 | 64.7 |
| This adapter | 55.8 ±1.5 | 67.6 ±1.8 | 83.1 ±0.5 | 61.7 ±1.0 | 74.4 ±1.6 | 68.5 |
Apart from Swahili, differences from the previous best are within the 95% confidence intervals: the adapter matches the state of the art at sentence level rather than clearly exceeding it.
Five-sentence passages — d-chrF
Table with columns: System, am, ha, sw, yo, zu, Avg| System | am | ha | sw | yo | zu | Avg |
|---|
| TranslatePsy-AfriSLM-2B, zero-shot | 52.2 | 65.3 | 79.3 | 40.9 | 70.7 | 61.7 |
| This adapter | 53.9 | 67.0 | 82.8 | 61.6 | 74.2 | 67.9 |
Translating 5-sentence passages costs the base model 3.0 d-chrF compared with sentence-by-sentence translation; with this adapter the drop is 0.6. (These are 5-sentence chunks and are not directly comparable with the paper's 10-sentence results.)
Safety and coverage checks (sentence level, averages over the 5 languages)
Table with columns: Check, NLLB-600M, Base, zero-shot, This adapter, References| Check | NLLB-600M | Base, zero-shot | This adapter | References |
|---|
| Numbers from the source kept (%) ↑ | 81.6 | 88.3 | 96.8 | 94.5 |
| Unit symbols kept (%) ↑ (approximate) | 69.4 | 67.1 | 88.4 | — |
| Wrong output language (%, GlotLID) ↓ | 2.26 | 1.85 | 1.78 | — |
| Cut off at the token limit (%) ↓ | 0.90 | 0.11 | 0.15 | — |
| Repetition loops (%) ↓ | 1.58 | 0.29 | 0.20 | 0.02 |
Other scores (sentence level, average): d-BLEU 34.6, chrF++ 57.5, SSA-COMET-QE 0.647 (base model: 0.659). The reference-free QE metric prefers the base model even though all reference-based metrics prefer the adapter; treat QE scores for these languages with caution.
Limitations and risks
- Clinical safety: automatic metrics do not measure clinical risk. Errors in drug names, doses, negation or diseases remain possible; a human clinical-risk evaluation is ongoing.
- Reference quality: AFRIDOC-MT references contain some errors and stylistic glosses (e.g. long explanatory phrases for medical terms in Amharic), which the adapter may reproduce.
- Amharic: the base tokenizer uses ≈6 tokens per Amharic word (vs ≈1 for NLLB), making Amharic slower; 2.2% of 5-sentence Amharic passages hit the generation limit in our evaluation.
- Wrong-language rate at sentence level (3–4% for Swahili and Zulu) is largely language-ID noise on short text; at passage level it is under 0.5%.
- Unit check only detects copied unit symbols; spelled-out units (e.g. Swahili miligramu) count as not kept.
- Single training run (one seed). Possible overlap between the base model's pre-training data and AFRIDOC-MT has not been ruled out.
- Directions: trained for English → African only; other directions are untested.
Intended use
Research on machine translation for African languages in the health domain, as a baseline or component (e.g. as a post-editor in a hybrid NMT + LLM pipeline). Suitable for drafting translations that a qualified human reviews. Not intended for unsupervised translation of patient-facing or clinical material.
Citation and references
If you use this adapter, please cite the AFRIDOC-MT paper and the TranslatePsy-AfriSLM paper:
- Alabi et al. (2025). AFRIDOC-MT: Document-level MT Corpus for African Languages. EMNLP 2025. arXiv:2501.06374
- TranslatePsy-AfriSLM: High-Quality Data Scaling For Low-Resource Machine Translation. EMNLP 2026. arXiv:2608.18655
Framework versions
- PEFT
- Transformers
- PyTorch