EngineeringData

Automatic pinyin transliteration is harder than it seems

Leon·September 17, 2026·12 min
Text size
118%

Our human editor Qiqi checked every pinyin reading in 1,085 graded stories — 184,372 characters. We turned those checks into a benchmark and ran six systems against it, including two LLMs.

The corpus comes from Dengdeng, our graded reading app for stories from China. We review the pinyin before publication. Many readers use it while they are still learning to recognize characters, so an incorrect reading is a content error. We scored the full catalogue against the reviewed readings.

1. What the machine has to decide

Converting Chinese text to pronunciation is grapheme-to-phoneme conversion, or g2p. Text-to-speech systems have worked on it for decades. For most characters, there is only one possible pronunciation and getting it right is just a lookup: is yǒu wherever it appears.

But there are polyphonic characters (, duōyīnzì) — characters with more than one possible pronunciation. Context determines which pronunciation it should have. is xíng in "to walk" and háng in "bank". is dé, de, or děi depending on grammar.

Most polyphonic characters keep the same syllable and change only the tone. Of the 201 characters our system routes for disambiguation, 160 work this way:

  • — wéi "for" or wèi "because of"
  • — zhǒng "seed" or zhòng "to plant"
  • — jiāo "teach" or jiào "teaching"

The other 41 change the syllable itself — 25 of them also change the tone, and 16 change the syllable alone:

  • — xíng "to walk" or háng "bank"
  • — dì "ground" or de, the structural particle

In our catalogue, these 201 characters make up 24.7% of all text. Tone-only cases make up 62.6% of their appearances.

The corpus at a glance:

The ground truth at a glance. The scorer runs over every one of the 184,372 character positions; the 2,557 pairs are the distinct readings those positions draw on.

The most frequent character-and-reading pairs:

  • de — 5,261
  • le — 2,592
  • guó — 2,338
  • rén — 2,296
  • zài — 2,286

At the other end, 245 pairs appear exactly once — readings that occur a single time in the whole catalogue and still have to be right.

Pronunciation rules also change dictionary readings. In tone sandhi, bù becomes bú before a fourth tone, yī shifts to yì or yí, and two third tones change the first one. In dōngxi "thing", is unstressed. Dictionaries differ on whether to write xī or xi. A benchmark must account for these accepted variants.

2. What exists today

g2pM (Interspeech 2020) made this task easier to compare. It released CPP, a 99,264-sentence benchmark from Chinese Wikipedia, with one marked polyphonic character per sentence. Its package combined a dictionary pass with a compact neural classifier for the marked characters.

g2pW (Interspeech 2022) replaced that compact classifier with a Chinese BERT encoder. It adds two useful ideas: a learned soft weighting over the candidate readings, rather than a hard candidate mask, and a part-of-speech (POS) prediction task trained through the same encoder. The joint task teaches the model the relationship between a reading and its grammatical role. For many polyphones, knowing whether the character is acting as a noun, verb, or another part of speech rules out one of its readings. g2pW predicts zhuyin (bopomofo) first and converts to pinyin afterwards — the two notations map to each other one-to-one. Its released v2 checkpoint was a common starting point for downstream systems, including ours.

How targeted disambiguation works: the same character, two sentences, two pronunciations.

LLM systems use a different method. There are several ways to ask an LLM for pinyin as plain text; the one we test hands the model the sentence and asks for one JSON-array item per character. There is no explicit lookup, target marker, or candidate list. The model generates the annotations in sequence. The format matters more than it may seem. Echoing each character beside its reading, or converting word by word, would fix some alignment failures and introduce others — a model may emit a whole word where a single character is needed, or skip over punctuation. We picked one format among several, and each has its own alignment quirks. We kept the naive format on purpose — it is what a first attempt looks like — but it means the LLM rows partly measure formatting discipline.

How an LLM emits per-character pinyin one token at a time, and what happens to alignment on mixed text.

Real text is not a clean sequence of Chinese characters. It has money, dates, percentages, punctuation, English acronyms, and named entities. When the model hits a comma, it may give the comma its own slot, skip it, or shift everything that follows — and each of those choices changes the rest of the character-aligned array.

3. Runtime costs

g2pW's released checkpoint is 606MB with about 158.8 million parameters. Its PyTorch model can use a GPU for faster batches; the released ONNX package we benchmarked runs on CPU. Our latency comparison is also uneven here: we measured g2pW with its batch-of-one reference runner, built for offline conversion, against our production-configured pipeline. With batched GPU inference, g2pW would be considerably faster.

