Finetuned from
oddadmix/Emhotob-25M, a tiny Llama-architecture
base (hidden 384, 8 layers, 6 heads, vocab 32000, tied embeddings).
Saved weights are the best checkpoint by validation loss (
eval_loss = 1.615). 20 samples
per direction with references are in
eval_bidirectional.json.
ChatML format. Pick the system prompt for the direction you want:
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "oddadmix/Emhotob-25M-Darija-MSA-v1"
5tok = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16).to("cuda").eval()
7
8SYSTEM = "أنت مترجم محترف. ترجم النص من الدارجة المغربية إلى اللغة العربية الفصحى."
9
10def translate(text, system=SYSTEM):
11 prompt = (f"<|im_start|>system\n{system}<|im_end|>\n"
12 f"<|im_start|>user\n{text.strip()}<|im_end|>\n<|im_start|>assistant\n")
13 ids = tok(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
14 if tok.bos_token_id is not None:
15 bos = torch.tensor([[tok.bos_token_id]], device=model.device)
16 ids["input_ids"] = torch.cat([bos, ids["input_ids"]], dim=1)
17 ids["attention_mask"] = torch.cat([torch.ones_like(bos), ids["attention_mask"]], dim=1)
18 out = model.generate(**ids, max_new_tokens=256, do_sample=False,
19 eos_token_id=tok.eos_token_id, pad_token_id=tok.pad_token_id)
20 return tok.decode(out[0, ids["input_ids"].size(1):], skip_special_tokens=True).strip()
A ~25.3M model: reliable on short/common sentences, but drift, repetition, and errors appear
on long or rare inputs. Gender is disambiguated only from context. For fluent translation use the
50M sibling.
Apache-2.0, inherited from the base model.