Add LESSONS_LEARNED_V1_5.md documenting all findings, fixes, and V2 rules
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859# Murli V1.5 Post-Mortem & Lessons Learned (`ViuAI/Murli-V1.5-Code`)
**Model:** Single-Speaker Hindi Acoustic Engine (`25.70M` params: RoPE TextEncoder + ConvNeXt Prosody/Prior + 12-block `384`-dim ConvNeXt-V2 OT-CFM + Vocos 24kHz)**Dataset Used:** `ViuAI/Murli_TTS_Dataset` → `bilingual_1000h/hindi_kalita` filtered to `kalita_rasa_male_01` (`6,774` clips = `12.88h`: `6,639` train / `135` val, `44.4 dB` mean SNR)**Stop Target:** `125,000` optimizer steps (`Val CFM` best = `0.2349` at Step `68,000`; `Prior Loss` ~`0.25–0.28`)
---
## 1. What V1.5 Fixed Compared to Murli V1.0 (`8.17M`)
Audio Naturalness Evaluation progression on held-out Hindi + numbers script (`50k → 75k → 100k`):- **Overall Score:** `6.5` → `6.7` → **`7.0 / 10`**- **Voice Texture & Clarity (`7.2 / 10`):** Eliminated V1's faint metallic Vocos buzz (`Val CFM` dropped from V1's `~0.52` plateau to **`0.2349`**; `Prior Loss` dropped from `~1.04` to **`~0.25`**).- **Pronunciation Accuracy (`7.3 / 10`):** Hindi G2P / IPA (`BilingualTextTokenizer`) + `<bos>`/`<eos>` + `min_frames=2` fixed V1's raw Devanagari failures (`बढ़ई`, `राघव`, `सम्मान`, edge character drops, and Hindi number expansion `12 साल`, `3.5 प्रतिशत`).
---
## 2. Problems Observed in Murli V1.5 (Root Causes & Status)
### A. Acoustic & Naturalness Gaps1. **Residual Robotic / Newsreader Tone (`Prosody & Emotion: 6.2 / 10`)** - *Root Cause 1 — Token-Constant Pitch Staircase ([prosody_aligner.py](models/prosody_aligner.py)):* `f0_predictor` and `energy_predictor` predict one `L1`-averaged scalar per phoneme token. Every frame inside a long vowel receives the exact same flat pitch value instead of a smooth intra-vowel pitch curve. - *Root Cause 2 — Pure Local ConvNeXt Receptive Field ([flow_matching.py](models/flow_matching.py)):* 12 ConvNeXt-V2 blocks (`kernel_size=7`, ~`0.75s` receptive field) lack global self-attention to shape multi-second sentence-level storytelling intonation arcs. - *Root Cause 3 — Inference CFG Over-Sharpening:* Default `cfg_scale=2.0` + `16` Euler steps over-accentuated harmonic peaks (creating a slight buzzy/robotic edge). Tuning inference to **`steps=48, cfg_scale=1.3, temperature=0.90, speed=0.92`** (`Natural Smooth` preset) noticeably smoothed out the buzzy edge without retraining. - *Attempted `temp=0.667` / `cfg=1.5` Regression:* Shrinking initial `x0` variance to `0.667` without Sway Sampling pushed early ODE steps out-of-distribution (`HF/LF` dropped `0.077 → 0.065`) and dulled clarity; reverted cleanly.
2. **Missing Natural Breathing & Inter-Sentence Transitions (`Breathing & Micro-Pauses: 5.8 / 10`)** - *Root Cause:* `narrate.py` split at every sentence boundary (`।`, `!`) and inserted dead `0x0000` digital zeros (`180–360ms`) + fade-in/out, creating artificial "studio-trimmed" transitions. - *Fix & Pitfall Learned:* Merging multiple sentences into one long chunk caused `!` / `।` rush-through and final-vowel clipping (`नमस्ते! आज → नमस्त्याज`, `लौटा। उसने → लौट उसने`). Keeping per-sentence splitting while replacing `0x0000` dead silence with a subtle `-68 dB` (`120ms`) room floor preserved crisp boundaries cleanly.
3. **Hindi Schwa Deletion Nuances (`लकड़ी → ləkəɽiː`, `मुरली → mʊɾəliː`)** - *Root Cause:* `hindi_word_to_ipa` kept an extra medial schwa `ə` in certain 3-syllable CVCV+long-vowel words (`mʊɾəliː` vs natural `mʊɾliː`). Kept frozen in V1.5 to avoid shifting phoneme targets mid-training on `100k–125k` weights; fix before V1.6 / V2.0 pretraining.
---
### B. Dataset & Labeling Issues4. **Speaker Fragmentation (`12.88h` vs `50h` Expected)** - *Root Cause:* Scanning only `shard-0` showed `kalita_rasa_male_01` made up `95%` of shard-0, but a full 28-shard metadata scan revealed `bilingual_1000h/hindi_kalita` (`58.53h` total) was split across **26 speakers**, with `kalita_rasa_male_01` concentrated in shards `0–8` (**`6,774` clips = `12.88h`**). - *Consequence:* On `6,639` train clips, `Val CFM` hit best (`0.2349`) by `Step 68k` and plateaued (`0.2360–0.2365` by `Step 74k`), making `300k–1M` step schedules overkill (`~483` epochs = `100k`, `~603` epochs = `125k`). - *Verified `~50h` Single-Speaker Alternatives Already on HF:* `hindi_50h` (`syspin_male_01`, `49.28h`, `53.1 dB` SNR) and `bilingual_1000h/hindi_female_iisc` (`iisc_f_hindi_female_spk001`, `46.63h+`, `50.0 dB` SNR).
5. **Unsupervised Emotion Conditioning (`neutral: 6639`, others `0`)** - *Root Cause:* `hindi_kalita` parquet shards lacked an `emotion` column, so every sample mapped to `0` (`neutral`) and `EmotionEmbedding` (`1..7`) received zero supervision.
---
### C. Engineering & Training Pipeline Bugs Found & Fixed During V1.56. **Random Batching Latency (`53–57 cl/s`, `11.7GB` VRAM) & Poisoned ETA:** Without duration bucketing, every batch of 32 padded to 15–18s clips, and `t_start`-based ETA included Epoch-1 cache creation. Fixed via deterministic pool-based length bucketing (`~80–99 cl/s`) + windowed ETA.7. **CLI Forwarding Gap (`--max_epochs` Ignored):** `grad_accum_steps`, `max_epochs`, `sample_every`, and `hf_sample_repo` were parsed by `argparse` but omitted from the config copy loop in `train.py` (capping epochs at `300` instead of `1200`). Fixed & verified.8. **Parquet Schema Aliases & Split/Cache Hygiene ([Murli_V15_Audit_Report.md](Murli_V15_Audit_Report.md)):** `hindi_50h` used `speaker`/`duration` while `bilingual_1000h` used `speaker_id`/`duration_s`; cache keys lacked `AudioConfig`/tokenizer hashes; and `train`/`val` splits lacked transcript disjointness. All resolved and covered by `tests/test_training_audit.py`.9. **Train/Infer Prosody Mismatch:** `forward_train` originally conditioned the CFM decoder on ground-truth frame `F0`/energy while inference used predicted token `F0`/energy; aligned both to predicted token prosody.
---
## 3. Rules to Carry Into V1.6 / Murli V2.01. **Always scan ALL shards' metadata (`speaker_id`, `duration_s`, `emotion`)** with `HfFileSystem` before committing to a single-speaker GPU run.2. **Use Frame-Level Prosody + Transformer/DiT Attention** (already present in Murli V2's DiT) for non-robotic storytelling intonation.3. **Refined Inference & Pause Handling:** Start ODE sweeps from `temp=0.90`, `cfg=1.3`, `steps=48` (`Natural Smooth`) instead of `cfg>=2.0`, and never splice `0x0000` dead silence between clauses.4. **Update Medial Schwa Deletion Rules** (`मुरली → mʊɾliː`, `लकड़ी → ləkɽiː`) prior to fresh pretraining.LESSONS_LEARNED_V1_5.mdAdded+59