The LLMs use API calls. DeepSeek V4.1 Flash with reasoning averaged about 8 seconds per sentence across our corpus and cost $11 for the full run. Individual requests used between 200 and 10,000 completion tokens, mostly for reasoning. The long requests were not random: whenever a sentence contained anything slightly unusual — punctuation, symbols, Latin letters — the reasoning ballooned far beyond its usual size, and the traces show the model debating with itself over how to process those characters. Gemini Flash Lite was faster and cheaper.

4. How these models are evaluated, and the dataset problem

The standard benchmark lineage starts with CPP (Chinese Polyphones with Pinyin), which g2pM introduced, and continues with CVTE-poly (Interspeech 2023). CVTE-poly removed CPP sentences whose target character was not truly polyphonic and expanded the data to about 845,000 samples. These datasets trained the g2pW lineage and many later polyphone systems.

They have known limitations. The label distribution is imbalanced — a handful of high-frequency characters dominate. The sentences come from encyclopedic and news text, not from the colloquial, mixed-script text people actually read. And the benchmarks score a single target character per sentence, which is cleaner than real production, where every character of every sentence needs a reading at once.

We built a second test from 1,085 reviewed stories and 184,372 characters, carefully reviewed and corrected daily by our human editor Qiqi. It contains the exact text we publish, rather than a proxy for it. The corpus and scorer are internal for now.

5. Our transliteration model

Our pipeline starts with words. It segments a sentence with jieba, then checks multi-character tokens against CC-CEDICT. A token with one usable dictionary reading can supply its per-character pinyin. We skip known ambiguous word forms and send the remaining polyphonic characters to the model.

Our model is a BERT — Bidirectional Encoder Representations from Transformers — a Transformer encoder architecture from Devlin et al. (2019). The target character is marked with the special tokens "[unused1]" and "[unused2]" inside an n-character context window. It classifies the reading among roughly 700 pinyin syllables.

The model receives the target character in an n-character context window.

We do not hard-mask the final logits to the readings allowed for that character while training. A hard mask would prevent the classifier from expressing that a predicted reading is implausible in context. Instead, the model learns the constraint from examples. At runtime, a separate validity check rejects an impossible reading and falls back to the phrase-table result. This keeps the production output valid without hiding training mistakes from the model.

Training data: about 925,000 examples. 8,700 were synthetic sentences generated by DeepSeek-R1, at a rate of ten sentences per character-reading pair and three per dictionary word — and a human evaluator reviewed and repaired every generated example before it entered the training set. The rest come from a mixture of synthetic data reviewed by multiple LLMs, public research datasets and dictionary-derived word lists.

Some in-house examples are minimal pairs — a form of counterfactual data augmentation. We generate two synthetic sentences that stay almost the same, each grounded in a specific meaning of the target word. We then change just enough context to require a different reading of the target character. That forces the training task to depend on context instead of an easy character-level shortcut. A human evaluator reviews the generated examples before they enter the training set.

We maintain a routing list of 201 polyphonic characters. Those go to the model. Other characters keep the phrase-table reading, which is more reliable when a character has one common reading. It is an old trick, and it does a lot of heavy lifting in our scores: on positions outside the routing list the phrase-table path is 99.97% accurate — better than any system is on the polyphonic ones.

Our model has 102.2 million parameters (390MB as ONNX). g2pW's checkpoint has 158.8 million (606MB). It disambiguates a polyphonic sentence in 50–100 milliseconds on a cheap, CPU-only deployment. Because the model is small to load, we deploy it serverless, and the cost of a container starting up and loading the model is negligible.

6. The comparison

The test set contains the exact published text. For each system, we compare every character’s output with Qiqi’s approved reading.

Three caveats before the numbers — this comparison has asymmetries we cannot fully remove:

  • Locale. g2pW was trained on Taiwan Mandarin while we review mainland-standard pinyin, so part of its error total is locale and dialect mismatch rather than disambiguation failure.
  • Drift conventions. The drift bucket favors our pipeline by construction: our production system flags for review exactly the slots where sandhi or a dropped second syllable is legal — dōngxi with or without the full xī — and Qiqi’s review calibrated those conventions on this corpus. Pure tone errors and pure syllable errors get no such benefit.
  • Tuning on the test set. We did not train the model on this corpus, but we did adjust dictionary overrides and routing configuration after reading its mistakes, which makes the corpus a development set for the production system.

Let’s keep these asymmetries in mind while comparing results.

Automatic pinyin transliteration is harder than it seems table
SystemExactAcceptable driftTone errorsSyllable errorsTotal errorsAccuracy
Our pipeline (dictionary override + BERT model)183,49955618413331799.828%
DeepSeek V4.1 Flash (reasoning on)182,4551,58223210333599.818%
pypinyin181,7491,1709894641,45399.212%
g2pW/G2PW177,8152,9321,9601,6643,62498.034%
DeepSeek (reasoning off)160,9411,31626421,85122,11588.005%
Gemini 3.1 Flash Lite143,9921,03831339,02839,34178.662%

