AfriE5 Twi query encoder (v3, score distillation)
Query encoder for Twi → English retrieval. Encode questions with this model and passages with the original
McGill-NLP/AfriE5-Large-instruct (the passage space is unchanged).
from sentence_transformers import SentenceTransformer
q_model = SentenceTransformer("prince4332/AfriE5-twi-query-encoder-v3")
p_model = SentenceTransformer("McGill-NLP/AfriE5-Large-instruct")
prompt = "Instruct: Given a question, retrieve Wikipedia passages that answer the question\nQuery: "
q = q_model.encode(["Kasa bɛn na nnipa dodow no ara ka wɔ Uganda?"], prompt=prompt, normalize_embeddings=True)
p = p_model.encode(["Languages of Uganda. In Uganda the most spoken local language is Luganda ..."], normalize_embeddings=True)
print(q @ p.T)
Training
English questions (Natural Questions, TriviaQA, SQuAD, GooAQ; sampled to favour low keyword overlap) translated to
Asante Twi with facebook/nllb-200-3.3B and kept only if their back-translation matches the original. The base model,
given the English question, scores the answer passage and 7 hard negatives; this model learns to
reproduce those scores from the Twi question (listwise KL distillation; passages frozen), plus a light Twi–English
alignment term on the GhanaNLP corpus. Final weights = 1.0 × trained + 0.0 × base.
No AfriQA data was used for training or model selection. NLLB-200 is CC BY-NC 4.0: research use.
AfriQA Twi test (nDCG@10, strict; passages encoded by base AfriE5)
| setting | base | trained | gemini_ref |
|---|---|---|---|
| Twi→Eng | 67.5 | 71.7 | 68 |
| Twi (standard ɛ/ɔ)→Eng | 68.3 | 72 | 70 |
| Twi (no ɛ/ɔ)→Eng | 63.4 | 70.2 | 63 |
| Eng→Eng (ref) | 87.7 | 87.3 | 89.6 |