supra15_amharic_gec_v1g
Amharic Grammatical Error Correction (GEC): a 51.8M-parameter causal language model
fine-tuned on hayuLabs/Amh_gec_v1, built as the Amharic counterpart of the Oromo
supra15 GEC system. v1g is the strongest Amharic GEC checkpoint we have trained.
Model
| Base | ntily/supra15_amharic_fineweb2_clm_v1g |
| Arch | LlamaForCausalLM (hidden 512, 12 layers, 8 heads / 4 KV, FFN 1408, tied embeddings) |
| Params | 51.8M |
| Vocab | 32k byte-level BPE (Amharic-aware, trained on FineWeb-2 Amharic) |
| Context | 5,120 positions |
| dtype | fp32 weights (use fp16 on GPU for inference) |
Training
- Task framing: causal SFT, prompt
gec: {noisy}→ response{clean}</s>, loss on response tokens only. - Data:
hayuLabs/Amh_gec_v1train split (2.24M rows → 2.08M after exact-pair dedup). Validation:val_real(1,983 pairs). The cache used for training is 98.65% synthetic, 0.31% dictionary, and 1.04% real (21,662 unique real pairs) after an 8-character minimum and exact dedup. - Recipe: lr 5e-5 linear (3% warmup), batch 64, 58,400 steps, single Kaggle T4.
- Best validation loss: 1.4465 (step 56,400) (
eval_loss,val_real). - Tokenization convention (must be mirrored at inference): prefix and noisy sentence are
encoded piecewise (
encode("gec: ")+encode(noisy)) exactly as in training.
Usage
The repo ships gec_amharic_infer.py,
a small wrapper that applies the beam-search guard described below. It picks cuda / mps / cpu
automatically.
from gec_amharic_infer import GEC
gec = GEC("ntily/supra15_amharic_gec_v1g")
print(gec.correct("እኔ ትምህርት ቤት ይሄዳል።"))
print(gec.correct_batch(["የአዲስ አበባ ከተማ ሕዝብ ቁጥር አንድ ነው", "ሰወች በጣም ተደሰቱ"]))
Raw transformers equivalent, without the guard:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "ntily/supra15_amharic_gec_v1g"
tk = AutoTokenizer.from_pretrained(repo)
md = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.float16, device_map="cuda").eval()
def correct(noisy: str, num_beams: int = 4, max_new_tokens: int = 256) -> str:
prefix = tk.encode("gec: ", add_special_tokens=False)
ids = prefix + tk.encode(noisy, add_special_tokens=False)
x = torch.tensor([ids], device=md.device)
out = md.generate(
x, num_beams=num_beams, do_sample=False, max_new_tokens=max_new_tokens,
pad_token_id=tk.pad_token_id, eos_token_id=tk.eos_token_id,
)
return tk.decode(out[0, len(ids):], skip_special_tokens=True).strip()
print(correct("እኔ ትምህርት ቤት ይሄዳል።"))
Decoding guard. Beam search has one rare failure mode: on an input ending in .፧
(ASCII full stop immediately followed by the Ethiopic question mark) it can drop the first
clause and repeat the second until the token cap. The wrapper treats a sequence that reaches
max_new_tokens without ever emitting EOS as degenerate and re-decodes that row greedily,
then trims a trailing periodic run. It fires on 1 of the 2,995 test rows and leaves every
other prediction unchanged.
Head-to-head evaluation
All metrics computed by us on hayuLabs/Amh_gec_v1 test splits, fp16, beam search for our
model (4 beams) and each baseline's own decoding settings (v4: mT5-small, 4 beams,
max_length 192, no-repeat-3; v5.5: T5, greedy, max_length 192, no-repeat-3).
test_synth (n = 1,995)
| model | CER ↓ | CER reduction | EM ↑ | clean preserved ↑ |
|---|---|---|---|---|
| noisy baseline | 5.86% | — | — | — |
| v1 (52k, v1f base) | 2.80% | 52.3% | 46.7% | 80.9% |
| v1r (real-adapted) | 3.87% | 34.0% | 38.5% | 78.1% |
| ours (v1g, 58,400) | 2.71% | 53.9% | 47.4% | 84.7% |
| v4 (hayuLabs) | 3.33% | 43.2% | 38.6% | 73.8% |
| v5.5 (hayuLabs) | 3.02% | 48.6% | 39.3% | 79.8% |
test_real (n = 1,000)
| model | CER ↓ | CER reduction | EM ↑ |
|---|---|---|---|
| noisy baseline | 13.65% | — | — |
| v1 (52k, v1f base) | 13.01% | 4.7% | 0.4% |
| v1r (real-adapted) | 12.61% | 7.7% | 0.8% |
| ours (v1g, 58,400) | 12.98% | 4.9% | 0.1% |
| v4 (hayuLabs) | 10.96% | 19.7% | 6.3% |
| v5.5 (hayuLabs) | 11.91% | 12.7% | 4.4% |
Pooled CER over both splits: 6.14% for v1g, 6.21% for v1, 6.79% for v1r, 5.88% for v4,
5.99% for v5.5. This mixes two error distributions, so treat it as a secondary
summary; the per-split tables above are the primary result.
Beam-search guard. The published numbers include a decoding guard: if a beam search hits
max_new_tokens without emitting EOS, that row is re-decoded greedily (for GEC the output length
tracks the input length, so a cap hit is always degenerate). This repairs exactly one of the 2,995
test rows -- an input ending in .፧ where 4-beam search dropped the first clause and repeated the
second 17 times -- and changes no other prediction. Without the guard the same checkpoint scores
3.15% on test_synth and 6.43% pooled.
Raw predictions and the full report are in eval/.
Intended use
- Amharic GEC on news/administrative prose and on synthetic edits of the same.
- Research baseline for small Amharic GEC models.
Limitations
- The train cache is 98.65% synthetic and only 1.04% real. Real-text CER still trails the larger hayuLabs v4 model.
- The gold
test_realconventionው → ዉis under-represented in training; this model emitsዉfar less often than the gold data does. - Rare decoding failures: roughly 1 in 2,000 synthetic sentences triggers a beam-search repetition
loop that repeats a clause until the token cap. The shipped wrapper detects and repairs it; if you
call
model.generatedirectly, add the same cap-hit greedy fallback. - 51.8M params: limited world knowledge; it corrects surface form rather than rewriting meaning.