/ Модель

Характеристики

Лицензия
Apache 2.0
Базовая модель
mmBERT-small
Библиотека
onnx
Опубликована
21 ноя 2026

zhiyi-zhen-feather-35M

Классификация текстаТекст → label
161скачиваний за 30 дней0лайковвеса обновлены3 дек 2026

Описание модели

Составлено на русском по карточке модели и метаданным Hugging Face

Компактная модель Zhiyi IME для выбора китайских и английских слов, преобразования фонетического ввода в китайские иероглифы и предсказания продолжения текста.

Zhiyi IME 的 zhiyi-zhen-feather-35M 是面向中英文输入法的紧凑型模型,由 Zhiyi IME 团队开发。它基于 mmBERT-small 微调,采用 8 层、宽度为 256 的 ModernBERT 编одировщик, 32-тысячный словарь и общий хешированный n-граммный блок памяти; для предсказания следующих слов используется декодер из 4 слоёв. Модель читает контекст до 128 токенов, а для композиции поддерживает контекст до 160 токенов. Репозиторий содержит ONNX- и Safetensors-форматы; лицензия — Apache-2.0.

Модель предназначена для выбора китайских слов и символов-кандидатов, преобразования длинного ввода пиньинем, чжуинем или ютпхином в иероглифы и предсказания следующих слов. Для традиционного китайского поддерживаются способы ввода пиньинем, чжуинем, ютпхином, Цанцзе и Quick; также доступны английские слова-кандидаты и продолжения. Модель может предлагать завершения в середине текста, учитывая содержимое после курсора. В README приведены результаты тестирования в Zhiyi IME на CPU и сравнение с предыдущей версией; это показатели конкретного приложения и тестовых наборов, а не гарантия качества в других условиях.

Сценарии применения

  • выбор китайского слова по контексту и введённой фонетической записи
  • преобразование длинной фразы на пиньине в китайские иероглифы
  • ввод традиционного китайского через чжуинь, ютпхинь, Цанцзе или Quick
  • предсказание следующего китайского или английского слова в экранной клавиатуре
  • завершение китайского слова по уже набранным первым символам
  • подсказка продолжения текста с учётом слов после курсора

Ограничения

Модель специализирована для задач ввода китайского и английского текста и не предназначена для универсального диалога или генерации произвольных текстов. В README отмечено, что предсказание следующих слов немного уступает предыдущей версии по отдельным тестам.

Публичные бенчмарки

Результаты из открытых лидербордов в сравнении с лидерами каталога

Публичных оценок пока нет

В подключённых источниках результатов этой модели не нашлось. Отсутствие оценки не значит, что модель хуже: её могли просто не проверять.

Источники: Hugging Face Leaderboards, Hugging Face Eval Results, Open LLM v2, MTEB, timm, Open ASR, EvalPlus, LLM Stats

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Zhiyi zhen-feather-1127

A new feather version will coming soon!

A Chinese / English input-method model of Zhiyi IME: 8 ModernBERT layers of width 256 reading 128 tokens of context, a 32,000-token vocabulary, and one shared hashed n-gram memory table (1,000,003 rows x 64, stored as product quantization, 16 MB) that all three tasks read:

  • word choice: one score per candidate (Simplified Chinese, English; Traditional Chinese with pinyin, Zhuyin, Jyutping, Cangjie and Quick);
  • composition: long pinyin, Zhuyin or Jyutping written as a sentence, one character per typed syllable (char_logits), through the head word choice uses;
  • next words: a 4-layer decoder proposes the next words after a word is committed (Simplified Chinese words in Chinese mode, English words in English mode), single characters too, completes a Chinese word whose first characters are already typed, and fills a gap mid-text: with the cursor inside the text it also reads the text after the cursor (你的作业|了吗, "your homework | yet?").

It replaces zhen-feather-preview-1121 in this repository and, since Zhiyi IME 1.7.3, in the IME (the ONNX file as released, with the word n-gram ng1017 beside it). In the IME end to end (CPU, quick inputs off): Simplified Chinese 88.2% (1121: 87.4%), long input 75.3% (72.4%), English 89.4% (89.0%); next words with a page of 10 (1000 rows): Chinese on the page 28.8% (28.0%), first 12.9% (14.0%), about 32 ms a prediction (35 ms).

