Views
No views yet
enp_Latn).| Property | Value |
|---|---|
| Base Model | facebook/nllb-200-distilled-600M |
| Language Pair | English ↔ Pirate English |
| LoRA Rank | 16 |
| Training Epochs | 10 |
| Training Samples | 15000 (bidirectional) |
| Validation Samples | 600 |
| Hardware | NVIDIA T4 (16GB VRAM) |
| Training Date | 2026-07-29 |
| Metric | Score |
|---|---|
| BLEU | 78.29 |
| chrF++ | 88.23 |
1from transformers import AutoModelForSeq2SeqLM, NllbTokenizer
2from peft import PeftModel
3
4model_id = "facebook/nllb-200-distilled-600M"
5adapter_id = "MihaiPopa-1/NLLB-200-Distilled-600M-Pirate-English" # or local path
6
7tokenizer = NllbTokenizer.from_pretrained(model_id)
8# Add the custom language token (if needed)
9if "enp_Latn" not in tokenizer.additional_special_tokens:
10 tokenizer.add_special_tokens({"additional_special_tokens": ["enp_Latn"]})
11
12model = AutoModelForSeq2SeqLM.from_pretrained(model_id, torch_dtype=torch.float16)
13model.resize_token_embeddings(len(tokenizer))
14model = PeftModel.from_pretrained(model, adapter_id)
15model.eval()
16
17# Translate English → Pirate English
18def translate(text, src_lang="eng_Latn", tgt_lang="enp_Latn"):
19 tgt_token_id = tokenizer.convert_tokens_to_ids(tgt_lang)
20 tokenizer.src_lang = src_lang
21 inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
22 with torch.no_grad():
23 outputs = model.generate(**inputs, forced_bos_token_id=tgt_token_id, max_new_tokens=128)
24 return tokenizer.decode(outputs[0], skip_special_tokens=True)
25
26print(translate("Hello, world!"))@article{{team2022nllb,
title={{No Language Left Behind}: Scaling Human-Centered Machine Translation},
author={{NLLB Team} and others},
journal={{arXiv preprint arXiv:2207.04672}},
year={{2022}}
}}