You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Negara-G2P-v2 (Homograph-Disambiguated & Natural Pronunciation)

This model is an advanced, robust fine-tuned version of negara-g2p-clean-v2 specifically optimized for Persian Grapheme-to-Phoneme (G2P) conversion. It achieves state-of-the-art results in Contextual Homograph Disambiguation (رفع ابهام هم‌نگاشت‌ها) while consistently maintaining superior baseline phonetic precision without catastrophic forgetting.


📊 Scientific Benchmark & Evaluation

To evaluate the model rigorously without synthetic bias, we benchmarked the fine-tuned checkpoint against the base model using Cleaned Human Ground Truth (derived from the human-annotated HomoRich benchmark) alongside a specialized Homograph Disambiguation Test Suite (19 Contextual Pairs):

Model Name Homograph Accuracy (%) ⬆️ True PER (%) ⬇️ True WER (%) ⬇️ Latency (ms) ⚡
Base Model (negara-g2p-clean-v2) 63.16% 2.59% 8.62% 145.40 ms
Our Fine-Tuned Model (Optimal) 94.74% (+31.58%) 2.41% (Best) 8.33% (Best) 175.89 ms

🌟 Key Highlights:

  • +31.58% Absolute Leap in Disambiguation: Resolves highly ambiguous Persian homographs depending on syntax and surrounding semantic context (e.g., maskan [home] vs. mosakken [painkiller], keSti [ship] vs. koSti [wrestling], deh [village] vs. dah [ten], mohr [stamp] vs. mehr [affection]).
  • Zero Catastrophic Forgetting: Not only preserves base phonetic capabilities, but lowers the overall Phoneme Error Rate (PER: 2.41%) and Word Error Rate (WER: 8.33%) across general Persian text.
  • Optimized for Persian TTS Pipelines: Generates clean, consistent phonetic notation ideal for acoustic models (such as VITS, FastSpeech2, and Tacotron2).

🔍 Qualitative Comparison (Base vs. Fine-Tuned)

# Input Sentence (Persian) Base Model (negara-g2p-clean-v2) Fine-Tuned Model (Ours) Target Context / Meaning
1 کشتی بزرگی در دریا غرق شد. kaStiye bozorgi... keStiye bozorgi... Ship (keSti) vs. Wrestling (koSti)
2 از مسکن بیرون آمدم تا یک قرص مسکن خوردم. az mosakken ... qorse mosakken az maskan ... qorse mosakken Home (maskan) vs. Painkiller (mosakken)
3 فضای ده بسیار آرام بود و ده نفر بیدار بودند. fazAye dah ... faqat dah nafar fazAye deh ... faqat dah nafar Village (deh) vs. Ten (dah)
4 به سمت مزرعه رفت، مردی که سمت کدخدایی داشت. be samte ... samte kadkhodAi be samte ... semate kadxodAyi Direction (samt) vs. Job Title (semat)
5 حیوان درنده بود؛ شاید یک ببر! وسایلت را ببر! ... SAyad yek bebar! ... bebar ... SAyad yek babr! ... bebar Tiger (babr) vs. To Take (bebar)
6 در کشور قطر بود و لوله‌ای به قطر چند متر ساخت. keSvare qatar ... be qatar Cand metr keSvare qatar ... be qotre Cand metr Country Qatar (qatar) vs. Diameter (qotr)
7 او با کمال مهر به نامه‌ای مهر تایید زد. kamAle mehr ... mehre tayid kamAle mehr ... mohre ta'yid Affection (mehr) vs. Stamp/Seal (mohr)
8 به شدت مراقب عرض و آبروی دیگران بود. morAqebe arz va Abru morAqebe erz o Abru Honor/Dignity (erz) vs. Expressing (arz)

💻 Usage Example

import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

device = "cuda" if torch.cuda.is_available() else "cpu"
model_id = "jafarahmadi/negara-g2p-v2-homorich-disambiguated"

# Load tokenizer and fine-tuned model
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id).to(device)
model.eval()

# Sample text with homograph challenges
text = "کشتی بزرگی در دریا غرق شد و مسافران از مسکن خود دور شدند."

inputs = tokenizer(text, return_tensors="pt").to(device)

with torch.no_grad():
    outputs = model.generate(
        **inputs,
        max_length=256,
        num_beams=4,
        early_stopping=True
    )

phonemes = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(phonemes)
# Expected Output: keStiye bozorgi dar daryA qarq Sod va mosAferAn az maskane xod dur Sodand
Downloads last month
197
Safetensors
Model size
8.26M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Space using jafarahmadi/negara-g2p-v2-homorich-disambiguated 1