persian-g2p-0.6b
A high-accuracy, 596M-parameter (Apache-2.0) Persian (Farsi) Grapheme-to-Phoneme (G2P) model fine-tuned from Qwen/Qwen3-0.6B-Base on a strictly leak-free, deduplicated, CC0-1.0 version of MahtaFetrat/HomoRich-G2P-Persian with kasra-override augmentation.
For an ultra-fast 16 MB CPU model (8.26M params, MIT), see the sibling model: mehdi-hf/persian-g2p-tiny.
Highlights
- Best accuracy across WER, Homograph Disambiguation, and Ezafe F1 on strictly held-out
SentenceBench(400 rows, 0% test overlap — beating the publishedHomo-GE2PEbaseline even though the originalHomoRichrelease contained 403 overlapping SentenceBench rows). - Explicit ezafe markers (
-e/-ye) in standard unambiguous Repr. 1 (ketAb-e jadid-e man), with lossless conversion to IPA. - 100% Kasra (
ـِ) override — typing Persian kasra (بارانِ ریزی) deterministically forces ezafe. - Clean Apache-2.0 license — trained solely on CC0-1.0 data from an Apache-2.0 base model (no GPL datasets, no Parsivar).
Benchmarks (SentenceBench, 400 rows)
| Model | Params | License | Leak-Free? | Valid PER ↓ (4k) | SB PER ↓ | SB PER (glottal) ↓ | SB WER ↓ | Official Homograph ↑ (212) | All-Ambig Homograph ↑ (359) | Ezafe F1 ↑ (P / R) | Kasra Override | Speed (A100) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Baseline (Homo-GE2PE) | 8.26M | MIT | No (403 leaked) | — | 3.21% | 3.39% | 16.04% | 70.28% | 77.44% | 86.76% (84.2 / 89.5) | 10/10 | 43.7 s/s |
persian-g2p-tiny | 8.26M | MIT | Yes (0 leak) | 1.76% | 3.20% | 3.34% | 15.34% | 69.81% | 77.44% | 87.07% (80.0 / 95.5) | 10/10 | 49.5 s/s |
persian-g2p-0.6b (this) | 596M | Apache-2.0 | Yes (0 leak) | 1.44% | 3.18% | 3.35% | 14.79% | 72.17% | 80.50% | 88.89% (83.1 / 95.5) | 10/10 | 26.5 s/s |
Diacritic Support (ـَ fatha, ـِ kasra, ـُ damma)
After a 2,000-step continuation fine-tune on 256,000 balanced plain + kasra + internal-vowel diacritized examples, persian-g2p-0.6b supports all three short-vowel diacritics natively with zero BPE tokenization breakage:
- Word-final Kasra (
ـِ) ezafe override:10/10(100%) - Full Diacritic Suite (22 homograph & general word items): doubled from
8/22(36.4%) →16/22(72.7%) — includingاین گُل است(gol) vsاین گِل است(gel),او مَرد است(mard) vsاو مُرد(mord),قَدر(qadr) vsقَدَر(qadar),شِش(SeS) vsشُش(SoS),بَعد(ba?d) vsبُعد(bo?d), and full-sentence diacritics (خُداوَندِ مِهرَبان→xodAvand-e mehrabAn,گُلِ قِرمِز→gol-e qermez). - Plain Persian SentenceBench actually improved simultaneously: PER
3.24% → 3.18%, WER15.05% → 14.79%, Official Homograph71.70% → 72.17%. - Persian
ژ(/ʒ/→Z) fix (v2): Fixed GE2PE's; → Zmapping inHomoRich(recovering 7,253ژsentences) and fine-tuned to10/10(100%) cleanZoutput (شارژ → SArZ,انرژی → ?enerZi,پروژه → proZe,ژاپن → ZApon,پژوهش → paZuheS,رژیم → reZim,آژانس → ?AZAns; SentenceBenchPER 3.20%,All-Ambig Homograph 80.50%,Ezafe F1 88.23%).

