Skip to main content

Tanglish pipeline: v1 (baseline) vs v2 (span-aware)

Evaluates the Tanglish pipeline v2 (open work: docs/todo/NOW.md). Reproduce:

uv run python scripts/build_tanglish_eval.py # set: tests/fixtures/tanglish/eval_v1.jsonl
uv run python scripts/eval_tanglish.py --stage spans # deterministic; needs the IndicXlit service
set -a; . ./.env; set +a
uv run python scripts/eval_tanglish.py --stage e2e # v1, v2 and ablations; raw: docs/eval/tanglish_e2e.json
uv run python scripts/eval_asr_tts.py --per-variant 60 # synthetic-speech ASR; raw: docs/eval/tanglish_asr_tts.json

Read this first: what these numbers are and are not​

  • The data is synthetic and unreviewed. It has 370 utterances (214 Tanglish, 78 Tamil-script, 78 English), generated from tests/fixtures/tanglish/phrasebank.yaml plus 30 hand-written hard cases. No Tamil-speaking clinician has checked the phrasing or the labels. It is not the release gate the TODO asks for.
  • Tuning leakage. I set the reranker (read-back weight, gemination handling, the common-word rule for places) while looking at words that also appear in the phrase bank (vali, illa, ratham, kitta, paati). The transliteration and span numbers are therefore optimistic until a held-out set exists.
  • Speech is TTS. The ASR analysis uses macOS say voices, not callers. Treat it as an upper bound.
  • LLM: end-to-end runs use DeepSeek (deepseek-flash) with 5 samples per utterance. The 95% intervals come from bootstrapping over utterances.

1. Language spans and transliteration (deterministic)​

Token language accuracy. v1 labels the whole utterance; v2 labels each token.

Subsetv1v2
Tanglish79.3% (macro-F1 0.24)98.7% (macro-F1 0.98)
Tamil script95.0%100%
English92.5%99.8%

Transliteration of the 1,306 romanised-Tamil words in Tanglish utterances (gold Tamil spelling):

MethodTop-1
v1: whole sentence through IndicXlit60.8%
v2: per word, beam order60.8%
v2: per word, Tamil-frequency rerank79.3%
v2: per word, read-back + frequency rerank88.4% (93.3% in the candidate list)
Negation words (இல்ல/இல்லை), n=40v1 0% (always இல்லா) → v2 100%

Preservation (kept as typed in the Tamil view):

v1v2
English words (n=190)0%97.9%
Numbers (n=74)0% (became Tamil numerals)100%
Place names (n=85)0%100%

The TODO's diagnostic sentence, nenju vali illa but moochu vidaradhu kashtam:

  • v1: நெஞ்சு வலி இல்லா பட் மூச்சு விடறது கஷ்டம்
  • v2: நெஞ்சு வலி இல்ல but மூச்சு {விடறது|விடரது} கஷ்டம், with every piece aligned to raw offsets. The gloss reads "No chest pain, but breathing is difficult."

2. End-to-end triage (LLM): Tanglish subset, n = 214​

Metricv1v2 (+ gloss)v2 (Tamil view only, default)v2 (gloss only)
Concept recall94.0 [90.3, 97.1]90.0 [85.7, 93.7]93.1 [89.4, 96.6]89.7
Concept precision89.5 [85.6, 93.0]90.292.6 [89.1, 95.8]90.1
Polarity accuracy88.4 [84.8, 92.1]86.589.1 [85.5, 92.7]85.1
Critical recall (policy severity)94.194.196.194.1
Critical caught (severity or human review)98.0100100100
Absent → present flips21.620.321.620.3
Present → absent flips0.00.00.00.0
Evidence cites the caller's words98.1100100100
Human-review rate22.930.823.825.2
p95 latency (s)11.94.12.93.0

