融注音

The decision model

  1. Keyscase, Shift
  2. Rulestwo scores per key
  3. Modelbidirectional GRU
  4. Per keyChinese or English
  5. CompositionBlendKey

▲ Every key press reruns this on the keys not yet committed.

What it decides

Zhuyin keys sit on the same keys as Latin letters, so the same keys often spell both Zhuyin and English: ai is ㄇㄛ and also AI, 2 is ㄉ and also a digit. For every key in the composition, Rong Zhuyin decides Chinese or English; the Chinese part then goes to BlendKey’s character selection.

Why not rules alone

Rules say: keys that can’t form Zhuyin are English, words in an English dictionary are English. Without mistakes, good rules are already accurate. One mistyped key, though, breaks the Zhuyin and the rules turn that stretch into English. The model looks at the whole run of keys and recognises mistyped Zhuyin.

The model

InputEach key (with case), plus two rule-based scores: whether the key sits inside a valid Zhuyin syllable or a dictionary word, and how far apart the best “Chinese” and “English” readings of the whole run are (from word frequencies and an English letter model).
NetworkTwo bidirectional GRU layers of 128 units, reading up to about 60 uncommitted keys at once.
OutputThe probability that each key is Chinese. On commit or punctuation an end marker is added, so a half-typed syllable is no longer treated as unfinished.
SizeAbout 460k parameters, stored as 8-bit integers: about 0.5 MB.
SpeedAbout 0.6 ms per decision on Apple silicon (40 keys, excluding character selection).
RunsIn Swift, inside the input method on your Mac. No network.

Training data

About five million key sequences in total, trained on the author’s own machine (RTX 4090).

How it was tested

About 7,000 sentences the author actually typed and the model never saw (4,000 Chinese only, 2,000 mixed, 1,000 with numbers), replayed as key presses with the same typing habits. They are used only for testing. Share of sentences with every key right:

Rules onlyRules + model
Chinese only, no mistakes98.5%99.6%
Chinese only, 2% mistyped79.9%98.0%
Mixed, no mistakes95.2%95.2%
Mixed, 2% mistyped77.5%92.3%
With numbers88.1%88.0%

“Rules only” uses the same dictionary and English frequencies without the model. When the model says it is 90% sure, it is right about 90% of the time (calibration error 0.07%), so the input method can mark the places it is unsure about.

What it can’t do

Open source and data

Based on BlendKey (MIT); dictionary from McBopomofo (MIT); English word list from Bopomix (MIT). Training text from Wikipedia (CC BY-SA), Common Voice (CC0) and Taskmaster (CC BY 4.0); everyday sentences generated with Qwen (Apache 2.0).