Against 1121 (the model of Zhiyi IME 1.7.2):

  • one file of 39.8 MB (onnx/laya.feather.onnx) for everything, instead of 1121's separate word-choice and next-word graphs (the 4-bit set Zhiyi IME 1.7.2 ships is 56 MB): Mini's 32k vocabulary, and one table instead of a decoder-only one;
  • word choice better on every neutral set: v2 / v3 / v4 / v5 93.61 / 93.99 / 92.22 / 72.36% instead of 93.07 / 93.57 / 91.93 / 70.67% (PyTorch), on v5's rows with 1-16 characters of context 72.8% instead of 70.5%; Traditional word choice 90.0% instead of 89.0% on average over the eight test sets;
  • composition clearly better: long Simplified pinyin as whole sentences 58.7% instead of 53.0%; Traditional pinyin / Zhuyin / Jyutping 41.5 / 71.9 / 37.2% instead of 35.4 / 65.9 / 33.3%;
  • next words a little lower (Chinese 14.6 instead of 15.1 first-word hits, single characters 29.6 instead of 32.3, English mid-text 36.3 instead of 41.4, of which 3.8 points came with the 32k vocabulary), but a whole prediction 3-4 times faster (12.6 ms instead of 38.6 ms);
  • word choice itself about twice as slow per key as 1121's int8 graph (4.2 ms instead of 1.9 ms, below).

zhen-feather-preview-1121 stays in this repository's history and in its GitHub release. All Zhiyi models: https://github.com/dd1000001000/zhiyi_models

