The larger multilingual input-method model of Zhiyi IME: 16 ModernBERT layers of width 384 (the mmBERT-small tokenizer, 100,000 of its tokens kept) that read 256 tokens of context, one shared hashed n-gram memory table (2,000,003 rows × 64, stored as product quantization, 32 MB) and a 4-layer next-word decoder, in one ONNX file. It does three things:
char_logits), in Simplified
and Traditional Chinese and Japanese;你的作业|了吗, "your homework | yet?"), and, when asked for,
single characters (就, 要, 的 in Chinese, Traditional Chinese and Japanese, what phone keyboards offer
after a word).It replaces ML-pumpkin-1103 in this repository (1103 stays in its history and in its GitHub release). pumpkin is now built like Flash (ml-flash-next-1130): the same tokenizer, vocabulary, inputs, table, decoder and graph, with twice the encoder depth and twice the context. What is new against 1103:
Việt, Hà, Nguyễn).Against 1103 (PyTorch, this model as exported: the table as PQ16, the 100,000-row vocabulary): the neutral word-choice sets v2 / v3 / v4 / v5 94.90 / 94.22 / 92.03 / 76.48% (1103's released file: 93.53 / 93.84 / 90.89 / 72.47%); Simplified Chinese words 89.1% instead of 88.5%, long input 85.6% instead of 85.1%; Traditional pinyin 87.8% instead of 86.4%, Quick 3 81.9% instead of 79.5%, Japanese prediction 86.4% instead of 85.5%, Vietnamese first letters 75.6% instead of 73.4%; composition up by 0.7-2.9 points (whole rows) in all four sets. Lower: English word completion (85.6% instead of 87.1%), long Simplified Chinese web text (90.7% instead of 91.0%), Jyutping (90.7% instead of 91.0%) and the Japanese whole-sentence set (93.0% instead of 93.3%). Against Flash 1130, its smaller sibling: every neutral set higher (v5 +3.0), every next-word set higher (Simplified Chinese 14.9% instead of 14.3%, Japanese 15.2% instead of 14.0%), composition +1.9-4.3 points, word choice up to 1.7 points higher; English completion lower (29.5% instead of 31.8%), see the table cut below. Tables under "Accuracy".
The price is size and time: the w8 file is 131 MB (1103's laya.int8g.onnx: 83 MB; Flash 1130: 115 MB), the slim
file 106 MB, 32 MB of each being the table; about 1.8 times Flash's time per key (speed below). A preview:
Zhiyi IME does not use it. All Zhiyi models: https://github.com/dd1000001000/zhiyi_models
| File | |
|---|---|
model.safetensors |
all weights (213 MB): matrices F16, quantized to Q8_0 when loading (below) to get the accuracy measured here; the n-gram table as PQ16 codes + codebooks |
config.json |
the structure (with encoder.layer_types), prefix_mask, shared_head, next_word_decoder, special tokens, sequence settings (choice_context_tokens 256, composition_context_tokens 282), ml (language tags, typed-text length, tone stride), ngram (the table: its keys and hash), next_word (the decoder), vocabulary and quantize_q8_0: the tensors to quantize |
next_rows.json |
the decoder's rows (= the token table's rows): token ids, pieces, the six languages' masks (allow_*, first_*, cont_*), the end row, langs, cjk, lang_tags, context_tokens |
tokenizer.json |
mmBERT's tokenizer (Gemma vocabulary, 256,000 tokens), unchanged: vocab_remap maps its ids to the 100,000 rows |
unified_vocab.json |
the 3,805 units, 28 letters, 9,067 characters and the other tables; max_context_tokens 282 (composition, with its prefix), choice_context_tokens 256 |
test_vectors.safetensors |
16 word-choice / composition inputs and 18 next-word inputs (2 a language, 2 completions, 2 mid-text, 2 with single characters) with the PyTorch model's outputs, to check an implementation |
candle_ref/ |
a reference forward pass in Rust (candle 0.11), version 0.11.0 (the same code as Flash 1130's: it reads the depth and the layer types from config.json) |
onnx/int8/ |
laya.one.next.w8.onnx (131 MB): the one graph (word choice and composition with a KV cache, and the next-word decoder), with its tokenizer and JSON files |
onnx/slim/ |
laya.one.next.slim.onnx (106 MB): the same graph with the token table and the unit embeddings in 4 bits; same inputs and outputs |
example.py |
the quick start below |
LICENSE |
Apache License 2.0 |
1103's three graphs (laya.int8g.onnx, laya.one.int8g.onnx, laya.one.fused.int8g.onnx) have no 1202 counterpart:
the one graph does word choice and composition with a cache, and its context mode alone is that graph's first half.
Parameters. 216.0 M in all: the n-gram table 128.0 M (2,000,003 × 64, stored as 32 MB of PQ16 codes), the token table 38.4 M (100,000 × 384, also the decoder's read-out), the 16 encoder layers 33.0 M, the decoder 10.0 M, the head, the composition read-out and the other tables 6.6 M. (Hugging Face's own count reads the safetensors file, where the table is 32 M one-byte codes.)
Word choice, composition and next words with onnx/int8/laya.one.next.w8.onnx (the code is in example.py):
pip install onnxruntime tokenizers numpy huggingface_hub
python example.py
D = os.path.join(snapshot_download("zhiyi-ime/zhiyi-ml-pumpkin", allow_patterns=["onnx/int8/*"]), "onnx", "int8")
tok = Tokenizer.from_file(os.path.join(D, "tokenizer.json")) # context, tags, typed text and candidates
BOS, EOS, MASK = 2, 1, 4
# 1. Word choice: <bos> context <eos> | <mask> x syllables <eos> <mask> cand1 <mask> cand2 ... <eos>
# (context mode on the leading block, then key mode on the rest with that cache; each candidate's score is read
# at the <mask> before it; ctx_tail = the context's last two tokens, for the table's candidate keys)
print(choose("今天天气很好,我们去公园", ["san", "bu"], ["散步", "散布", "三部"]))
# 2. Composition: <bos> "已输入的上文: " + context <eos> | <mask> x syllables <eos>; one character per slot
print(compose("明天早上八点", "wo men zai xue xiao men kou jian mian".split()))
# 3. Next words: context mode once with need_cross (the context's and the table's keys and values), then is_step in
# a beam search
print(next_words("今天天气很好,我们一起去"))
print(next_words("Thank you very much for your", "en"))
print(next_words("今天天氣很好,我們一起去", "hant"))
print(next_words("我们明天去公", min_chars=1)) # completion: the typed start of the word ends the context
print(next_words("你的作业", right="了吗")) # mid-text: <bos> left <mask> right <eos>
print(next_words("他说下班以后", min_chars=1)) # single characters too (phones)
Output (ONNX Runtime 1.30.0, CPU):
[('散步', 1.20...), ('散布', -8.76...), ('三部', -9.49...)]
我们在学校门口见面
[('看看', -2.96...), ('旅游', -3.93...), ('游泳', -4.16...), ('逛街', -4.57...), ('玩玩', -4.69...)]
[('support', -1.98...), ('help', -3.07...), ('understanding', -3.19...), ('interest', -3.36...), ('attention', -3.69...)]
[('看看', -3.65...), ('湖州', -5.64...), ('山東', -5.94...), ('一場', -6.16...), ('湖邊', -6.48...)]
[('司', -1.33...), ('园', -2.11...), ('安', -3.06...), ('共', -3.09...), ('开', -3.36...)]
[('结束', -1.83...), ('完成', -2.55...), ('回来', -3.42...), ('做好', -3.62...), ('开始', -3.93...)]
[('要', -2.59...), ('就', -2.68...), ('会', -3.01...), ('我', -3.54...), ('还', -3.69...)]
The calls build the inputs of test_vectors.safetensors cases 0, 5, next0, next3, next4, next12, next14
and next16 (token for token); the int8 graph's words differ a little from the vectors' PyTorch ones (next0:
玩玩 in place of 玩耍; next4: 一場, 湖邊 in place of 海灘, 海邊, 湖州, 山東; next12: 开
in place of 馆; next16: 还 in place of 可以; the first word is the same in all of them). Japanese, Korean and Vietnamese work the same way (next_words(text, "ja"), "ko", "vi"): the
language's tag from next_rows.json lang_tags goes after <bos>. For the slim file, set PUMPKIN_DIR to a local
onnx/slim folder and GRAPH=laya.one.next.slim.onnx (same inputs and outputs); PUMPKIN_DIR alone (a local
onnx/int8) skips the download.
One input is_step (bool scalar) picks the mode; an If node runs only that mode's branch. Every input has a small
default, so ONNX Runtime lists them as overridable initializers, not as graph inputs (get_overridable_initializers());
feed them by name as usual and leave out what the mode does not use.
is_step false (the default): word choice and composition with a KV cache: input_ids, unit_ids, past_enc_k /
_v (16 × 1 × 6 × P × 64), past_choice_k / _v (2 × 1 × 6 × P × 64), past_mask, marker_pos, slot_pos,
ctx_tail (1 × 2: the context block's tokens at positions n−3 and n−2, before its <eos>; −1 when the block
has under 3 tokens) → logits, char_logits, present_0 … present_3 (the encoder's and the head's keys and
values), and cross_k_out / cross_v_out (4 × 1 × 6 × (T + 4) × 64) with cross_mask_out (1 × (T + 4), bool):
the decoder's cross-attention keys and values of the tokens just run and of the table's four positions, computed
only when the input need_cross (bool scalar, default false) is true. Run the leading block <bos> … <eos> once per
context (no past) to get the cache, then on each key only the rest with the cache as the past, marker_pos and
slot_pos counted from the start of the rest. Pass the same ctx_tail in both modes (context mode does not read
it): a candidate's first tokens and the first syllables are keyed on the context's last tokens in the table.need_cross true on <bos> [tag] encode(context)[last 256 tokens] <eos>
(mid-text: <bos> [tag] left <mask> right <eos>, below) with unit ids 0 (Korean, Vietnamese, English: the
context's trailing spaces cut first). This is the block word choice runs, so an input method gets the next word's
keys and values in the same call as its context cache.is_step true: one decoder step for N hypotheses: prev (N, the previous row; any value at position 0), pos
(N, 0 = start), dec_past_k / dec_past_v (4 × N × 6 × P × 64) with dec_past_mask (N × P) = the earlier steps (at
position 0 a placeholder of length 1 with the mask false), cross_k / cross_v / cross_mask = the context's, one
copy per hypothesis (cross_mask from cross_mask_out) → logits (N × 100,000 rows), present_0 / present_1 =
the decoder's keys and values with this step appended.Quantization: the encoder, head and decoder matrices are dynamic int8 (DynamicQuantizeMatMul); only the shared token
table is weight-only (MatMulNBits in blocks of 32: 8 bits in w8, 4 bits in slim, where the unit embeddings are 4-bit
too), and the inputs read their rows from the read-out's quantized weight, so the token table is stored once. The
n-gram table is stored once too, as its PQ16 codes, and every lookup (encoder keys, slot keys, the decoder's four
positions) reads it. The hashes run on the raw token ids (before zhiyi_vocab_remap), as in training.
Speed (ONNX Runtime 1.30.0, CPU, AMD Ryzen 5 9600X, median; pumpkin 1202 and Flash 1130 timed in turn in one process with the CPU otherwise idle, each with its own context: pumpkin 256 tokens, Flash 128; the search loop around the graph not counted; 300 pages of neutral v2, 300 Simplified and 300 English next-word test contexts):
| pumpkin 1202 w8 | pumpkin 1202 slim | Flash 1130 w8 | Flash 1130 slim | |
|---|---|---|---|---|
| Word choice, context mode (once per context), 4 threads / 1 thread | 8.90 / 14.49 ms | 8.88 / 14.92 ms | 4.73 / 7.93 ms | 4.73 / 7.90 ms |
| Word choice, a key, 4 threads / 1 thread | 6.91 / 9.99 ms | 6.92 / 10.30 ms | 3.87 / 5.52 ms | 3.74 / 5.48 ms |
| A whole next-word prediction, Chinese, 4 threads / 1 thread | 15.6 / 26.9 ms | 15.2 / 26.7 ms | 11.8 / 20.3 ms | 11.2 / 20.4 ms |
| A whole next-word prediction, English, 4 threads / 1 thread | 13.0 / 22.1 ms | 12.8 / 21.4 ms | 10.3 / 15.2 ms | 8.8 / 15.4 ms |
A key costs about 1.8 times Flash's (twice the encoder layers); a whole next-word prediction 1.3-1.45 times (the decoder steps are the same as Flash's).
Two stages on one rented RTX 5090, sharing the card with Flash 1130's training for more than half of the time.
min_chars picks whether single characters may end it), and every number here is of that graph.Names are the PyTorch ones. Matrices F16, vectors and the decoder's 1-D tensors F32.
| Tensor | Shape | |
|---|---|---|
encoder.embeddings.tok_embeddings.weight |
100000 × 384 | the kept rows (see vocab_remap); also the decoder's input table and read-out |
vocab_remap |
256000 | I32: token id → row (tokens outside the kept set → <unk>'s row, the last) |
encoder.layers.N.* (N = 0…15), encoder.* |
16 ModernBERT layers (attention Wqkv 1152 × 384, Wo; gated MLP Wi 2304 × 384, Wo 384 × 1152; norms) |
|
unit_emb.weight, tone_emb.weight, type_emb.weight |
as 1103 (type_emb[0] is the one used) |
|
head.layers.{0,1}.*, scorer.*, out.*, char_emb.weight, char_bias |
the shared head, word choice, composition | |
ngram.codes |
2000003 × 16 | U8: the table's PQ16 codes; row r = concat over p of ngram.codebooks[p, codes[r, p]] (64 values) |
ngram.codebooks |
16 × 256 × 4 | the PQ16 codebooks |
ng_proj (128 → 384), ng_sproj (128 → 384) |
the encoder-input projections of the token keys / the slot keys | |
next.mem_in.0 (384 → 384), next.mem_in.1 (LayerNorm) |
the decoder's memory | |
next.mem_proj (64 → 384), next.mem_norm (LayerNorm), next.mem_type |
4 × 384 | the decoder's four table positions |
next.tok_in (384 → 384) |
a row's embedding → the decoder's input | |
next.start |
384 | the input at position 0 |
next.pos.weight |
22 × 384 | learned positions |
next.layers.N.* (N = 0…3) |
nn.TransformerDecoderLayer: self_attn, multihead_attn (in_proj_weight = q, k, v stacked, 1152 × 384), linear1 (384 → 1536), linear2, norm1-norm3 |
|
next.out.0 (LayerNorm), next.out.1 (384 → 384) |
the decoder's output | |
next.bias |
100000 | the read-out's bias, one per row; −10000 on the rows no language writes |
The 104 tensors listed in config.json quantize_q8_0 (every linear weight of the encoder, the head, the table's
projections and the decoder) go to Q8_0: blocks of 32 along the input dimension, one f16 scale per block; so does the
decoder's read-out (the token table). With candle:
use candle_core::quantized::{GgmlDType, QMatMul, QTensor};
let w = safetensors.load(name, &device)?.to_dtype(DType::F32)?;
let w = QMatMul::from_qtensor(QTensor::quantize(&w, GgmlDType::Q8_0)?)?;
// w.forward(&x) = x · wᵀ, then add the bias if the layer has one
Keep the embeddings unquantized where they are indexed and everything 1-D in F32.
One sequence at a time, with the prefix mask: positions up to and including the first <eos> attend only to
themselves, in every encoder and head layer; the positions after them attend to everything.
x = tok_emb[vocab_remap[input_ids]] + unit_emb[unit_ids % 3833] + tone_emb[unit_ids / 3833] + ng(…), then
LayerNorm. ng is the table's part (all keys over the raw token ids; hash below):<bos>, before the first <eos>) and every candidate token (from
the first marker on, up to the final <eos>) adds ng_proj([row(k2); row(k3)]), k2 = hash(1; prev1, tok),
k3 = hash(2; prev2, prev1, tok); for a candidate's tokens prev1 / prev2 count from the latest marker at or before
the token, the context's last two tokens standing before it (that is what ctx_tail carries in the graph);ng_sproj([row(kb); row(kt)]),
kb = hash(5; u_prev, u) after a slot, else hash(7; c1, u); kt = hash(6; u_prev2, u_prev, u) after two slots,
hash(8; c1, u_prev, u) after one, else hash(9; c2, c1, u); c1 / c2 = the context's last / second-last token.full_attention), the others a window of ±64 (sliding_attention; config.json
encoder.layer_types); exact GELU in the gated MLP; no biases.h0 = encoder output + type_emb[0], then the two head layers (nn.TransformerEncoderLayer,
norm_first=True, 6 heads, feed-forward 1536, ReLU), with the prefix mask.score = scorer.3(gelu(scorer.1(scorer.0(h0[marker])))) at each candidate's <mask>. Higher is
better.char_logits = out.1(out.0(h0[slot])) · char_embᵀ + char_bias, compared within the characters the
slot's unit spells in the row's language.Caching the context. Run the block alone once per context and keep each layer's keys and values; on each key run only the positions after it.
<bos> [encode(tag)] encode(context)[last 256 tokens] <eos> with unit ids 0 (Korean,
Vietnamese, English: the context's trailing spaces cut first; mid-text: below), through the encoder:
m = LayerNorm(next.mem_in.0(encoder output + type_emb[0])), (T, 384), then four table positions:
next.mem_norm(next.mem_proj(row(key_j)) + next.mem_type[j]) for the keys around the gap g (the <mask>, else the
final <eos>): hash(1; l2, l1), hash(2; l3, l2, l1), hash(3; r1, r2), hash(4; l1, r1) (l1 = the token before the
gap, r1 the one after it; r1 / r2 −7 without a right side). Memory = (T + 4, 384). Each decoder layer's
cross-attention keys and values are the memory through rows 384-767 and 768-1151 of its
multihead_attn.in_proj_weight (and bias): once per context.next.start; position j ≥ 1 is next.tok_in(E[r_j]), E =
tok_embeddings, r_j the row written at step j; plus next.pos.weight[j].nn.TransformerDecoderLayer, norm_first=True, 6 heads of 64, LayerNorm eps 1e-5, no dropout):
x += self_attn(norm1(x)) causal; x += multihead_attn(norm2(x), memory); x += linear2(relu(linear1(norm3(x)))).logits = next.out.1(next.out.0(x)) · Eᵀ + next.bias over the 100,000 rows.Search (as example.py and candle_ref): beam 8, k = 5 words, at most 6 tokens a word; the language's masks from
next_rows.json (disallowed rows −10⁹ before the log-softmax):
zh), Traditional (hant), Japanese (ja): any allow_* row, then allow_* rows or the end. A
word is its rows' pieces joined (none of them starts with ▁), kept with at least 2 characters (min_chars 2), or
with single characters too (min_chars 1: completion, and the phone-style list where 就, 的 and words are ranked
together).en), Korean (ko): a first_* row (a ▁ word start) first, then cont_* rows (pieces) or the end.
Vietnamese (vi): a first_* row first, then any allow_* row (more ▁ syllables: words of several syllables)
or the end. The word is the pieces joined with ▁ as a space, stripped; English and Vietnamese lower-cased.allow_* row (Chinese, Japanese), a cont_* piece (English, Korean) or any allow_vi row; the
words found are the rest of the word.<bos> [tag] left <mask> right <eos> with right = encode(text after the cursor)[:32] and the left
side cut so that the block is no longer than without a right side (256 tokens of text); the words are the ones that
fit the gap.Token ids are tokenizer.json's, <bos> (2) as [CLS], <eos> (1) as [SEP], <mask> (4); text encoded without
special tokens. A row in Traditional Chinese, Japanese, Korean or Vietnamese starts with its tag as plain text
(<zh-Hant>, <ja>, <ko>, <vi>); Simplified Chinese and English have none. The composition prefix
已输入的上文: ("text typed so far: ") is literal model input; prefix and context together keep at most 282 tokens
(the prefix and the end of the context).
word choice (zh, en) <bos> encode(context)[last 256] <eos> <mask> × typed units <eos> <mask> encode(" 候选1")[:16] … <eos>
word choice (others) <bos> encode(tag) encode(context)[last 256] <eos> encode(typed text)[:24] <eos> <mask> encode(" 候选1")[:16] … <eos>
composition <bos> [encode(tag)] encode("已输入的上文: " + context)[≤ 282] <eos> <mask> × slots <eos>
next word <bos> [encode(tag)] encode(context)[last 256] <eos>
next word, mid-text <bos> [encode(tag)] encode(left)[last 255 − len(R)] <mask> R = encode(right)[:32] <eos>
test_vectors.safetensors: word-choice / composition cases i = 0…15 (i.input_ids full-vocabulary ids,
i.unit_ids, i.marker_pos, i.slot_pos, PyTorch's i.logits / i.char_logits); next-word cases nextN,
N = 0…17: nextN.input_ids (the prefix block), nextN.mode (the language's index in langs: 0 zh, 1 en, 2 hant,
3 ja, 4 ko, 5 vi), nextN.min_chars, nextN.comp (1 = completion; cases 12 and 13; 14 and 15 are mid-text, 16 and
17 Chinese with min_chars 1) and PyTorch's 5 words nextN.text (UTF-8, one a line) with nextN.logp. The Q8_0 model agrees with the word-choice and composition outputs to about 2.47 and picks the same best candidates and characters in 15 of 16 cases (case 6, jin tian tian qi zhen bu cuo with every character allowed: its last character is 错 in PyTorch and the Traditional form 錯 in the other three files; within the Simplified characters the syllable spells they agree); on the next-word cases it gives the same first word in 18 of 18, the same 5 words in 12. The w8 ONNX file: the same best in 15 of 16 cases (case 6) and the same first word in 12 of 18; the slim one: 14 of 16 (cases 6 and 7, a partly typed syllable j g) and 15 of 18.
The model alone, not the IME end to end. Spot checks of the shipped files against PyTorch fp32 (the model as
exported: the table as PQ16, the 100k vocabulary): the first 300 rows of each Traditional, Japanese, Korean and
Vietnamese test file and every third row of the Simplified Chinese and English sets; Q8_0 = this file through
candle_ref; w8 / slim = the two ONNX files. Next word: the first 200 rows of each language's test set, 100 words cut
inside (completion), 100 mid-text rows (Simplified, English) and 100 natural-mix rows with min_chars 1 (Simplified).
Small sets: a row is a third or half a point.
| Word choice, first candidate right | fp32 | Q8_0 (candle_ref) |
w8 ONNX | slim ONNX |
|---|---|---|---|---|
| Simplified Chinese, words and word pairs (2175) | 88.8% | 88.8% | 88.5% | 88.5% |
| Simplified Chinese, long input (749) | 86.9% | 86.9% | 87.3% | 87.0% |
| English (729) | 90.0% | 90.3% | 90.0% | 89.7% |
| Simplified Chinese, IME's real candidates (545) | 91.9% | 91.6% | 91.7% | 91.4% |
| Simplified Chinese homophones with the previous sentence (267) | 93.6% | 93.6% | 93.3% | 93.6% |
| English word completion (280) | 84.6% | 85.0% | 85.0% | 85.4% |
| Traditional, pinyin (luna_pinyin) (300) | 88.0% | 88.0% | 88.3% | 87.3% |
| Traditional, Zhuyin (bopomofo_tw) (300) | 89.7% | 90.0% | 90.0% | 90.0% |
| Traditional, Zhuyin (libchewing) (300) | 95.3% | 95.3% | 95.0% | 94.3% |
| Traditional, Jyutping (jyut6ping3) (300) | 89.7% | 89.3% | 89.3% | 89.3% |
| Traditional, Cangjie 5 (300) | 98.0% | 98.0% | 97.0% | 97.3% |
| Traditional, Quick 5 (300) | 90.0% | 90.0% | 91.0% | 90.0% |
| Traditional, Cangjie 3 (300) | 85.0% | 85.3% | 86.3% | 85.3% |
| Traditional, Quick 3 (300) | 79.3% | 80.0% | 78.7% | 79.0% |
| Japanese, conversion (Mozc) (300) | 94.0% | 94.0% | 94.0% | 94.0% |
| Japanese, prediction (Mozc) (300) | 88.3% | 88.7% | 89.0% | 88.7% |
| Japanese, whole sentence (Mozc) (300) | 95.7% | 95.7% | 94.7% | 94.7% |
| Korean, word completion (300) | 66.3% | 66.7% | 65.7% | 65.7% |
| Vietnamese, without diacritics (300) | 90.0% | 90.3% | 90.3% | 90.7% |
| Vietnamese, first letters (300) | 75.0% | 74.7% | 74.0% | 75.7% |
| Composition, whole rows / characters right | fp32 | Q8_0 (candle_ref) |
w8 ONNX | slim ONNX |
|---|---|---|---|---|
| Simplified, long pinyin in full (300) | 64.7 / 87.8% | 64.0 / 87.8% | 63.3 / 87.6% | 63.0 / 87.6% |
| Traditional, pinyin (300) | 44.3 / 75.1% | 43.7 / 74.7% | 43.3 / 74.1% | 43.3 / 74.5% |
| Traditional, Zhuyin (70% with tones) (300) | 71.3 / 93.1% | 71.7 / 93.2% | 73.0 / 93.3% | 70.7 / 92.9% |
| Traditional, Jyutping (300) | 42.7 / 75.5% | 42.0 / 75.0% | 42.0 / 74.6% | 42.0 / 74.6% |
| Japanese, kana (300) | 76.7 / 96.7% | 77.3 / 96.9% | 75.3 / 96.7% | 75.7 / 96.7% |
| Next word @1 / @5 | fp32 | Q8_0 (candle_ref) |
w8 ONNX | slim ONNX | first word = fp32's (Q8_0 / w8 / slim) |
|---|---|---|---|---|---|
| Simplified Chinese (200) | 18.5 / 30% | 18.5 / 30% | 17.5 / 29% | 17.5 / 29.5% | 97% / 77.5% / 72.5% |
| English (200) | 19.5 / 41.5% | 20 / 41% | 19 / 42% | 20 / 44.5% | 98% / 86% / 79.5% |
| Traditional Chinese (200) | 14 / 24% | 14 / 24% | 14 / 24.5% | 13.5 / 24% | 95.5% / 75.5% / 74% |
| Japanese (200) | 16.5 / 26% | 16 / 26% | 16 / 28% | 17.5 / 27.5% | 95% / 72% / 64% |
| Korean (200) | 8.5 / 17.5% | 8.5 / 17.5% | 9 / 16.5% | 10 / 16% | 95.5% / 79% / 72.5% |
| Vietnamese (200) | 27 / 45.5% | 27.5 / 45% | 26.5 / 44.5% | 26 / 46.5% | 98% / 84.5% / 83.5% |
| Completion, Simplified (100) | 58 / 74% | 58 / 74% | 57 / 76% | 57 / 75% | 100% / 90% / 88% |
| Completion, English (100) | 31 / 43% | 31 / 41% | 31 / 43% | 29 / 41% | 97% / 80% / 75% |
| Completion, Traditional (100) | 56 / 81% | 56 / 82% | 61 / 80% | 61 / 81% | 100% / 85% / 85% |
| Completion, Japanese (100) | 57 / 82% | 58 / 82% | 57 / 81% | 56 / 79% | 99% / 86% / 82% |
| Completion, Korean (100) | 35 / 57% | 35 / 57% | 34 / 56% | 34 / 56% | 98% / 86% / 79% |
| Completion, Vietnamese (100) | 67 / 84% | 67 / 85% | 68 / 83% | 65 / 86% | 97% / 88% / 88% |
| Mid-text, Simplified (100) | 20 / 39% | 21 / 39% | 20 / 32% | 22 / 36% | 98% / 72% / 72% |
| Mid-text, English (100) | 33 / 55% | 32 / 54% | 35 / 54% | 35 / 54% | 99% / 82% / 77% |
Any next unit, Simplified (min_chars 1) (100) |
27 / 39% | 27 / 40% | 25 / 40% | 22 / 38% | 98% / 80% / 72% |
The Q8_0 file follows PyTorch closely (the same first next word in 95-100% of rows); the int8 ONNX files move more (dynamic per-tensor int8 for the matrices: the same first word in 64-90% of rows), with set scores within about two points either way (mid-text Simplified @5: 32-36% against 39%).
On the full test sets, against ML-pumpkin-1103 and against Flash 1130 (PyTorch fp32; 1202 and Flash 1130 with their tables as stored, PQ16, and the 100,000-row vocabulary; first candidate right, the row's best):
| Word choice | pumpkin 1103 | Flash 1130 | pumpkin 1202 |
|---|---|---|---|
| Simplified Chinese, words and word pairs (6523) | 88.5% | 88.1% | 89.1% |
| Simplified Chinese, long input (2247) | 85.1% | 84.5% | 85.6% |
| Simplified Chinese web text, short / long (1001 / 344) | 92.0 / 91.0% | 92.1 / 91.3% | 92.4 / 90.7% |
| English (2189) | 89.9% | 89.3% | 89.9% |
| English web text (426) | 87.6% | 87.1% | 88.0% |
| Simplified Chinese, IME's real candidates (1634) | 89.4% | 89.1% | 90.3% |
| Simplified Chinese homophones with the previous sentence (800) | 90.9% | 90.4% | 92.0% |
| English word completion (840) | 87.1% | 85.8% | 85.6% |
| Traditional, pinyin (luna_pinyin) | 86.4% | 86.1% | 87.8% |
| Traditional, Zhuyin (bopomofo_tw) | 92.3% | 91.5% | 92.4% |
| Traditional, Zhuyin (libchewing) | 96.4% | 96.5% | 97.0% |
| Traditional, Jyutping (jyut6ping3) | 91.0% | 90.3% | 90.7% |
| Traditional, Cangjie 5 / Quick 5 | 95.7 / 90.1% | 95.6 / 89.8% | 95.8 / 90.3% |
| Traditional, Cangjie 3 / Quick 3 | 84.9 / 79.5% | 85.8 / 80.1% | 86.7 / 81.9% |
| Japanese, conversion / prediction (Mozc) | 92.8 / 85.5% | 92.2 / 85.5% | 92.9 / 86.4% |
| Japanese, whole sentence (Mozc) | 93.3% | 92.6% | 93.0% |
| Korean, word completion | 61.7% | 60.4% | 61.9% |
| Vietnamese, without diacritics / first letters | 90.7 / 73.4% | 90.8 / 74.5% | 91.2 / 75.6% |
(Traditional, Japanese, Korean and Vietnamese: 3,000 rows each.)
| Composition, whole rows / characters right (3,000 rows each) | pumpkin 1103 | Flash 1130 | pumpkin 1202 |
|---|---|---|---|
| Traditional, pinyin | 46.5 / 77.8% | 45.1 / 77.1% | 49.4 / 79.4% |
| Traditional, Zhuyin | 74.0 / 93.6% | 73.5 / 93.4% | 76.2 / 94.2% |
| Traditional, Jyutping | 42.3 / 73.9% | 41.1 / 73.4% | 43.0 / 74.7% |
| Japanese, kana | 69.7 / 95.5% | 68.1 / 95.4% | 71.4 / 95.9% |
Next words, the text's word first (@1) / among the 5 (@5), beam 8 (Simplified Chinese 4,941 rows, the others 3,000;
completion: the same rows with the word cut inside; mid-text: the rows whose text goes on after the word, that text as
the right side; "any next unit": the natural-mix test rows with min_chars 1, the text's real next unit as the answer,
split into those where it is a single character and those where it is a word). 1103 has no next-word decoder; Flash
1130 reads 128 tokens of context, pumpkin 256:
| @1 / @5 | Flash 1130 | pumpkin 1202 |
|---|---|---|
| Simplified Chinese | 14.3 / 25.8% | 14.9 / 27.1% |
| ... with ng1017 (the n-gram of Zhiyi IME) | 14.7 / 27.9% | 15.5 / 29.3% |
| English | 22.6 / 41.4% | 23.4 / 43.2% |
| ... with a trigram of the training text | 22.8 / 42.8% | 23.6 / 43.9% |
| Traditional Chinese | 13.7 / 23.9% | 14.7 / 25.4% |
| Japanese | 14.0 / 26.0% | 15.2 / 27.8% |
| Korean | 9.2 / 16.2% | 9.9 / 19.0% |
| Vietnamese | 19.3 / 36.9% | 20.5 / 38.2% |
| Completion, Simplified / English | 54.5 / 77.8%, 31.8 / 38.8% | 56.4 / 79.2%, 29.5 / 40.3% |
| Completion, Traditional / Japanese | 53.3 / 75.7%, 50.4 / 73.8% | 56.7 / 78.6%, 52.9 / 76.5% |
| Completion, Korean / Vietnamese | 25.2 / 48.1%, 56.3 / 75.2% | 27.5 / 51.0%, 58.6 / 75.6% |
| Mid-text, Simplified / English | 20.2 / 35.8%, 36.0 / 55.6% | 21.8 / 38.7%, 39.1 / 58.6% |
| Mid-text, Traditional / Japanese | 19.2 / 32.9%, 21.6 / 36.5% | 21.5 / 36.6%, 23.9 / 39.6% |
| Mid-text, Korean / Vietnamese | 13.2 / 22.6%, 34.4 / 54.0% | 16.4 / 25.5%, 36.4 / 57.2% |
| Any next unit, Simplified | 19.8 / 35.0% | 20.4 / 36.1% |
| ... single characters | 30.4 / 49.8% | 31.1 / 51.0% |
| ... words of two or more characters | 12.2 / 24.3% | 12.7 / 25.4% |
| Any next unit, Traditional (single characters / words) | 17.2 / 29.3% (25.9 / 10.5%) | 17.6 / 31.8% (25.2 / 11.8%) |
| Any next unit, Japanese (single characters / words) | 12.3 / 24.0% (24.6 / 10.5%) | 13.4 / 25.4% (24.9 / 11.7%) |
(The last two rows' brackets give @1 only.) Many continuations make sense and only the text's word counts, so the next-word scores are low; the teacher Qwen3-1.7B-Base (1.7B parameters, beam 32) gets 26.2 / 45.5% (Simplified Chinese) and 39.2 / 64.9% (English). English completion is the one set where the 100,000-row table costs pumpkin more than Flash (33.8% → 29.5% @1 against the full table; Flash 34.6% → 31.8%).
On the public neutral word-choice test sets (v2, v3 web, v4 chat, v5 hard; whole page, first candidate right):
| v2 | v3 | v4 | v5 | |
|---|---|---|---|---|
| ml-flash-next-1130, PyTorch fp32 (table PQ16) | 93.78% | 93.67% | 91.70% | 73.43% |
| ml-pumpkin-1202, PyTorch fp32 (table PQ16) | 94.90% | 94.22% | 92.03% | 76.48% |
ML-pumpkin-1103, int8 ONNX (laya.int8g.onnx) |
93.53% | 93.84% | 90.89% | 72.47% |
ml-flash-next-1130, int8 ONNX (onnx/int8) |
93.6% | 93.3% | 91.6% | 73.2% |
ml-pumpkin-1202, int8 ONNX (onnx/int8) |
94.8% | 94.1% | 92.0% | 76.3% |
The ONNX rows are the comparison scorer's (the charts below), the fp32 rows the training code's; the two count the same rows slightly differently. Paired over the four sets' 37,891 rows (fp32), pumpkin 1202 is right where Flash 1130 is wrong on 1,068 rows and the other way round on 767 (sign test p < 0.001).
candle_ref: candle's quantized kernels choose their SIMD code at compile time, so build with
RUSTFLAGS="-C target-cpu=native" (or at least x86-64-v3), otherwise the Q8_0 dot products run scalar code.
cd candle_ref
RUSTFLAGS="-C target-cpu=native" cargo build --release
target/release/zhiyi-ref ../model.safetensors ../test_vectors.safetensors out.safetensors
candle_ref runs the whole sequence with the mask (it does not cache) and reruns the decoder over each hypothesis'
prefix at every step; the outputs are those of the cached runs.
Each model alone (no engine, no n-gram add-on), on three tasks: the neural input-method models under 1B parameters we could run, and one large-model reference, Qwen3.5-2B-Base (zero-shot, run through VimeML's own search code). Of the Zhiyi models only the four maintained ones are shown: pumpkin (this model), Flash (zhiyi-ml-flash-0.2B), Mini (zhiyi-zhen-mini-12M) and Feather (zhiyi-zhen-feather), scored in PyTorch with the released weights, so the points can differ a little from the numbers above. Models far behind are left out and named under each chart. The word-choice models (the file of each, its license and how it is run) and their scoring code: https://github.com/dd1000001000/zhiyi_models/tree/main/comparisons/models
The composition and next-word sets are new (December 2026) and not published yet.
For each task the first chart ranks the models (bars from 0, with parameters and compute per row), the second puts the score against compute per row (log scale): green is the most attractive quadrant (at most the median compute and at least the median score), the dotted line the Pareto front (no other model at least as good on both axes). Word choice: the theoretical multiply-adds to score a row's candidates (the context once, then each candidate). Composition and next word: the multiply-adds of each model's own pipeline (its search and beams), counted with PyTorch's FLOP counter on a sample of about 100 rows per set; pipelines that rerun whole sequences are counted as with a KV cache. N-gram table lookups are not counted.
These weights are Zhiyi IME's own work and are licensed under the Apache License 2.0 (LICENSE). The reference
code in candle_ref/ is GPL-3.0-only, like Zhiyi IME (https://github.com/dd1000001000/zhiyi_ime/blob/main/LICENSE).
The upstream parts keep their licenses: the Laya architecture (https://huggingface.co/convaiinnovations/laya)
Apache-2.0, the mmBERT-small encoder and tokenizer (Marone et al., 2025; https://huggingface.co/jhu-clsp/mmBERT-small)
MIT. The n-gram table follows the idea of hashed n-gram embeddings read beside a transformer (Engram-style conditional
memory); the design and the code here are Zhiyi's own.
Teachers (only their scores and words were used; none of their weights are in these files): Qwen3.5-9B (https://huggingface.co/Qwen/Qwen3.5-9B) fine-tuned with LoRA for word choice and composition, Qwen3-1.7B-Base (https://huggingface.co/Qwen/Qwen3-1.7B-Base; Simplified Chinese, English) and Qwen3-4B-Base (https://huggingface.co/Qwen/Qwen3-4B-Base; Traditional Chinese, Japanese, Korean, Vietnamese) for next words and mid-text, all by the Qwen team (Alibaba Cloud), Apache-2.0. Next-word text: Chinese text of C4 (Raffel et al.) and LCCC, English text of FineWeb (CC-MAIN-2025-26) and C4, and FineWeb-2 (Penedo et al., ODC-By) in the other languages; the next words segmented with jieba (Chinese), SudachiPy (Japanese) and pyvi (Vietnamese). The short-context word-choice rows: candidates from several input-method engines run on the typed letters (only their candidate lists were used). These programs and data only produced training rows; none of them is in these files.
model.safetensors 203 MiBonnx/int8/laya.one.next.w8.onnx 125 MiBonnx/slim/laya.one.next.slim.onnx 101 MiBtest_vectors.safetensors 1 MiBjhu-clsp/mmBERT-small