Basics Β· Raw vs Intl.Segmenter("ja") Tokenization & IME Homophone Disambiguation Β· 18.01 MB WASM q8

Inside Japanese DeBERTa-v2: Wakati-gaki Boundaries & Homophone Context

ku-nlp/deberta-v2-tiny-japanese was pre-trained on Juman++ space-segmented (wakati-gaki) Japanese. Compare raw unsegmented text against native browser Intl.Segmenter("ja", { granularity: "word" }) side by side, then test how bidirectional attention flips kanji homophones (きしゃ, γ„γŒγ„, γ“γ†γˆγ‚“, γ‹γŒγ).

1. Raw vs Intl.Segmenter("ja") Tokenization Comparator

Raw #1 prediction–
Wakati #1 prediction–
Top-1 prob shift–
Entropy delta–
Token count delta–
NaN score check–

Raw Unsegmented Input (No Spaces)

–

Initialize model to compare raw unsegmented predictions.

Intl.Segmenter("ja") Wakati-gaki Input

–

Initialize model to compare wakati-gaki predictions.

2. Bidirectional IME Kanji Homophone Disambiguation Matrix

Each reading maps to multiple kanji candidates. DeBERTa-v2 scores the exact candidate token logits at [MASK] across contrasting Japanese contexts (8 live passes).

Contextual IME homophone candidate logit rankings across four Japanese readings
Reading Context Prompt Expected IME #1 Winner Candidate Logits Latency
Run the probe above to score all 4 Japanese homophone pairs live.

3. Inspect Wakati & IME Candidate Scoring Helpers

Show the code Β· deberta-ja-core.mjs β€” segmentJapaneseWakati()
Show the code Β· deberta-ja-core.mjs β€” normalizeFiniteCandidateScores()