Table 2 — Per-character results against the reviewed corpus.

How to read the table:

  • Acceptable drift covers sandhi and neutral-tone variants the scorer accepts as context-dependent readings, not errors (see the caveats above).
  • g2pW produces 2,932 drift variants to our 556 — more than five times as many — so raw exact-match counts need context. Models also differ in whether they apply sandhi or neutral-tone dropping at all, and since the convention our pipeline uses is the one Qiqi accepts, this column carries an inherent advantage for us.
  • The reasoning-off LLM and Gemini mostly have syllable errors from alignment failures. pypinyin, our pipeline and g2pW concentrate their mistakes in the tone column.

Because most characters are trivial to read, the headline accuracy blends two regimes. Restricted to the 45,598 positions whose character is on the routing list — the positions that require disambiguation, defined identically for every system — the picture changes:

Automatic pinyin transliteration is harder than it seems table
SystemPolyphonic positions (45,598)All other positions (138,774)
Dengdeng pipeline99.399% (274 errors)99.969% (43)
DeepSeek V4.1 Flash (reasoning on)99.553% (204)99.906% (131)
pypinyin97.245% (1,256)99.858% (197)
g2pW/G2PW95.298% (2,144)98.934% (1,480)
DeepSeek (reasoning off)87.861% (5,535)88.053% (16,580)
Gemini 3.1 Flash Lite80.100% (9,074)78.190% (30,267)

Table 3 — Accuracy on the disambiguation positions, and on the rest of the text.

One caveat on those 45,598 positions. Only 149 characters take more than one reading anywhere in the corpus — 2,394 distinct characters against 2,557 approved character–reading pairs leaves no room for more. Of the 201 characters we route, 183 appear at all, and only 109 of those actually vary here; the other 40 varying characters sit outside the routing list and are read from the phrase table. Routing a character that never varies in this corpus is still the right call — the text we publish tomorrow is not this corpus — but the benchmark exercises a narrower slice of ambiguity than a 201-character routing list suggests. That is one more reason to quote these per-position numbers rather than character counts.

And split by whether the editor approved the character's default dictionary reading or a minority reading (10,188 of the 45,598 polyphonic positions; default means the base syllable of the first reading we list for the character):

Automatic pinyin transliteration is harder than it seems table
SystemDefault-reading positions (35,410)Minority-reading positions (10,188)
Dengdeng pipeline99.36% (226 errors)99.53% (48)
DeepSeek V4.1 Flash (reasoning on)99.45% (193)99.89% (11)
pypinyin96.62% (1,198)99.43% (58)
g2pW/G2PW97.35% (938)88.16% (1,206)
DeepSeek (reasoning off)87.94% (4,272)87.60% (1,263)
Gemini 3.1 Flash Lite79.91% (7,113)80.75% (1,961)

Table 4 — Polyphonic positions, split by whether the editor approved the default reading.

Three things stand out. DeepSeek with reasoning beats every dedicated system on the disambiguation positions — while the same model with reasoning off falls to 87.9% on them. Our pipeline is the flattest across both regimes. DeepSeek with reasoning is the best system on minority readings — 11 errors in 10,188 — and slightly ahead of us there, while we are near-perfect on the easy remainder. And g2pW collapses on minority readings (88.2%): its predictions carry a strong prior toward a character's dominant reading.

Which systems make the same mistakes

Shared mistake positions for each pair of systems. The matrix is symmetric, so only the lower half is drawn, and each system's own error total sits beside its name. The DeepSeek-no-reasoning and Gemini pair share 10,690 positions — alignment failures cluster across vendors.

Two patterns. The reasoning-off DeepSeek and Gemini configurations agree with each other more than with anyone else — 10,690 shared errors, by far the largest overlap in the matrix: when per-character alignment fails, it fails the same way for every LLM. And our pipeline's errors are the most idiosyncratic in the set — only 32 shared with its closest competitor, which is also why the 620 positions where our pipeline, DeepSeek, or both miss the approved reading — 317 + 335 − 32, read straight off the matrix — are worth mining: nearly every one is a labelled example at least one system has never seen.

Note: the g2pW row reads as hàn — a Taiwan Mandarin reading of the conjunction — 1,139 times. Excluding those cases leaves 2,485 errors on its 184,371 scored characters, or 98.652% — close to eight times our error rate. The row sums to 184,371 rather than 184,372 because one character was excluded as a suspected ground-truth error; the same applies to the Gemini row.

And the latency and hardware table:

