Views
No views yet
facebook/nllb-200-distilled-600M using Ghana NLP's
ENGLISH_TWI_PARALLEL_TEXT dataset.mclanorjeff/english-twi-nllb-lora.Lanor-and-Nick/english-twi-nllb-lorafacebook/nllb-200-distilled-600Meng_Latntwi_LatnENGLISH_TWI_PARALLEL_TEXTcheckpoint-1000| Metric | Value | Interpretation |
|---|---|---|
| BLEU | 26.9278 | Decent/useful translation quality for a low-resource pair. |
| chrF | 50.5380 | Strong useful character-level similarity for Twi spelling/morphology. |
| Eval loss | 1.4805 | Lower is better; validation error improved during training. |
| English input | Twi output |
|---|---|
Where are you? | Ɛhe na wowɔ? |
For this reason, many people are interested in it. | Esiane eyi nti, nnipa pii ani gye ho. |
The students learn very well because they want to improve their future lives. | Asuafoɔ no sua adeɛ yie ɛfiri sɛ wɔpɛ sɛ wɔn daakye asetena tu mpɔn. |
1from peft import PeftConfig, PeftModel
2from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
3import torch
4
5model_id = "mclanorjeff/english-twi-nllb-lora"
6source_lang = "eng_Latn"
7target_lang = "twi_Latn"
8
9config = PeftConfig.from_pretrained(model_id)
10tokenizer = AutoTokenizer.from_pretrained(model_id, src_lang=source_lang, tgt_lang=target_lang)
11base_model = AutoModelForSeq2SeqLM.from_pretrained(config.base_model_name_or_path)
12model = PeftModel.from_pretrained(base_model, model_id)
13
14device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15model.to(device)
16model.eval()
17
18text = "Where are you?"
19inputs = tokenizer(text, return_tensors="pt").to(device)
20forced_bos_token_id = tokenizer.convert_tokens_to_ids(target_lang)
21
22with torch.no_grad():
23 output = model.generate(
24 **inputs,
25 forced_bos_token_id=forced_bos_token_id,
26 max_new_tokens=192,
27 num_beams=5,
28 no_repeat_ngram_size=3,
29 )
30
31print(tokenizer.batch_decode(output, skip_special_tokens=True)[0])