Qualitative Homograph Wins vs. Baseline
| Persian Sentence | Homograph | Baseline (Homo-GE2PE) | persian-g2p-0.6b |
|---|---|---|---|
| من هر روز نان تست داغ میکنم | تست → tost | ... nAn-e test-e dAq mikanam | man har ruz nAn-e tost dAq mikonam |
| ملک و درباریان از در کاخ داخل شدند | ملک → malek | melk ... ?az dar kAx ... | malek va darbAriyAn ?az dar-e kAx dAxel Sodand |
| حیوان خانگی من دیروز در اثر گرما بیهوش شد و مرد | مرد → mord | ... bihuS Sod va mard | ... bihuS Sod va mord |
| قدری درهم و دینار نصیبش شد | درهم → derham | qadri darham ... | qadri derham va dinAr nasibaS Sod |
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
REPO = "mehdi-hf/persian-g2p-0.6b"
PROMPT = "Convert this Persian sentence to phonemes (Repr. 1 with -e/-ye ezafe):\n{text}\nPhonemes:"
tok = AutoTokenizer.from_pretrained(REPO)
tok.padding_side = "left"
if tok.pad_token_id is None:
tok.pad_token = tok.eos_token
model = AutoModelForCausalLM.from_pretrained(REPO, torch_dtype=torch.bfloat16, device_map="auto").eval()
def g2p(sentences: list[str]) -> list[str]:
prompts = [PROMPT.format(text=s) for s in sentences]
enc = tok(prompts, padding=True, truncation=True, max_length=512, return_tensors="pt").to(model.device)
plen = enc["input_ids"].shape[1]
with torch.no_grad():
out = model.generate(
enc["input_ids"],
attention_mask=enc["attention_mask"],
do_sample=False,
max_new_tokens=256,
pad_token_id=tok.pad_token_id,
eos_token_id=tok.eos_token_id,
)
decoded = tok.batch_decode(out[:, plen:], skip_special_tokens=True)
return [s.strip().split("\n")[0].strip() for s in decoded]
print(g2p([
"من هر روز نان تست داغ میکنم",
"بارانِ ریزی روی آسفالتِ خیس میبارد",
]))
# ['man har ruz nAn-e tost dAq mikonam',
# 'bArAn-e rizi ru-ye ?AsfAlt-e xis mibArad']
Converting Repr. 1 Output to IPA
REPR1_TO_IPA = {
"a": "æ", "A": "ɒː", "e": "e", "o": "o", "i": "iː", "u": "uː",
"p": "p", "b": "b", "t": "t", "d": "d", "k": "k", "g": "ɡ", "q": "q", "?": "ʔ",
"f": "f", "v": "v", "s": "s", "z": "z", "S": "ʃ", "Z": "ʒ", "x": "x", "h": "h",
"C": "tʃ", "j": "dʒ", "m": "m", "n": "n", "l": "l", "r": "ɾ", "y": "j",
}
def to_ipa(repr1: str) -> str:
return " ".join(
"".join(REPR1_TO_IPA.get(ch, "") for ch in w.replace("-", ""))
for w in repr1.split()
)
Phoneme Notation (Repr. 1)
| Symbol | IPA | Persian Sound | Example |
|---|---|---|---|
a | /æ/ | short a (ـَ) | dard (درد) |
A | /ɒː/ | long ā (آ / ا) | mAh (ماه) |
e | /e/ | short e (ـِ) | zehn (ذهن) |
o | /o/ | short o (ـُ) | zohr (ظهر) |
i | /iː/ | long i (ای) | miz (میز) |
u | /uː/ | long u (او) | dust (دوست) |
S | /ʃ/ | ش | Sahr (شهر) |
C | /tʃ/ | چ | Catr (چتر) |
Z | /ʒ/ | ژ | ZAle (ژاله) |
q | /q, ɣ/ | ق / غ | qazA (غذا) |
x | /x/ | خ | xAk (خاک) |
? | /ʔ/ | glottal stop (ع / ء) | ?omr (عمر) |
-e, -ye | /e/, /je/ | explicit ezafe suffix | ketAb-e man |
Training Details
- Base Model:
Qwen/Qwen3-0.6B-Base(Apache-2.0, 596M parameters). - Dataset:
MahtaFetrat/HomoRich-G2P-Persian(CC0-1.0), cleaned & deduplicated (423,769 base train + 41,742 kasra-augmented = 465,511 train; 4,000 valid; 0 SentenceBench overlap). - Training: Prompt-masked causal LM loss (target phonemes + EOS only), 1× NVIDIA A100-40GB, bf16 SDPA, length-bucketed batching, 2 epochs (7,274 steps, effective batch 128, AdamW
lr=1e-4cosine).
Credits & License
- License: Apache-2.0.
- Base Model: Qwen Team (
Qwen/Qwen3-0.6B-Base, Apache-2.0). - Dataset:
MahtaFetrat/HomoRich-G2P-Persian(CC0-1.0) by Mahta Fetrat Qharabagh, Elnaz Rahmati et al. (Fast, Not Fancy: Rethinking G2P with Rich Data and Rule-Based Models, arXiv:2505.12973).