Controls (v1 → v2 Tamil-view-only):

  • Tamil script: recall 94.3 → 95.9, polarity 88.5 → 89.4, absent→present flips 18.8 → 12.5.
  • English: recall 99.2 → 95.9 [91.0, 100]. The intervals overlap, but this is a 3-point drop worth watching before rollout.
    • Cause found (2026-10-02): eval-set artefacts, not a v2 regression. 2 of the 3 English misses are generated sentences no caller would say: "My father is pregnant and bleeding, age 59" and "has no bleeding but is pregnant and bleeding". v2 marked them uncertain, which is arguably the right answer. These rows and 10 others like them are now excluded (coherence_problems in scripts/build_tanglish_eval.py). Re-summarised without them (358 rows, same DeepSeek runs), v1 → v2 Tamil view only:

      SubsetRecallPolarityAbsent→presentPresent→absentCritical recallCritical caught
      Tanglish (207)94.0 → 93.588.7 → 89.320.8 → 20.80 → 093.5 → 95.797.8 → 100
      Tamil script (76)94.1 → 95.888.1 → 89.018.8 → 12.50 → 1.3100 → 94.1100 → 100
      English (75)99.1 → 99.198.1 → 99.10 → 00 → 0100 → 100100 → 100
    • Previously unreported: Tamil script has one v2 present→absent flip and one critical miss, both the negated-verb-is-the-symptom case. In ta-006, "எலும்பு ஒடையல, ஆனா மூச்சு விடல" (bone didn't break, but not breathing), v2 read fracture as present and breathing as absent, so severity was urgent; human review caught it. In ta-026, "பேசல கண் திறக்கல" (not talking, eyes not opening), v2 read unconscious as absent; the call still went critical with ALS via stroke signs. The polarity prompt (below) targets exactly this; the escalation list had no Tamil-script பேசல / கண் திறக்கல forms. They are now added (esc/0.2-draft, with wake-up paraphrases not in the eval set), so either sentence goes to a human with ALS even when the model reads it backwards. The first two forms come from the eval set, so escalation recall on these rows is optimistic.

Both keep 100% of critical cases caught.

What we learned, including what failed

  1. v2's first run lost 10 points of recall (94 → 85), and the cause was my own rule. Any close runner-up transliteration, or a case-only difference, demoted a finding to "uncertain". 29 of 34 misses came from that rule. The rule now demotes only on an actual disagreement: the language is unknown, or the model quoted a non-top reading. Case-only differences match the normalised view, which counts as the caller's own words.
  2. The IndicTrans2 gloss hurts more than it helps. Removing it raised recall, precision and polarity accuracy, and cut p95 latency from 4.1 s to 2.9 s. v2 now defaults to the Tamil view only (VAAZHVU_TANGLISH_VIEWS).
  3. The biggest remaining safety issue is not transliteration. About 20% of gold-absent concepts come back present in every configuration, v1 included: the LLM reads a denied symptom as present. All 20 v2 flips are fused verb negation (elumbu odaiyala, paambu kadikkala, thala suthala, moozhgala, நெஞ்சு வலிக்கல); separate negation words (illa, no) are already read correctly.
    • Fix implemented in v2, not yet measured. The grounded prompt explains fused negation and concepts that are themselves an absence, using example words that do not appear in the eval set. Each finding now quotes its denial before its status. A "present" finding that quotes a denial found in the caller's words is demoted to uncertain (polarity_self_contradiction), never to absent; for a red flag, policy R11 sends it to a human and adds ALS. The re-run is pending an LLM (DeepSeek returned HTTP 402 on 2026-10-02).
    • Rejected: a deterministic -ala suffix rule. The same ending is on 27 gold-present spans, all critical (moochu vidala not breathing, ratham nikkala bleeding won't stop, kai kaal velai seyyala). In emergency Tamil a negated verb is often the symptom.
  4. Present → absent flips stayed at 0 for v1 and every v2 configuration on this set. This is the direction that could hide a critical case.
  5. An outage of IndicXlit or IndicTrans2 keeps the raw text, marks spans uncertain, lowers input quality and sends the call to a human (policy R11). It never fabricates a normalised text. Unit tests cover this.

3. Speech recognition on synthetic speech (60 per variant)​

EnglishTamilSpoken Tanglish
CER, Tamil-hinted decode2%16%51%
CER, auto-detected language2%19%49%
Clinical phrase recovered98%85%55%
Auto-detect says Tamil / English—97%87% (10% Hindi, 2% Malay)
Hinted and auto decodes disagree on the clinical phrase0%0%1.7%

When Tanglish is spoken, Whisper writes the English words in Tamil script ("chest pain" → கட்சேச் பேன்). So spoken Tanglish reaches triage as Tamil script, and v2's English-preservation gains mostly benefit typed messages.

Change made from this: the voice line now detects Tamil or English per utterance. Anything else (Hindi, Malay) is re-decoded as Tamil, and the agent answers in the language the caller spoke (VAAZHVU_VOICE_LANGUAGE=auto). Previously a phone set to English forced Tamil speech into English.

Status against the TODO's release gate​

Not met. v1 remains the live default.

RequirementStatus
Provenance end to end (utterance/1, spans, aligned views, raw-offset citations, dispatcher UI)Done
Labelled eval set ≥ 300 / ≥ 150 TanglishDone, but synthetic and unreviewed
Clinical review of labels and phrasesNot done: needs Tamil-speaking clinicians
Real call audio, consented, ASR WER by conditionHarness done, real audio still needed: scripts/eval_asr.py reports WER and CER per engine, language and condition (Speech recognition). Current numbers come from synthetic TTS speech with added noise. Consented recordings (protocol in tests/fixtures/asr/README.md) are still needed.
"No critical finding lost to transliteration/translation; no high-risk negation flipped"Present→absent: 0. Absent→present: about 20% in v1 and v2 (LLM, not transliteration). Must be addressed before rollout.
Escalation-only phrase list reviewedNot done: config/escalation_phrases.yaml is a draft

Rollback: VAAZHVU_TANGLISH_PIPELINE=v1 (the default) restores the baseline path unchanged.

Known failure cases:

  • ah (Tamil particle ஆ) is read as English.
  • Some colloquial verbs fall outside IndicXlit's top 8 (kaichal → காய்ச்சல் is missing).
  • Loanwords like lorry are labelled Tamil (லாரி).
  • Mixed-script ASR output such as "मைலாப்" (Devanagari leaking into Tamil).