Downloads · 30 days
7
22% of all-time downloads
mutaician/nllb-swahili-kalenjin-joint-v2
nllb-swahili-kalenjin-joint-v2 is a translation model from mutaician. Use it when you need text moved from one language to another. It is set up for peft. The card lists the license as cc-by-nc-4.0.
LoRA adapter for bidirectional Swahili–Kalenjin translation on facebook/nllb-200-distilled-600M at revision f8d333a098d19b4fd9a8b18f94170487ad3f821d.
Downloads · 30 days
7
22% of all-time downloads
All-time downloads
32
Public
Repo size
176 MB
Likes
0
Public
Click a slice to open those files.
.safetensors138 MB · 79%
From the Hugging Face model README
LoRA adapter for bidirectional Swahili–Kalenjin translation on
facebook/nllb-200-distilled-600M
at revision f8d333a098d19b4fd9a8b18f94170487ad3f821d.
This is the validation-selected epoch-13 joint checkpoint from a
deployment-informed redevelopment of a Swahili–Kalenjin translator. One adapter
covers both directions. The tokenizer includes a native kln_Latn language token
(id 256204).
This repository is the adapter only. It is not a complete model: load the pinned NLLB base, resize embeddings to the adapter tokenizer, then attach these weights.
Not intended as a certified public-service translator. Automatic metrics do not establish adequacy across Kalenjin varieties.
The adapter tokenizer is larger than stock NLLB because of kln_Latn. Skipping
resize_token_embeddings will fail or silently drop the native token.
import torch
from peft import PeftModel
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
ADAPTER = "mutaician/nllb-swahili-kalenjin-joint-v2"
BASE = "facebook/nllb-200-distilled-600M"
BASE_REVISION = "f8d333a098d19b4fd9a8b18f94170487ad3f821d"
tokenizer = AutoTokenizer.from_pretrained(ADAPTER)
base = AutoModelForSeq2SeqLM.from_pretrained(
BASE,
revision=BASE_REVISION,
torch_dtype=torch.float16,
device_map="auto",
)
base.resize_token_embeddings(len(tokenizer))
model = PeftModel.from_pretrained(base, ADAPTER)
model.eval()
def translate(text: str, src_lang: str, tgt_lang: str) -> str:
tokenizer.src_lang = src_lang
encoded = tokenizer(text, return_tensors="pt").to(model.device)
generated = model.generate(
**encoded,
forced_bos_token_id=tokenizer.convert_tokens_to_ids(tgt_lang),
num_beams=5,
max_length=256,
)
return tokenizer.batch_decode(generated, skip_special_tokens=True)[0]
print(translate("Habari yako?", "swh_Latn", "kln_Latn"))
print(translate("Chamgei?", "kln_Latn", "swh_Latn"))
Language tags: swh_Latn (Swahili), kln_Latn (Kalenjin).
Checkpoint selection used macro-average validation chrF across both directions. The clean test set was not used for selection. Scores below are the training-run evaluation on 6,666 exact-pair-disjoint unique test pairs per direction (beam 5, batch 4, max length 256).
| Direction | BLEU | chrF | chrF++ |
|---|---|---|---|
| Swahili → Kalenjin | 5.72 | 40.60 | 35.25 |
| Kalenjin → Swahili | 15.75 | 44.12 | 40.92 |
| Macro average | 10.74 | 42.36 | 38.09 |
SacreBLEU signature: nrefs:1|case:mixed|eff:no|tok:13a|smooth:exp|version:2.6.0.
Under a matched training budget, this joint adapter stayed within 0.15 macro chrF of two independently selected directional adapters while storing one adapter instead of two.
A later epoch-42 checkpoint scored higher on the same test set. That comparison was run after test inspection and is not this release.
| Item | Value |
|---|---|
| Base | facebook/nllb-200-distilled-600M @ f8d333a |
| Method | QLoRA training, LoRA inference adapter |
| Rank / alpha / dropout | 64 / 128 / 0.05 |
| Trainable parameters | 34,604,032 (including the native kln_Latn row) |
| Target modules | q_proj, k_proj, v_proj, out_proj, fc1, fc2 |
| Native token | kln_Latn = 256204, initialized from luo_Latn |
| Data | thinkKenya/kenyan-low-resource-language-data (kln_swa) @ 05cfaa75 |
| Train pairs | 17,776 unique pairs, concatenated 1:1 as 35,552 directional examples |
| Selection | epoch 13 / global step 14443, max macro validation chrF (42.742) |
| Seed | 42 |
Adapter selected for the IAAI application study From Benchmark to Pilot: Deployment-Informed Development of Swahili–Kalenjin Machine Translation. Use this repository, not the historical two-adapter Space, as the v2 model artifact.