A small Chinese / English input-method model of Zhiyi IME: 8 ModernBERT layers of width 256 (the mmBERT-small tokenizer) that do three things:
char_logits), through the head word choice uses;It is zh-lite-next-preview-1120 (itself zh-lite-next-preview-1116 with the memory table and single-character next words) with composition trained. A preview: Zhiyi IME does not use it yet. The GitHub release model-zhen-feather-preview-1121 also has the 4-bit phone set, and its release notes have every test result. All Zhiyi models: https://github.com/dd1000001000/zhiyi_models
| File | |
|---|---|
model.safetensors |
all weights, unquantized (143 MB, full token table; the memory table's PQ codes are 16 MB of it) |
config.json |
the structure (encoder.layer_types, prefix_mask, shared_head, compact, char_count, next_word with memory_table), special tokens, sequence settings, ml (tags, tone stride) and quantize_q8_0: the tensors to quantize |
tokenizer.json |
mmBERT's tokenizer (256,000 tokens): context, tags, typed text |
tokenizer.candidates.json |
the same with Metaspace prepend_scheme never: candidates, Chinese and English (no leading ▁) |
unified_vocab.json |
the slot units and letters, the 9,067 composition characters (chars, the order of char_emb) and the readings that say which characters a unit can spell |
next_rows.json |
the decoder's 102,464 output rows: token ids, pieces, each row's text and characters, the mode masks (zh, en_start, en_cont), the end row |
test_vectors.safetensors |
13 word-choice, 6 composition and 15 next-word inputs with the fp32 ONNX model's outputs |
candle_ref/ |
a reference forward pass in Rust (candle 0.11), version 0.8.1 |
onnx/int8g/ |
the desktop ONNX graphs, int8, token table pruned to 116,118 rows: laya.int8g.onnx (word choice and composition, whole graph), laya.one.int8g.onnx / laya.one.fused.int8g.onnx (the same with a KV cache), laya.next.context.int8w.onnx + laya.next.step.int8w.onnx (next words), with their tokenizers and JSON files |
LICENSE |
Apache License 2.0 |
Word choice, composition and next words with the int8 graphs of onnx/int8g/ (the same code as example.py):
pip install onnxruntime tokenizers numpy huggingface_hub
import json
import os
import numpy as np
import onnxruntime as ort
from huggingface_hub import snapshot_download
from tokenizers import Tokenizer
D = os.path.join(snapshot_download("zhiyi-ime/zhiyi-zhen-feather", allow_patterns=["onnx/int8g/*"]), "onnx", "int8g")
tok = Tokenizer.from_file(os.path.join(D, "tokenizer.json")) # context, typed text
ctok = Tokenizer.from_file(os.path.join(D, "tokenizer.candidates.json")) # candidates (no leading ▁)
vocab = json.load(open(os.path.join(D, "unified_vocab.json"), encoding="utf-8"))
BOS, EOS, MASK = 2, 1, 4
UNIT = {u: i for i, u in enumerate(vocab["units"])} # "f:san" = the full syllable san, "p:s" = typed only partly
def enc(text):
return tok.encode(text, add_special_tokens=False).ids
def session(name):
return ort.InferenceSession(os.path.join(D, name), providers=["CPUExecutionProvider"])
laya = session("laya.int8g.onnx")
def run(ids, units, markers, slots):
"""The whole graph. No markers = a composition row: marker_mask false, no candidate vector anywhere."""
feed = {"input_ids": np.array([ids], np.int64), "attention_mask": np.ones((1, len(ids)), np.int64),
"unit_ids": np.array([units], np.int64), "marker_pos": np.array([markers or [0]], np.int64),
"marker_mask": np.array([[bool(markers)] * len(markers or [0])]), "slot_pos": np.array([slots or [0]], np.int64)}
logits, char_logits = laya.run(["logits", "char_logits"], feed)
return logits[0], char_logits[0]
# 1. Word choice: <bos> context <eos> <mask> x syllables <eos> cand1 cand2 ... <eos>; one score per candidate
def choose(context, syllables, cands):
ids = [BOS] + enc(context)[-128:] + [EOS]
units = [0] * len(ids)
for s in syllables:
ids.append(MASK)
units.append(UNIT[f"f:{s}"])
ids.append(EOS)
markers = []
for c in cands:
markers.append(len(ids)) # the candidate's first token: where the score is read
ids += ctok.encode(c, add_special_tokens=False).ids[:16]
ids.append(EOS)
units += [0] * (len(ids) - len(units))
scores, _ = run(ids, units, markers, None)
return sorted(zip(cands, scores.tolist()), key=lambda x: -x[1])
print(choose("今天天气很好,我们去公园", ["san", "bu"], ["散步", "散布", "三部"]))
# 2. Composition (Simplified, full pinyin): one character per syllable, among those the syllable can spell
CHARS = vocab["chars"]
SPELL = {}
for i, c in enumerate(CHARS):
for r in vocab["readings"].get(c, []): # Simplified readings (Traditional / Jyutping tables: vocab["ml"])
SPELL.setdefault(r, []).append(i)
def compose(context, syllables):
head = enc(vocab["context_prefix"]) # "已输入的上文: " (literal text, see the README)
body = enc(vocab["context_prefix"] + context)
if len(body) > 160: # keep the prefix and the end of the context, 160 tokens in all
body = head + body[len(body) - (160 - len(head)):]
ids = [BOS] + body + [EOS]
units = [0] * len(ids)
slots = []
for s in syllables:
slots.append(len(ids))
ids.append(MASK)
units.append(UNIT[f"f:{s}"])
ids.append(EOS)
units.append(0)
_, char_logits = run(ids, units, None, slots)
out = ""
for s, row in zip(syllables, char_logits):
allowed = SPELL[s]
out += CHARS[allowed[int(np.argmax(row[allowed]))]]
return out
print(compose("明天早上八点", "wo men zai xue xiao men kou jian mian".split()))
# 3. Next words: the context graph once, then the step graph's beam search over next_rows.json's output rows
ctx_g, step_g = session("laya.next.context.int8w.onnx"), session("laya.next.step.int8w.onnx")
R = json.load(open(os.path.join(D, "next_rows.json"), encoding="utf-8"))
END, MAXTOK = R["end"], R["max_word_tokens"]
ZH = np.full(len(R["tokens"]), -1e9, np.float32)
ZH[R["zh"]] = 0
ZH[END] = 0
def next_words(context, k=5, beam=8, min_chars=2):
"""Chinese mode: words of Simplified Han rows, at least min_chars characters (1: single characters too)."""
ids = [BOS] + enc(context)[-128:] + [EOS]
ck, cv, cm = ctx_g.run(None, {"input_ids": np.array([ids], np.int64), "attention_mask": np.ones((1, len(ids)), np.int64)})
beams, done, cache = [(0.0, [], 0)], {}, None
for step in range(MAXTOK + 1):
if not beams:
break
n = len(beams)
if step == 0:
pk = np.zeros((ck.shape[0], n, ck.shape[2], 1, ck.shape[4]), np.float32)
past = (pk, pk, np.zeros((n, 1), bool))
else:
r = [b[2] for b in beams]
past = (cache[0][:, r], cache[1][:, r], cache[2][r])
lg, k_, v_ = step_g.run(None, {
"prev": np.array([b[1][-1] if b[1] else 0 for b in beams], np.int64), "pos": np.full(n, step, np.int64),
"past_k": past[0], "past_v": past[1], "past_mask": past[2],
"cross_k": np.repeat(ck, n, 1), "cross_v": np.repeat(cv, n, 1), "cross_mask": np.repeat(cm, n, 0)})
cache = (k_, v_, np.concatenate([past[2], np.ones((n, 1), bool)], 1))
x = lg + ZH
lp = x - x.max(-1, keepdims=True)
lp -= np.log(np.exp(lp).sum(-1, keepdims=True))
if step == 0:
lp[:, END] = -1e9 # a word has at least one row
if step == MAXTOK:
lp[:, np.arange(lp.shape[1]) != END] = -1e9
nxt = []
for j, (base, seq, _) in enumerate(beams):
for i in np.argsort(-lp[j], kind="stable")[:beam]:
v = float(lp[j, i])
if v < -1e8:
continue
if i == END:
if sum(R["chars_zh"][t] for t in seq) >= min_chars:
w = "".join(R["text_zh"][t] for t in seq)
done[w] = float(np.logaddexp(done.get(w, -1e9), base + v))
else:
nxt.append((base + v, seq + [int(i)], j))
beams = sorted(nxt, key=lambda b: -b[0])[:beam]
best = sorted(done.values(), reverse=True)[:k]
if len(best) >= k and (not beams or beams[0][0] < best[-1]):
break
return sorted(done.items(), key=lambda x: -x[1])[:k]
print(next_words("今天天气很好,我们一起去"))
Output:
[('散步', 1.68...), ('散布', -5.97...), ('三部', -6.85...)]
我们在学校门口见面
[('看看', -3.02...), ('旅游', -3.59...), ('逛逛', -5.07...), ('南宁', -5.25...), ('玩玩', -5.72...)]
It builds the inputs of test_vectors.safetensors cases 0, 5 and next0; the int8 graphs' outputs differ a little from
the vectors' fp32 ones (next0's fifth word, for one). Traditional rows add the tag <zh-Hant> after <bos> (see
"Inputs").
One RTX 5070 Ti, from zh-lite-next-preview-1120, the whole model: 230k steps of composition rows (128 a step: ML-Flash-1103's
6.96 million Simplified, Traditional and Cantonese phrase rows, half on Qwen3.5-9B's soft scores, half on the text, plus
386k rows mined so that every Simplified character has 100 examples, hard labels), word-choice rows (64 a step) and
next-word rows (96 a step) together, then 20k steps polishing word choice (128 a step, composition 32 at half weight).
1120's file had the composition weights (out.*, char_bias) but never trained them.
Names are the PyTorch ones. F16: the encoder, head.*, scorer.*, type_emb, char_emb and the decoder's matrices
and next.pos; F32: unit_emb, tone_emb, cand_emb, out.*, char_bias and the decoder's other float tensors. The
weights are the trained ones, except that the decoder's matrices are rounded to F16 and its memory table is stored
product-quantized.
| Tensor | Shape | |
|---|---|---|
encoder.embeddings.tok_embeddings.weight |
163856 × 256 | the kept token rows (see vocab_remap) |
vocab_remap |
256000 | I32: token id → row; the 92,144 tokens not kept → <unk>'s row |
encoder.embeddings.norm.weight |
256 | LayerNorm, no bias |
encoder.layers.N.attn_norm.weight (N ≥ 1; layer 0 has none) |
256 | |
encoder.layers.N.attn.Wqkv.weight |
768 × 256 | N = 0…7 |
encoder.layers.N.attn.Wo.weight |
256 × 256 | |
encoder.layers.N.mlp_norm.weight |
256 | |
encoder.layers.N.mlp.Wi.weight |
1024 × 256 | |
encoder.layers.N.mlp.Wo.weight |
256 × 512 | |
encoder.final_norm.weight |
256 | |
unit_emb.weight |
3833 × 256 | row 0 = none, 1-3804 the units of unified_vocab.json, 3805-3832 the letters |
tone_emb.weight |
6 × 256 | Zhuyin tones: row 0 = none, 1-5 (5 = neutral) |
type_emb.weight |
3 × 256 | only row 0 is used |
cand_emb |
256 | added at each candidate's first token |
head.layers.0.* |
one nn.TransformerEncoderLayer |
|
scorer.0 (LayerNorm), scorer.1 (256 → 256), scorer.3 (256 → 1) |
word choice | |
out.0 (LayerNorm), out.1 (256 → 256) |
composition | |
char_emb.weight |
9067 × 256 | the 9,067 characters' token-embedding rows (unified_vocab.json chars order) |
char_bias |
9067 | composition |
next.mem_in.0 (256 → 384), next.mem_in.1 (LayerNorm) |
the decoder's memory | |
next.tok_in (256 → 384) |
an output 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 → 256) |
the decoder's output | |
next.rows |
102464 | I32: each output row's row of tok_embeddings (its token: next_rows.json tokens) |
next.bias |
102464 | the read-out's bias |
next.mem_codes |
1000003 × 16 | U8: the memory table's rows, each 16 parts of 4 values, a part one of 256 centroids |
next.mem_books |
16 × 256 × 4 | the centroids of each part |
next.mem_proj (64 → 384), next.mem_type (4 × 384), next.mem_norm (LayerNorm) |
a table row → one memory position |
The ONNX files keep 116,118 token rows (tokens seen at least 50 times in the word-choice contexts, 3 times as candidates or 100 times in the next-word contexts); this file keeps all 163,856.
The 66 tensors listed in config.json quantize_q8_0 (every linear weight but scorer.3) go to Q8_0: blocks of 32
along the input dimension, one f16 scale per block; so does the decoder's read-out tok_embeddings[next.rows]. Keep the
embeddings unquantized where they are indexed (the decoder's input table too) and everything else in F32. This gives
the accuracy measured below. 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
Token ids are tokenizer.json's (full-vocabulary ids; the remap happens in the model): <bos> (2) as [CLS], <eos>
(1) as [SEP], <mask> (4). Encode without special tokens: the context, a tag and typed text with tokenizer.json,
candidates with tokenizer.candidates.json, each cut to 16 tokens (an empty one: <unk>). In word choice and
next words, a <mask> in the text is replaced by a space first. A Traditional row starts with the tag <zh-Hant> as plain text; Simplified
Chinese and English have none. Positions that carry no unit have unit 0.
Word choice, Simplified Chinese (pinyin) and English:
<bos> encode(context)[last 128 tokens] <eos> <mask> × typed units <eos> cand(candidate 1)[:16] cand(candidate 2)[:16] … <eos>
Each <mask> carries its unit in unit_ids: a pinyin unit of unified_vocab.json units (f:san the full
syllable, p:s one typed only in part), or for English one <mask> a typed letter, unit 3805 + its index in
letters (lower case, at most 24). marker_pos lists each candidate's first token.
Word choice, Traditional Chinese (pinyin, Zhuyin, Jyutping, Cangjie, Quick): the typed code as text instead of units (cases 8-15 show each scheme):
<bos> encode("<zh-Hant>") encode(context)[last 128 tokens] <eos> encode(typed text)[:24] <eos> cand(candidate 1)[:16] … <eos>
Composition (Simplified pinyin, full, initials or mixed; Traditional pinyin, Zhuyin with or without tones, Jyutping), at most 24 slots:
<bos> [encode("<zh-Hant>")] encode("已输入的上文: " + context) <eos> <mask> × slots <eos>
The prefix 已输入的上文: (literal text, "typed context: "; config.json context_prefix) is encoded together
with the context; if that is longer than 160 tokens, keep the prefix's own tokens and the last tokens of the rest, 160
in all. slot_pos lists the slots; each slot carries its unit: pinyin f: / p:, Jyutping jf: / jp:, Zhuyin the
syllable's pinyin unit + 3833 × tone (tone 1-5, 5 = neutral; config.json ml.tone_stride). There are no
candidates: marker_pos is empty.
Next word: <bos> encode(context)[last 128 tokens] <eos>, unit ids 0; English: cut the context's trailing spaces
first. Mid-text (the cursor inside the text): <bos> encode(left)[last tokens] <mask> encode(right)[first 32 tokens] <eos>, at most 130 tokens in all (the left side gives way); encode the right side on its own.
One sequence at a time (batch 1, no padding; with padding, mask padded keys in every attention).
The prefix mask. Let n be the position of the first <eos> plus one: positions 0 … n−1 are the leading
block. A query inside the block may attend only to keys inside it; a query after it attends to every key (within the
sliding window where the layer has one). This holds in every encoder layer and in the head layer.
x = tok_emb[vocab_remap[input_ids]] + unit_emb[unit_ids % 3833] + tone_emb[unit_ids / 3833], plus cand_emb
at every position in marker_pos, then LayerNorm (encoder.embeddings.norm).h = attn_norm(x) (layer 0: h = x); q, k, v = split(Wqkv h), laid out as (3, heads, 64).x·cos + rotate_half(x)·sin, frequencies
1 / 160000^(2i/64), positions 0, 1, 2, ….config.json
encoder.layer_types: full_attention), the others only where |i − j| ≤ 64 (sliding_attention).x += Wo(attention); then a, g = split(Wi mlp_norm(x)) (512 each), x += mlp.Wo(gelu(a) · g), exact (erf)
GELU.final_norm.h0 = encoder output + type_emb[0], then head.layers.0 (PyTorch nn.TransformerEncoderLayer,
norm_first=True, 4 heads, feed-forward 1024 with ReLU, LayerNorm eps 1e-5, in_proj_weight = q, k, v stacked;
no final norm), with the prefix mask.p, score = scorer.3(gelu(scorer.1(scorer.0(h0[p])))) (erf
GELU). Higher is better.s, q = out.1(out.0(h0[s])) and char_logits = q · char_embᵀ + char_bias
(9,067). Compare only the characters the slot's unit can spell (f: / jf:: that syllable's characters; p: /
jp:: those of every syllable starting with it), from unified_vocab.json: Simplified rows readings (the first
6,163 characters, ml.old_chars); Traditional pinyin and Zhuyin rows ml.pinyin, Cantonese rows ml.jyutping,
both without ml.simp_only. A composition row adds cand_emb nowhere, as it was trained: with it, composition
gets worse (300 rows of long pinyin, whole rows right: 53.0% without; 48.3% in laya.one.int8g.onnx, which always
adds it at marker_pos, with one dummy candidate after the slots).Caching the context. Run the block alone once per context and keep each layer's keys and values (after RoPE) for
its n positions; on each key run only the positions after it. onnx/int8g/laya.one.int8g.onnx is this as one graph
with a KV cache.
m = next.mem_in.1(next.mem_in.0(encoder output + type_emb[0])), (T, 384); then append the four memory
table positions (below), (T + 4, 384). Each decoder layer's cross-attention keys and values are m through rows
384-767 and 768-1151 of its multihead_attn.in_proj_weight (and bias): compute them once per context.next.start; position j ≥ 1 is next.tok_in(E[r_j]), with
E = tok_embeddings[next.rows] and r_j the j-th output row written; plus next.pos.weight[j].nn.TransformerDecoderLayer, norm_first=True, 6 heads of 64, LayerNorm eps 1e-5):
x += self_attn(norm1(x)) with a causal mask; x += multihead_attn(norm2(x), memory) (every memory position);
x += linear2(relu(linear1(norm3(x)))). Attention scale 1/8.logits = next.out.1(next.out.0(x)) · Eᵀ + next.bias over the 102,464 rows. A cache of each
layer's self-attention keys and values makes a step cost one position.Memory table. Four keys, each a hash of the sequence's token ids (full-vocabulary ids, before the remap) around
the gap: the gap is the position of <mask> (4) if the sequence holds one (mid-text), else its last position (the
<eos>). With at(o) = the id at gap + o (clamped to the sequence), l1, l2, l3 = at(-1), at(-2), at(-3) and, with
a <mask>, r1, r2 = at(1), at(2) (else -7 each):
h(salt, t...): x = salt * 0x9E3779B1 + 12345
for each t: x = (x XOR (t + 1)) * 0x100000001B3; x = x XOR (x >> 29)
row = x mod 1000003 (Euclidean: 0 ... 1000002)
keys = h(1, l2, l1), h(2, l3, l2, l1), h(3, r1, r2), h(4, l1, r1)
in signed 64-bit integers: the multiplications wrap around, >> is the arithmetic shift. Row r's 64 values are the 16
centroids next.mem_books[p][next.mem_codes[r][p]], p = 0…15, joined; key k's position is
next.mem_norm(next.mem_proj(row) + next.mem_type[k]), in key order after the context's memory.
Search (as the ONNX reference loop and candle_ref): beam 8, k = 5 words, at most 6 tokens a word.
zh rows (Simplified Han tokens) and the end; English mode en_start at the first
token, then en_cont or the end. Disallowed rows get −10⁹ before the log-softmax.next_rows.json text_zh / text_en;
English stripped), kept if it has at least min_chars characters (2 for words, 1 to let single characters
through); hypotheses writing the same text are summed (log-sum-exp).min_chars 1; the words found are the
rest of the word.test_vectors.safetensors, all int64 inputs (full-vocabulary token ids), outputs of the fp32 ONNX graphs (token table not pruned):
| Cases | Inputs | Output |
|---|---|---|
i = 0-4 (Simplified Chinese), 8-15 (the first row of each Traditional word-choice test file: pinyin, Zhuyin bopomofo_tw, Zhuyin libchewing, Jyutping, Cangjie 5, Quick 5, Cangjie 3, Quick 3) |
i.input_ids, i.unit_ids, i.marker_pos; i.slot_pos = [0], a placeholder |
i.logits (one per candidate) |
i = 5-7 (Simplified pinyin), 16-18 (the first row of the Traditional pinyin, Zhuyin and Jyutping composition test files) |
i.input_ids, i.unit_ids, i.slot_pos; i.marker_pos empty |
i.char_logits (slots × 9067) |
nextN, N = 0-14 (8-11 mid-text; 7 and 12-14 min_chars 1) |
nextN.input_ids, nextN.mode (0 Chinese, 1 English), nextN.min_chars |
nextN.text (UTF-8, one word a line), nextN.logp (the 5 words) |
candle_ref reads this file and writes its outputs under the same names:
cd candle_ref
RUSTFLAGS="-C target-cpu=native" cargo build --release
target/release/zhiyi-ref ../model.safetensors ../test_vectors.safetensors out.safetensors
candle's quantized kernels choose their SIMD code at compile time: build with -C target-cpu=native (or at least
x86-64-v3), otherwise the Q8_0 dot products run scalar code. candle_ref runs the whole sequence with the mask (no
cache) and reruns the decoder over each hypothesis' prefix at every step, which gives the same outputs as caching.
With Q8_0, on the 13 word-choice vectors it agrees with fp32 to within 0.22 and picks the same best candidate; on the 6
composition vectors to within 0.42, the same best character in every slot but one; on the 15 next-word vectors it
gives the same first word in all but one (next3: the same 5 words in another order), log p within 0.13.
The model alone, not the IME end to end (the release notes have those). fp32 ONNX = the export with the token table not pruned; int8 ONNX =
the released whole graph laya.int8g.onnx (pruned token table, ONNX Runtime 1.24.4); Q8_0 = this file through
candle_ref.
Word choice, first candidate right: every third row of the Simplified Chinese sets, the first 300 rows of each Traditional test file.
| Word choice | fp32 ONNX | int8 ONNX | Q8_0 (candle_ref) |
|---|---|---|---|
| Simplified Chinese, words and word pairs (2175) | 87.7% | 86.9% | 87.7% |
| Simplified Chinese, long input (749) | 81.2% | 79.2% | 81.2% |
| Simplified Chinese, IME's real candidates (545) | 90.5% | 90.1% | 90.3% |
| Simplified Chinese homophones with the previous sentence (267) | 92.9% | 93.3% | 92.9% |
| Traditional, pinyin (luna_pinyin) (300) | 81.7% | 79.7% | 81.7% |
| Traditional, Zhuyin (bopomofo_tw) (300) | 87.3% | 87.0% | 87.7% |
| Traditional, Zhuyin (libchewing) (300) | 93.7% | 94.0% | 93.3% |
| Traditional, Jyutping (jyut6ping3) (300) | 88.3% | 89.7% | 88.0% |
| Traditional, Cangjie 5 (300) | 95.7% | 95.3% | 96.0% |
| Traditional, Quick 5 (300) | 93.7% | 92.3% | 94.0% |
| Traditional, Cangjie 3 (300) | 82.0% | 79.7% | 81.3% |
| Traditional, Quick 3 (300) | 73.7% | 72.3% | 73.0% |
Composition, whole rows right / characters right (the best allowed character per slot): the first 300 full-pinyin rows of the long-input test set and of each Traditional composition test file.
| Composition | fp32 ONNX | int8 ONNX | Q8_0 (candle_ref) |
|---|---|---|---|
| Simplified, long pinyin in full (300) | 53.0% / 82.4% | 50.7% / 80.9% | 52.3% / 82.1% |
| Traditional, pinyin (300) | 32.3% / 66.7% | 28.7% / 64.9% | 33.0% / 66.8% |
| Traditional, Zhuyin (300) | 63.0% / 89.7% | 61.7% / 88.9% | 63.0% / 89.7% |
| Cantonese, Jyutping (300) | 35.3% / 68.4% | 33.3% / 67.6% | 35.3% / 68.3% |
Next word, the text's next word first (@1) / among the 5 words (@5), no n-gram, beam 8: the first 600 rows of the
Chinese and English next-word test sets, 300 mid-text rows of each, 300 Chinese rows with single characters allowed
and 300 Chinese words cut after their first characters (completion). int8w = the weight-only int8 graphs
laya.next.context + laya.next.step (the context graph measured with this file's 163,856-row token table, not the released pruned one).
| Next word | fp32 ONNX | int8w ONNX | Q8_0 (candle_ref) |
Q8_0's first word = fp32's |
|---|---|---|---|---|
| Simplified Chinese (600) | 14.5 / 22.0% | 14.5 / 22.0% | 14.7 / 22.0% | 95.8% |
| English (600) | 21.3 / 40.8% | 21.5 / 41.0% | 21.5 / 40.8% | 98.7% |
| Chinese mid-text (300) | 21.3 / 30.7% | 21.3 / 30.3% | 21.3 / 31.3% | 98.3% |
| English mid-text (300) | 42.3 / 62.0% | 42.3 / 62.0% | 42.3 / 62.0% | 96.7% |
Chinese, single characters too (300, min_chars 1) |
26.7 / 42.3% | 26.7 / 42.7% | 26.3 / 43.0% | 96.0% |
| Chinese completion (300) | 56.7 / 77.3% | 56.0 / 77.0% | 56.7 / 76.7% | 99.0% |
Word choice on the public neutral test sets, each model alone (no engine, no n-gram), against the theoretical compute
to score a row: of the Zhiyi models only the four maintained ones are shown, pumpkin
(zhiyi-ml-pumpkin), Flash
(zhiyi-ml-flash), Mini
(zhiyi-zhen-mini) and Feather
(zhiyi-zhen-feather), each scored with its released ONNX file
(this model: onnx/int8g/laya.int8g.onnx), so the points can differ a little from the numbers above. The other models (the file of each,
its license and how it is run) and the scoring code: https://github.com/dd1000001000/zhiyi_models/tree/main/comparisons/models
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.
Teachers (only their scores and words were used; none of their weights are in this file): Qwen3.5-9B (https://huggingface.co/Qwen/Qwen3.5-9B) fine-tuned with LoRA for word choice and composition, and Qwen3-1.7B-Base (https://huggingface.co/Qwen/Qwen3-1.7B-Base) for next words, both by the Qwen team (Alibaba Cloud), Apache-2.0. Text: composition rows as ML-Flash-1103's (SkyPile-150B, LCCC, C4, SODA, Tatoeba, FineWeb, FineWeb-2, the Cantonese Wikipedia) and new rare-character rows from FineWeb-2 (Penedo et al., 2025; ODC-By 1.0) cmn_Hani, their readings from pypinyin, OpenCC and librime with the Rime schemas (rime-cantonese among them); word choice and next words as zh-lite-next-preview-1120 (FineWeb-2, LCCC, SkyPile-150B, FineWeb, C4). These only produced training rows; none of them is in this file.
model.safetensors 143 MBonnx/int8g/laya.next.step.int8w.onnx 66 MBonnx/int8g/laya.next.context.int8w.onnx 57 MBonnx/int8g/laya.one.fused.int8g.onnx 43 MBonnx/int8g/laya.one.int8g.onnx 42 MBonnx/int8g/laya.int8g.onnx 42 MBtest_vectors.safetensors 2 MBjhu-clsp/mmBERT-small