Automatic pinyin transliteration is harder than it seems table
SystemParamsRuns onp50 per sentenceCost per corpus
Dengdeng pipeline102MCPU; serverless-friendly<100ms~$0 (idle scales to zero)
g2pW/G2PW158MCPU ONNX or GPU PyTorch; heavier offline model~6.7s (batch-1 CPU reference runner)free
DeepSeek (reasoning on)APIAPI~8s$11
DeepSeek (reasoning off)APIAPI~2s$0.73
Gemini 3.1 Flash LiteAPIAPI~1.2s≈$1 (est.)
pypinyin—CPU~0.1msfree

Table 5 — Model size, hardware, latency and cost.

The full catalogue can be scored in under an hour on ordinary CPU instances. The deployment has no compute cost between runs.

7. Error patterns

The totals do not show the full pattern of failure.

Our residual 317 mistakes are tone decisions on characters that only context can settle: in AI "teach people to work with AI" came out jiào where the editor wrote jiāo; "carefully approach" came out dì where it had to be neutral de. pypinyin's phrase table misses the same kind of thing — as fèn where the sentence wanted fēn.

g2pW's most common apparent error is a locale difference: it reads as hàn — a Taiwan Mandarin reading of the conjunction — 1,139 times. The mismatch goes beyond that character: g2pW was trained on Taiwan Mandarin, so , , and various tone conventions diverge as well, and the remaining 2,485 errors are probably still inflated. After excluding only the 1,139 cases, its error rate is close to eight times ours.

Gemini's errors are structural. On the sentence “SpaceX”, it read the Latin letters as pinyin: s, p, a, c, e, x — six syllables that no dictionary of Chinese contains. Elsewhere the alignment shifts instead: every reading after the foreign token lands one or more columns off, and the rest of the sentence is wrong with nothing to flag it. It scored 48.7% on sentences containing Latin or digits, 92.7% on clean ones.

DeepSeek's reasoning mode makes the difference. With reasoning on, it keeps the output aligned and reaches 99.818%. With reasoning off, it drops 11.8 accuracy points and produces 21,851 syllable errors, mostly from the same array-alignment failures seen in Gemini.

That protection is expensive. Reasoning used between 200 and 10,000 completion tokens per request: about 10 million tokens for this corpus, $11, and eight seconds per sentence. It is accurate enough for an offline batch, but the latency is unacceptable for a low-latency or real-time pinyin service. The error pattern suggests that much of the benefit comes from maintaining output alignment rather than better pronunciation decisions.

8. Why the last fraction matters

Even if we eventually reach 99.99%, one reading in 10,000 is still wrong. At this corpus size, that is about 18 wrong readings. Some are total nonsense: an earlier run produced r for , which is not pinyin. “Almost always right” is not enough for educational content.

Chinese g2p is not primarily a dictionary problem. Set the easy characters aside and what remains is a small contextual language-understanding problem surrounded by a large amount of deterministic bookkeeping. Specialized pipelines do well because they use each approach only where it is needed: a dictionary handles the readings it can settle, the model handles the characters that need context, and the constraint check catches anything impossible.

Read one

Dengdeng publishes a daily edition of graded stories from China, adapted to your level, pinyin on every word. One story from each daily edition is free in the app.

Browse today's edition.

References

1. Devlin, J., Chang, M.-W., Lee, K., Toutanova, K. "BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding." NAACL 2019. arXiv:1810.04805

2. Kyubyong Park and Seanie Lee. g2pM: A Neural Grapheme-to-Phoneme Conversion Package for Mandarin Chinese Based on a New Open Benchmark Dataset. Interspeech 2020. Paper · CPP dataset and package

3. Yi-Chang Chen, Yu-Chuan Chang, Yen-Cheng Chang, Yi-Ren Yeh. "g2pW: A Conditional Weighted Softmax BERT for Polyphone Disambiguation in Mandarin." Interspeech 2022, pp. 1926–1930. DOI: 10.21437/Interspeech.2022-216 · arXiv:2203.10430

4. g2pW toolkit (Apache-2.0), including the ONNX checkpoint benchmarked here. https://github.com/GitYCC/g2pW

5. Siheng Zhang, Xingjun Tan, Yanqiang Lei, Yuan Xie, et al. "CVTE-Poly: A New Benchmark for Chinese Polyphone Disambiguation." Interspeech 2023, pp. 5526–5530. DOI: 10.21437/Interspeech.2023-553 · Dataset

6. MDBG, CC-CEDICT. https://www.mdbg.net/chinese/dictionary?page=cc-cedict

7. mozillazg, pypinyin. https://github.com/mozillazg/python-pinyin

Also on the Blog

The Dengdeng app icon

Level up your Chinese.

Start with today’s story. Free on iOS and Android.

Download on the App StoreGet it on Google Play