File
model.safetensorsall weights (44.3 MB): the token table, the unit table and the decoder already 4-bit as ggml Q4_0 blocks; the encoder, the head, the composition read-out and the table's two projections F16 (quantized to Q8_0 at load: config.json quantize_q8_0); the n-gram table as PQ16 codes + codebooks; the rest F32
config.jsonthe structure (with encoder.layer_types), prefix_mask, shared_head, compact, char_count, special tokens, sequence settings (choice_context_tokens 128, max_context_tokens 160 for composition, context_prefix), ml, next_word (the decoder, rows_are_tokens, context_tokens 128), ngram (the table: its token, slot and decoder keys and the hash), vocab_size, q4_0 (each 4-bit tensor's [rows, columns]) and quantize_q8_0
next_rows.jsonper token: its piece and text, the mode masks (zh, en_start, en_cont), the end token, characters per token
tokenizer.jsonthe 32k Unigram tokenizer: context, tags, typed text
tokenizer.candidates.jsonthe same with Metaspace prepend_scheme never: candidates, Chinese and English (no leading ▁)
unified_vocab.jsonthe slot units and letters, the 9,067 composition characters (chars, the order of char_emb; char_tokens their 32k token ids) and the readings that say which characters a unit can spell
test_vectors.safetensors13 word-choice, 6 composition and 15 next-word inputs with the fp32 PyTorch model's outputs, to check an implementation
candle_ref/a reference forward pass in Rust (candle 0.11), version 0.9.0: reads this file (4-bit, F16 and the table)
onnx/laya.feather.onnx (39.8 MB: word choice, composition and next words in one file, the table included; opset 21 + com.microsoft MatMulNBits / GatherBlockQuantized: the word-choice / composition / context branch 8-bit, the next-word step and the token table 4-bit), with both tokenizers and the JSON files
example.pythe quick start below
LICENSEApache License 2.0

Quick start (Python, ONNX Runtime)

Word choice, composition, next words and mid-text with onnx/laya.feather.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-zhen-feather", allow_patterns=["onnx/*"]), "onnx")
tok = Tokenizer.from_file(os.path.join(D, "tokenizer.json"))              # context, tags, typed text
ctok = Tokenizer.from_file(os.path.join(D, "tokenizer.candidates.json"))  # candidates (no leading ▁)
BOS, EOS, MASK = 2, 1, 4
CTX = 128      # context tokens (word choice and next words)
CTX_P2C = 160  # composition: the context with its prefix

# 1. Word choice: <bos> context <eos> <mask> x syllables <eos> cand1 cand2 ... <eos>; one score per candidate
#    (context mode on the leading block, then key mode on the rest with that cache; ctx_tail = the context's last
#    two tokens, for the table's candidate and slot keys)
print(choose("今天天气很好,我们去公园", ["san", "bu"], ["散步", "散布", "三部"]))

# 2. Composition: <bos> "已输入的上文: " + context <eos> in context mode, then <mask> x syllables <eos> in key mode
#    with slot_pos (no candidates: marker_pos empty); per slot the best character it can spell
print(compose("明天早上八点", "wo men zai xue xiao men kou jian mian".split()))

# 3. Next words: context mode once (cross_k_out / cross_v_out / cross_mask_out: the context and the table's four
#    positions), then is_step in a beam search over the 32k tokens
print(next_words("今天天气很好,我们一起去"))
print(next_words("Thank you very much for your", lang="en"))
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>

Output (ONNX Runtime 1.30.0, CPU):

[('散步', 1.92...), ('散布', -5.27...), ('三部', -6.15...)]
我们在学校门口见面
[('看看', -1.52...), ('旅游', -2.40...), ('体验', -4.32...), ('逛逛', -5.04...), ('逛街', -5.04...)]
[('support', -1.66...), ('service', -2.64...), ('help', -2.68...), ('advice', -3.20...), ('appreciation', -3.83...)]
[('司', -1.15...), ('园', -1.55...), ('交', -2.96...), ('交车', -2.97...), ('共', -3.47...)]
[('开始', -2.13...), ('工作', -2.67...), ('完成', -2.73...), ('结束', -3.93...), ('作业', -4.07...)]

The calls build the inputs of test_vectors.safetensors cases 0, 5, next0, next5, next7 and next8 (token for token); the file's next words differ a little from the vectors' fp32 ones (the same first word in each of these four, the later words partly another order). Traditional rows add the tag <zh-Hant> after <bos> and the typed text instead of <mask> units in word choice (see "Inputs"). Set FEATHER_DIR to a local onnx folder to skip the download.

Using the single file

The bool input is_step picks the branch (an If node runs only that one). 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 and leave out what the branch does not use.

  • is_step false (the default), word choice and composition: input_ids, unit_ids, past_enc_k / past_enc_v (8 × 1 × 4 × P × 64), past_choice_k / past_choice_v (1 × 1 × 4 × P × 64) with 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 (one per marker), char_logits (one row of 9,067 per slot), present_0 … present_3 (the encoder's and the head's keys and values), cross_k_out / cross_v_out, cross_mask_out. Context mode (the leading block <bos> … <eos>, no past) gives the cache; key mode (the rest, the cache as the past) gives the scores, with marker_pos and slot_pos counted from the start of the rest. Pass the same ctx_tail in both modes: a candidate's first tokens and the first slots are keyed on the context's last tokens in the table. Composition passes an empty marker_pos (1 × 0: no candidates, as trained) and the slots in slot_pos; word choice reads logits and may pass slot_pos = [[0]].
  • Next word, once per context: context mode on <bos> context[last 128 tokens] <eos> (mid-text: <bos> left <mask> right <eos>, below) with unit ids 0 → cross_k_out, cross_v_out (4 × 1 × 6 × (T + 4) × 64), the decoder's cross-attention keys and values of the T context positions and the table's four positions, and cross_mask_out (1 × (T + 4), all true for one context). In an input method this is the context pass word choice already runs, when the contexts are the same.
  • is_step true, one next-word step for N hypotheses: prev (N, the previous token; any value at position 0), pos (N), dec_past_k / dec_past_v (4 × N × 6 × P × 64) with dec_past_mask (N × P; at position 0 a placeholder of length 1, false), cross_k / cross_v (4 × N × 6 × (T + 4) × 64, one copy per hypothesis) with cross_mask (N × (T + 4), from cross_mask_out) → logits (N × 32,000, one per token), present_0 / present_1 = the decoder's keys and values with this step appended.

Speed (ONNX Runtime 1.24.4, CPU, AMD Ryzen 5 9600X; the search loop around the graph not counted; 300 pages of neutral v2, 300 Simplified composition rows of the dev set (157 of them in full pinyin) and 100 Chinese next-word test contexts, medians):

zhen-feather-1127, 4 threads / 1zhen-feather-preview-1121, 4 threads
Word choice, context mode (once per context)6.76 / 12.36 ms3.88 ms (laya.one.int8g.onnx)
Word choice, a key4.15 / 6.12 ms1.94 ms (laya.one.int8g.onnx), 2.54 ms (the 4-bit phone graph)
Composition, context mode + the slots2.88 + 2.55 / 3.05 + 2.47 ms
A whole next-word prediction (beam 8, 5 words)12.6 / 18.6 ms51.9 ms (int8), 38.6 ms (the 4-bit phone graphs; 45.6 ms on 1 thread)

1121's numbers are those measured for its release (same rows, same runtime). Word choice costs more mostly in the table's keys (hashing and lookups for every token and slot, many small operators); next words cost less with 32,000 output tokens instead of 102,464 and the step in the same file. Memory of the process (onnx/, loaded / running): 131 / 316 MB.

Training

One RTX 5070 Ti, from zhen-feather-preview-1121, the whole model.

  • The structure (no training): 1121's token table cut to Mini's 32k vocabulary (the kept tokens' rows copied; 1121's 116,118-row word-choice table, 102,464-row next-word read-out and its remap are gone: one 32,000 × 256 table is the input of both encoders and the decoder's read-out); 1121's decoder memory table (1,000,003 × 64) became the one table all tasks read, its keys still hashed on the old 256k token ids (ngram.idmap) so its trained rows keep their meaning; the two new readers (ng_proj for the encoder's token keys, ng_sproj for the slot keys) start at zero.
  • One stage on everything at once (536,352 steps, the last 10% decayed; learning rates 5e-5 decoder, 3e-5 encoder, 1e-4 table, 3e-4 the new projections, 5e-5 composition read-out): every step
    • 96 next-word rows: four epochs of 12.87 million rows (5.6 million Simplified Chinese and 3.27 million English rows as 1121, 1 million each with 256-token contexts, 2 million rows that allow single characters), Qwen3-1.7B-Base / Qwen3-4B-Base top-30 words as targets, the mid-text rows' words rescored with the right side (70% of those trained with it);
    • 128 word-choice rows: one pass over 55.4 million rows (1121's 52.6 million Simplified, Traditional and English rows; 2 million new Simplified / English rows with 256-token contexts, 300 thousand Traditional ones, 448 thousand short-context long-span rows), each with stored Qwen3.5-9B LoRA scores alone where it has them, else the 8-layer zh-lite-next-preview model reading 128 tokens as an online teacher (KL 0.7, temperature 2);
    • 68 composition rows: about four passes over 9.1 million rows (1121's 7.0 million Simplified, Traditional and Cantonese rows, 1.76 million new ones with long and short contexts, 386 thousand rare-character rows), on Qwen3.5-9B's soft scores where a row has them.
  • Then the table stored as PQ16 (16 sub-vectors of 4 values a row, 256 codes each: 256 MB of float32 to 16 MB; the scores move by at most 0.5 points) and the weights rounded (above).

The weight formats and the table

A tensor listed in config.json q4_0 is stored as ggml's Q4_0 blocks: dtype U8, shape rows × (columns / 32 × 18). Each block of 32 values along a row is 18 bytes: an f16 scale d (little-endian), then 16 bytes q; value j (0…15) is ((q[j] & 15) − 8) · d, value j + 16 is ((q[j] >> 4) − 8) · d. This is the layout candle's qtensor_from_ggml(GgmlDType::Q4_0, …) (and llama.cpp) read, so a linear layer runs as a 4-bit matrix product:

use candle_core::quantized::{ggml_file::qtensor_from_ggml, GgmlDType, QMatMul};

let raw = safetensors.load(name, &device)?.flatten_all()?.to_vec1::<u8>()?;
let w = QMatMul::from_qtensor(qtensor_from_ggml(GgmlDType::Q4_0, &raw, vec![rows, cols], &device)?)?;
// w.forward(&x) = x · wᵀ, then add the bias if the layer has one

The 4-bit tensors: every linear weight of the decoder (next.*), and the two embedding tables encoder.embeddings.tok_embeddings.weight (32000 × 256) and unit_emb.weight (3833 × 256), whose rows are unpacked when read. The token table is also the read-out: keep it as a Q4_0 matrix for x · tableᵀ and unpack only the rows a lookup needs (one copy in memory). The tensors in quantize_q8_0 (the encoder's and the head's matrices, scorer.1, out.1, char_emb, ng_proj, ng_sproj) are F16, for an implementation to quantize to 8 bits as it loads them (candle_ref: Q8_0): at 4 bits composition lost 6.7 points of whole Simplified sentences of 300. Everything else is F32.

The table (ngram.codes U8 1000003 × 16, ngram.codebooks F32 16 × 256 × 4): row r is the 16 codebook vectors codebooks[p, codes[r, p]] (p = 0…15) one after another, 64 values.

The hash (config.json ngram.hash): for a salt and key tokens t₁ … tₖ, in int64 with a wrapping multiply,

x = salt * 0x9E3779B1 + 12345
for t in t1 ... tk:  x = (x XOR (t + 1)) * 0x100000001B3;  x = x XOR (x >> 29)   (arithmetic shift)
row = x mod 1000003   (non-negative)

An absent key token is −7. Token ids in every key are the old ones, o = ngram.idmap[id]; slot keys use the unit ids as unit_ids holds them (tone included).

Tensors

Names are the PyTorch ones.

TensorShape
encoder.embeddings.tok_embeddings.weight32000 × 256Q4_0; token id = row
encoder.embeddings.norm.weight256LayerNorm, no bias
encoder.layers.N.attn_norm.weight (N ≥ 1; layer 0 has none)256
encoder.layers.N.attn.Wqkv.weight768 × 256N = 0…7, F16
encoder.layers.N.attn.Wo.weight256 × 256F16
encoder.layers.N.mlp_norm.weight256
encoder.layers.N.mlp.Wi.weight1024 × 256F16
encoder.layers.N.mlp.Wo.weight256 × 512F16
encoder.final_norm.weight256
unit_emb.weight3833 × 256Q4_0; row 0 = none, 1-3804 the units of unified_vocab.json, 3805-3832 letters
tone_emb.weight6 × 256Zhuyin tones: row 0 = none, 1-5 (5 = neutral)
type_emb.weight3 × 256row 0 is the one used
cand_emb256added at each candidate's first token
ngram.codes, ngram.codebooks1000003 × 16, 16 × 256 × 4the table (PQ16)
ngram.idmap32000 (I32)token id → the id every key is hashed on (the 256k vocabulary's)
ng_proj.weight, ng_proj.bias256 × 128, 256token keys: two table rows (2 × 64) → the encoder's input; F16
ng_sproj.weight, ng_sproj.bias256 × 128, 256slot keys: two table rows → the encoder's input; F16
head.layers.0.*one nn.TransformerEncoderLayer (matrices F16)
scorer.0 (LayerNorm), scorer.1 (256 → 256), scorer.3 (256 → 1)word choice
out.0 (LayerNorm), out.1 (256 → 256)composition
char_emb.weight9067 × 256the 9,067 characters' token-embedding rows (unified_vocab.json chars order, char_tokens); F16
char_bias9067composition
next.mem_in.0 (256 → 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 (256 → 384)a token's embedding → the decoder's input
next.start384the input at position 0
next.start_word384position 0 in training's "word" mode (2+ character Chinese rows); the search below uses next.start
next.pos.weight22 × 384learned 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; matrices Q4_0
next.out.0 (LayerNorm), next.out.1 (384 → 256)the decoder's output
next.bias32000the read-out's bias, per token

Forward pass: encoder, word choice, composition

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> (1) 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.

  1. x = tok_emb[input_ids] + unit_emb[unit_ids % 3833] + tone_emb[unit_ids / 3833], plus cand_emb at every position in marker_pos (each candidate's first token; none in composition).

  2. Token keys, on o = ngram.idmap[input_ids]: for every context position p (1 ≤ p < n − 1, between <bos> and the first <eos>) and every candidate token (from the first marker up to, not including, the final <eos>):

    • prev1 = o[p − 1], prev2 = o[p − 2] (−7 at p < 2); for a candidate token at offset off from its candidate's first token: off = 0 → prev1 = o[n − 2], prev2 = o[n − 3] (the context's last two tokens; −7 when n < 3), off = 1 → prev2 = o[n − 2];
    • x[p] += ng_proj(concat(row(hash(1; prev1, o[p])), row(hash(2; prev2, prev1, o[p])))). Every other position adds ng_proj's bias alone.
  3. Slot keys, on the unit ids u = unit_ids and c1 = o[n − 2], c2 = o[n − 3] (the context's last two tokens; c2 = −7 when n < 3): at every position p with u[p] > 0 (the typed units of word choice and composition),

    • bigram: hash(5; u[p−1], u[p]) if position p − 1 is a unit, else hash(7; c1, u[p]);
    • trigram: hash(6; u[p−2], u[p−1], u[p]) if positions p − 1 and p − 2 are units, hash(8; c1, u[p−1], u[p]) if only p − 1 is, else hash(9; c2, c1, u[p]);
    • x[p] += ng_sproj(concat(row(bigram), row(trigram))). Every other position adds ng_sproj's bias alone.

    Then LayerNorm (encoder.embeddings.norm).

  4. Encoder: 8 pre-norm ModernBERT layers, width 256, 4 heads of 64, no biases.

    • h = attn_norm(x) (layer 0: h = x); q, k, v = split(Wqkv h), laid out as (3, heads, 64).
    • RoPE on q and k, base 160000, rotate-half form: x·cos + rotate_half(x)·sin, frequencies 1 / 160000^(2i/64), positions 0, 1, 2, ….
    • Attention with scale 1/8 and the prefix mask. Layers 0, 2, 4 and 7 attend globally (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.
    • After the last layer, final_norm.
  5. Head: 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.

  6. Word choice: at each candidate's first token p, score = scorer.3(gelu(scorer.1(scorer.0(h0[p])))) (erf GELU). Higher is better.

  7. Composition: at each slot 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. 229 of the 9,067 characters have no token of their own in the 32k vocabulary: their char_emb row is <unk>'s, so only char_bias tells them apart.

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 (the ONNX file's context and key modes). The key part needs the context's last two tokens for its token and slot keys (ctx_tail).

Forward pass: the next-word decoder

  1. Memory. Encode <bos> encode(context)[last 128 tokens] <eos> (English: the context's trailing spaces cut first) with the encoder above (unit ids 0, no candidates; one prefix block, so the plain mask with the sliding window). m = next.mem_in.1(next.mem_in.0(encoder output + type_emb[0])), (T, 384). Mid-text: <bos> L <mask> R <eos> with R = encode(right)[first 32 tokens] and L = encode(left)[−(127 − len(R)):] (as trained: the left side gives way to the right side), the gap marked by <mask> (a context never holds one: replace <mask> in the text by a space first). Encode the right side on its own; English: cut the left side's trailing spaces as before.
  2. The table's four positions. On the block's old ids o = ngram.idmap[c], with g the <mask> position (else the final <eos>): l1, l2, l3 = o[g−1], o[g−2], o[g−3], r1, r2 = o[g+1], o[g+2] (−7 without a gap; indices clamped to the block); keys hash(1; l2, l1), hash(2; l3, l2, l1), hash(3; r1, r2), hash(4; l1, r1) (ngram.decoder.salt_offset 0: the first two are the same rows as the last context token's token keys); position j = next.mem_norm(next.mem_proj(row(key_j)) + next.mem_type[j]). Append the four after m: the memory is (T + 4, 384).
  3. 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): compute them once per context.
  4. Decoder input. Position 0 is next.start; position j ≥ 1 is next.tok_in(tok_emb[t_j]), t_j the token written at step j; plus next.pos.weight[j].
  5. Layers (PyTorch nn.TransformerDecoderLayer, norm_first=True, 6 heads of 64, LayerNorm eps 1e-5, no dropout): x += self_attn(norm1(x)) with a causal mask; x += multihead_attn(norm2(x), memory) (all T + 4 positions); x += linear2(relu(linear1(norm3(x)))). Attention scale 1/8.
  6. Read-out. logits = next.out.1(next.out.0(x)) · tok_embᵀ + next.bias over the 32,000 tokens. A cache of each layer's self-attention keys and values makes a step cost one position.

Search (as example.py and candle_ref): beam 8, k = 5 words, at most 6 tokens a word.

  • Allowed tokens: Chinese mode the zh tokens (Simplified Han) and the end (<eos>, next_rows.json end); English mode en_start at the first token, then en_cont or the end. The others get −10⁹ before the log-softmax.
  • The end may not come first; at the 7th token only the end is allowed.
  • A hypothesis that ends becomes a word: the texts of its tokens joined (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).
  • Each step keeps the 8 best open hypotheses; the search stops when 5 words are found and no open hypothesis is above the 5th.
  • Completion (Chinese): put the typed characters at the end of the context, min_chars 1; the words found are the rest of the word.

Inputs

Token ids are tokenizer.json's, with <bos> (2) as [CLS], <eos> (1) as [SEP], <mask> (4). The context, a tag and the typed text are encoded with tokenizer.json; candidates with tokenizer.candidates.json (no ▁, English ones too), each cut to 16 tokens. Encode without special tokens. A Traditional row starts with the tag <zh-Hant> as plain text; Simplified Chinese and English have no tag. Characters outside the 32k tokens fall back to UTF-8 bytes (<0x..> tokens).

word choice, Simplified (pinyin)   <bos> encode(context)[last 128] <eos>  <mask> × typed units <eos>  cand(候选1)[:16] cand(候选2)[:16] … <eos>
word choice, Traditional           <bos> encode("<zh-Hant>") encode(context)[last 128] <eos>  encode(typed text)[:24] <eos>  cand(候選1)[:16] … <eos>
word choice, English               as Simplified, one <mask> a typed letter (its letter unit)
composition                        <bos> [encode("<zh-Hant>")] encode("已输入的上文: " + context) <eos>  <mask> × slots <eos>
next word                          <bos> encode(context)[last 128] <eos>
next word, mid-text                <bos> encode(left)[−(127 − len(R)):] <mask> R = encode(right)[:32] <eos>

marker_pos lists the position of each candidate's first token. Each <mask> of the typed units carries its unit in unit_ids (unified_vocab.json units: f:san = the full syllable san, p:s = typed only partly; English letters 3805 + the letter's index in letters); the other positions have unit 0.

Composition: 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. At most 24 slots; slot_pos lists them; each 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.

Test vectors

test_vectors.safetensors, all int64 inputs, outputs of the fp32 PyTorch model with the table as stored (PQ16), the other weights before rounding:

CasesInputsOutput
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 placeholderi.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 emptyi.char_logits (slots × 9067, before the masks)
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_charsnextN.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 (it loads the model in about 0.3 s):

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 RUSTFLAGS="-C target-cpu=native" (or at least x86-64-v3). candle_ref is a reference, not a fast runtime: it runs the whole sequence with the mask (no cache) and reruns the decoder over each hypothesis' prefix at every step; the outputs are those of the cached runs. On the vectors it picks the same best candidate in 13 of 13 word-choice cases (logits within 0.73) and gives the same first word in 11 of the 15 next-word cases (4.0 of the 5 words shared on average).

Accuracy

The model alone, not the IME end to end. PyTorch = the trained model with the table as stored (PQ16), fp32 otherwise; the exported files are checked against it below.

Word choice, first candidate right, the whole test sets:

Word choicezhen-feather-preview-1121zhen-feather-1127
Simplified Chinese, words and word pairs (6523)88.1%88.5%
Simplified Chinese, long input (2247)82.5%82.8%
English (2189)88.9%89.3%
Simplified Chinese web text, short (1001)91.9%91.5%
Simplified Chinese web text, long (344)87.2%88.4%
English web text (426)86.6%86.2%
Simplified Chinese, IME's real candidates (right word among them) (1634)90.3%90.6%
Simplified Chinese homophones with the previous sentence (800)90.9%90.9%
English, the older test set (840)86.8%85.2%
Traditional, pinyin (luna_pinyin) (3000)84.2%85.3%
Traditional, Zhuyin (bopomofo_tw) (3000)91.1%92.1%
Traditional, Zhuyin (libchewing) (3000)96.2%96.5%
Traditional, Jyutping (jyut6ping3) (3000)88.9%90.0%
Traditional, Cangjie 5 (3000)95.3%96.4%
Traditional, Quick 5 (3000)94.2%95.5%
Traditional, Cangjie 3 (3000)84.1%85.4%
Traditional, Quick 3 (3000)78.3%79.1%

Composition, whole rows right / characters right (the best allowed character per slot):

Compositionzhen-feather-preview-1121zhen-feather-1127
Simplified, long pinyin in full (300)53.0% / 82.4% (its fp32 ONNX)58.7% / 84.7%
Traditional, pinyin (3000)35.4% / 71.1%41.5% / 75.2%
Traditional, Zhuyin (3000)65.9% / 90.9%71.9% / 92.7%
Cantonese, Jyutping (3000)33.3% / 67.9%37.2% / 71.3%

Next word, the text's next word first (@1) / among the 5 words (@5), beam 8, the whole next-word test sets (mid-text = the rows whose text goes on after the word, that text as the right side; single characters = the rows of the set that allows them):

@1 / @5zhen-feather-preview-1121zhen-feather-1127
Chinese next word (4941)15.1 / 27.2%14.6 / 26.5%
... with ng101715.4 / 27.8%14.6 / 27.7%
Chinese, single characters too (3548)21.7 / 35.6%20.1 / 35.3%
... of them single characters (1489)32.3 / 49.8%29.6 / 47.8%
Chinese mid-text (3789)21.6 / 35.8%20.3 / 34.9%
Chinese completion (4941)56.8 / 78.5%55.7 / 78.3%
English next word (3000)24.2 / 43.0%22.5 / 41.4%
... with a trigram of the training text24.0 / 43.4%23.2 / 41.8%
English mid-text (2969)41.4 / 60.4%36.3 / 54.8%

The vocabulary change alone (1121 cut to 32k tokens, before any training) took English mid-text to 37.6 / 55.3% and English next words to 21.8 / 39.1%.

On the public neutral word-choice test sets (v2, v3 web, v4 chat, v5 hard; whole page, first candidate right):

v2v3v4v5
zhen-feather-preview-1121, PyTorch fp3293.07%93.57%91.93%70.67%
zhen-feather-1127, PyTorch93.61%93.99%92.22%72.36%
zhen-feather-preview-1121, int8 ONNX (laya.int8g.onnx)92.3%92.9%91.6%68.7%
zhen-feather-1127, ONNX (onnx/laya.feather.onnx)93.6%93.9%92.2%72.2%

v5 by the context before the typed text (PyTorch; none / 1-16 characters / more):

none1-16 charactersmore
zhen-feather-preview-112160.73%70.46%82.46%
zhen-feather-112762.11%72.79%83.74%

The ONNX rows are the comparison scorer's (the charts below), the PyTorch rows the training code's; the two count the same rows slightly differently.

The exported files against PyTorch, on the same rows (300 a set: every set's first 300 rows, the Simplified word choice rows of the parity sets, composition alone on the dev set of the training data's composition rows (Simplified) and on the test files (Traditional); next words 300 Chinese and 300 English test rows, 150 mid-text rows of each and 150 Chinese completions):

ONNX onnx/laya.feather.onnxcandle_ref on model.safetensors
Word choice: the same best candidate as PyTorch (9 sets)95.3-99.7%95.3-99.7%
Word choice: accuracy against PyTorch's, per set−0.3 … +1.7 points−0.3 … +1.3 points
Composition: the same character as PyTorch (4 sets)96.1-99.1%95.6-99.0%
Composition: whole rows against PyTorch's, per set−0.3 … +0.6 points−0.3 … +0.3 points
Simplified long pinyin (300): whole / characters58.0% / 84.8% (PyTorch 58.7% / 84.7%)58.3% / 84.7%
Next words: the same first word as PyTorch (5 sets)82.0-92.0%77.3-91.3%
Next words: @1 against PyTorch's, per set−0.6 … +2.0 points−1.4 … +0.3 points

Compared with other input-method models

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 (zhiyi-ml-pumpkin), Flash (zhiyi-ml-flash-0.2B), Mini (zhiyi-zhen-mini-12M) and Feather (this model), 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

  • Word choice: pick the original text among one engine's candidates, on the public neutral test sets v2–v5 (v5: the hard cases).
  • Composition: a whole pinyin string to a sentence, first output exactly right. Every target is typed four ways (full pinyin, last syllable cut short, full and initials mixed, initials only), with the text before it as context: web paragraphs from October 2026 (2,000 rows) and LCCC test dialogues (1,800 rows).
  • Next word: the next word (2+ characters) is among the top 5 predictions: web (6,000 rows) and LCCC test dialogues (4,943 rows).

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.

Word choice

Word choice accuracy on neutral v2-v4 and v5

Word choice accuracy against compute per row

Composition

Composition: first output exactly right, web and chat

Composition accuracy against compute per row

Next word

Next word: hit in the top 5, web and chat

Next-word hit in the top 5 against compute per row

License and credits

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 32k tokenizer is a subset of its vocabulary). 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): Zhiyi's own 8-layer model (zh-lite-next-preview's Lite x8) online for word choice; Qwen3.5-9B (https://huggingface.co/Qwen/Qwen3.5-9B) fine-tuned with LoRA for word choice and composition (stored scores), Qwen3-1.7B-Base (https://huggingface.co/Qwen/Qwen3-1.7B-Base) and Qwen3-4B-Base (https://huggingface.co/Qwen/Qwen3-4B-Base; the new Chinese mid-text rows) for next words, all by the Qwen team (Alibaba Cloud), Apache-2.0. Text: as zhen-feather-preview-1121 (composition rows as ML-Flash-1103's: SkyPile-150B, LCCC, C4, SODA, Tatoeba, FineWeb, FineWeb-2, the Cantonese Wikipedia; rare-character rows from FineWeb-2; word choice and next words: FineWeb-2, LCCC, SkyPile-150B, FineWeb, C4), plus the new rows of this version: long contexts from FineWeb-2 (Penedo et al., 2025; ODC-By 1.0; cmn_Hani, Simplified and Traditional) and FineWeb, short-context word choice from FineWeb-2, LCCC and C4 with candidates from seven input-method engines run on the typed letters (Zhiyi, Rime with rime-ice and with luna_pinyin, libpinyin, libime, Qingjian and Microsoft Pinyin; only their candidate lists were used), readings from pypinyin, OpenCC and librime with the Rime schemas (rime-cantonese among them). These programs and data only produced training rows; none of them is in these files.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · onnx · text-classification

Можно запустить

Подбираем GPU…

Ревизия весов
8a973af

0 моделей