Next-word prediction dictionaries for RIME input method — Simplified / Traditional / Merged Chinese.
After you commit a character or word, the candidate bar automatically suggests the next common character or word — type 我 and it offers 们, type 問 and it offers 題. This works with any Chinese RIME schema (Cangjie, Pinyin, Wubi, Zhuyin, …); it is not tied to a particular input method.
The files are binary dictionaries in the Rime::Predict/1.0 format, read by the official librime-predict plugin.
The configuration example below uses Cangjie 5 (Cangjie5_SC) purely for illustration. The dictionary itself is schema-independent — Pinyin and other schemas work the same way.
These are data files. They do nothing on their own: they are read by the librime-predict
plugin, which has to be part of your RIME distribution. Without the plugin, RIME silently skips the
predictor — typing works normally, there are simply no predictions and no visible error. (The Rime
log records error creating processor: 'predictor'.)
| Platform | librime-predict |
The prebuilt dist/*.db |
|---|---|---|
| Windows — Weasel 小狼毫, official installer | bundled | works |
macOS — Squirrel 鼠鬚管, official installer / brew install --cask squirrel-app |
bundled | works |
Arch Linux — librime |
bundled | expected to work, untested |
Fedora — librime-predict |
separate package | expected to work, untested |
Alpine — librime-plugin-predict |
separate package | expected to work, untested |
| Debian / Ubuntu | not packaged | needs extra work — see Using on Linux |
Checked 2026-09-20. "Bundled" for Weasel and Squirrel means their installers ship librime binaries
produced by librime's own release CI, whose plugin list includes rime/librime-predict; both are in
daily use by the author (Weasel 0.17.4 / librime 1.13.1, Squirrel 1.1.2). "Expected to work" means
the distribution builds the plugin inside the librime source tree, which is what keeps the
prebuilt .db compatible — see Technical notes — but nobody has reported back
yet. Debian and Ubuntu ship only the charcode, lua and octagram plugins.
| File | Content | Heads | Entries | Freq. coverage | Size |
|---|---|---|---|---|---|
dist/predict-zhs.db |
Simplified only | 4,169 | 52,780 | 99.1% | 524 KB |
dist/predict-zht.db |
Traditional only | 4,409 | 54,381 | 88.5% | 550 KB |
dist/predict-merged.db |
Merged (Simplified-first, Traditional alongside) | 6,061 | 94,810 | — | 924 KB |
src/*.tsv |
Plain-text sources (head ⇥ continuation ⇥ weight) for audit / rebuild |
||||
raw/*.txt |
Upstream raw association lists from chinesecj.com |
Naming:
zhs= Simplified,zht= Traditional,merged= both combined. RIME loads a file namedpredict.db(set bypredictor/dbin the schema). So "enabling a version" means copying the version you want topredict.db, or pointingpredictor/dbat a specific filename.predict.dbitself is not committed to this repo — create your own copy.
-
Pick a
.dbfromdist/and copy it into your RIME user directory, renaming it topredict.db— or keep its name and pointpredictor/dbat it in step 2.Distribution User directory Weasel (Windows) %APPDATA%\Rime\Squirrel (macOS) ~/Library/Rime/fcitx5-rime (Linux) ~/.local/share/fcitx5/rime/ibus-rime (Linux) ~/.config/ibus/rime/~/.config/fcitx/rime/belongs to Fcitx 4. Fcitx 5 does not read it. -
Enable the predictor in a patch file named after your schema. The filename must be
<schema_id>.custom.yaml—schema_idcomes from the schema itself, and is not necessarily the name of the.schema.yamlfile or the name you see in the menu. Find it with:grep -H schema_id ~/.local/share/fcitx5/rime/*.schema.yaml # Linux (fcitx5)
Select-String -Path "$env:APPDATA\Rime\*.schema.yaml" -Pattern schema_id # Windows
For example the Cangjie 3 schema from cangjie-system/rime-cangjie-integrated declares
schema_id: cangjie, so its patch file iscangjie.custom.yaml, notcangjie3.custom.yaml. The example below usescangjie5_sc.custom.yaml.patch: "engine/processors/@before 0": predictor "engine/translators/@before 0": predict_translator "switches/+": - { name: prediction, states: [ Prediction Off, Prediction On ], reset: 1 } predictor: db: predict.db # or point directly at predict-zht.db, etc. max_candidates: 6
If that file already exists, merge these entries into its existing
patch:block — do not add a secondpatch:line and do not overwrite the file. -
Redeploy from the tray menu (Linux: restart the input method, e.g.
fcitx5-remote -r). Type我and the candidate bar should show我们 · 我见 · 我行我素 ….
The patch above is the minimum needed for prediction, and is safe for any schema. A fuller,
commented version — with a few optional preferences for shape-based schemas such as Cangjie — lives
at docs/example.custom.yaml.
Switching versions (drop multiple .db files into the user directory, change one line):
predictor:
db: predict-zhs.db # or predict-zht.db / predict-merged.dbThen redeploy.
- Simplified
predict-zhs.db— for Simplified-only input. Cleanest. 99.1% frequency coverage. - Traditional
predict-zht.db— for Traditional-only input. 88.5% coverage (see Technical notes). - Merged
predict-merged.db— for mixed input with Simplified as the primary (recommended for daily use).- Heads that differ by form (問≠问, 愛≠爱, 國≠国 …) have naturally distinct keys, so the two datasets never interfere — zero cross-talk.
- Heads with identical form (我 / 中 / 你 …) share one key, with Simplified first and Traditional trailing, so Simplified input is virtually unaffected.
Two features are easy to mix up, and only one of them comes from this repository:
| What it does | Where it comes from | |
|---|---|---|
| Per-keystroke hints (逐鍵提示, code completion) | While you are still typing a code, it shows candidates whose codes merely start with what you have typed — in Cangjie, typing 人 already hints at what 人月, 人金 … would produce |
table_translator, built into shape-based schemas; on by default. Switch: translator/enable_completion |
| Next-word prediction (上屏聯想) | After a character or word is committed, it offers the next likely character or word — commit 我, get 我們 |
librime-predict plus a predict.db. This repository. Switch: the prediction switch |
They are independent: enable_completion has no effect on prediction, and vice versa.
docs/example.custom.yaml turns per-keystroke hints on
(translator/enable_completion: true), which is what most people expect while learning a
shape-based schema. Set it to false if you would rather see only exact matches for the code you
have typed.
Community-tested, not verified by me. I use RIME on Windows and macOS only. Everything in this section was worked out and tested by Hunt-hash7 on Debian 13 (Trixie) + Fcitx 5, and posted in rime/home discussion #2174. Thanks to them. Package names and paths below are Debian/Ubuntu-specific; on Arch, Fedora and Alpine just install the plugin package listed under Requirements and follow the normal Quick start.
ls /usr/lib/*/rime-plugins/If you see librime-predict.so, you are done — go back to Quick start. On Debian
and Ubuntu you will only see librime-lua.so and librime-octagram.so, because the predict plugin
is not packaged.
sudo apt update
sudo apt install -y \
build-essential git \
librime-dev librime-bin librime-data \
darts libx11-dev \
libleveldb-dev libmarisa-dev libopencc-dev \
libgoogle-glog-dev libgflags-dev \
libboost-dev libboost-locale-dev libboost-regex-dev \
libyaml-cpp-dev
sudo apt install -y fcitx5 fcitx5-rime fcitx5-config-qtdarts, libx11-dev and libgoogle-glog-dev are needed even though librime-dev does not depend
on them. Check that your librime supports external plugins (it must print at least one line):
TRIPLET=$(dpkg-architecture -qDEB_HOST_MULTIARCH) # x86_64-linux-gnu, aarch64-linux-gnu, …
nm -D /usr/lib/$TRIPLET/librime.so.1 | grep PluginManagerThen build and install it:
git clone https://github.com/rime/librime-predict.git ~/librime-predict
cd ~/librime-predict
g++ -shared -fPIC -std=c++17 -O2 \
-I /usr/include -I src \
$(pkg-config --cflags yaml-cpp 2>/dev/null) \
src/predict_module.cc src/predict_db.cc src/predictor.cc \
src/predict_translator.cc src/predict_engine.cc \
-L /usr/lib/$TRIPLET -lrime \
-o librime-predict.so
ldd librime-predict.so | grep rime # must resolve to /usr/lib/$TRIPLET/librime.so.1
sudo mkdir -p /usr/lib/$TRIPLET/rime-plugins
sudo cp librime-predict.so /usr/lib/$TRIPLET/rime-plugins/Compile against the system
librime-dev. Building against a different librime version makes the plugin fail to load, silently.
On Debian and Ubuntu the prebuilt dist/*.db files will not work with a plugin built this way.
They load without complaint and then return nothing — see Technical notes for
why. Build your own database from the plain-text source in src/ instead, with a build_predict
compiled the same way as the plugin:
cd ~/librime-predict
g++ -std=c++17 -O2 \
-I /usr/include -I src \
$(pkg-config --cflags yaml-cpp 2>/dev/null) \
tools/build_predict.cc \
src/predict_module.cc src/predict_db.cc src/predictor.cc \
src/predict_translator.cc src/predict_engine.cc \
-L /usr/lib/$TRIPLET \
-lrime -lleveldb -lmarisa -lopencc -lglog \
-o build_predict
# pick the version you want: predict-zhs.tsv / predict-zht.tsv / predict-merged.tsv
./build_predict ~/.local/share/fcitx5/rime/predict.db < /path/to/rime-predict-zh/src/predict-zht.tsvSuccess prints created: …/predict.db and no E... lines. Row order inside each head is
preserved, so the candidate order is the same as in the prebuilt files.
Then continue from Quick start step 2, and restart the input method:
fcitx5-remote -r # or: killall fcitx5; fcitx5 -dIf nothing happens, raise the log level in default.custom.yaml
(patch: {'logger/level': 3}), redeploy, and look for predict in
~/.local/share/fcitx5/rime/rime.*.log.
The rebuild in step 3 is only necessary because of which darts.h the compiler picks up. If you
build the plugin against librime's own darts.h, the files in dist/ should load exactly as
they do on Weasel and Squirrel, with no rebuild:
mkdir -p ~/rime-darts
curl -fsSL -o ~/rime-darts/darts.h \
https://raw.githubusercontent.com/rime/librime/master/include/darts.hthen put -I ~/rime-darts first in the include path — before -I /usr/include, which would
otherwise win — in both g++ commands above. (librime's copy of darts.h is byte-identical from
1.10.0 through master, so the branch you take it from does not matter.)
This route is reasoned from the source code and has not been tested by anyone. The verified route is step 3. If you try this and it works — or doesn't — please say so in discussion #2174.
A self-built plugin is tied to the librime it was compiled against. When your distribution upgrades
librime (Debian 13 and Ubuntu 25.10 ship 1.13.1; Debian forky and Ubuntu 26.04+ are on 1.16–1.17), recompile
librime-predict.so against the new librime-dev. If predictions stop working after that, rebuild
the .db as well, using the build_predict you rebuilt at the same time.
chinesecj.com association lists (GBK/GB18030)
├─ jtlx.txt Simplified source
└─ ftlx.txt Traditional source
│ ① Parse: split each line into (head → [continuations...])
│ ② Sort: reorder continuations by commonness
│ (the raw lists are in phonetic order, so this step is needed)
│ frequencies taken from rime-ice cn_dicts/base.dict.yaml
│ Traditional words are first converted to Simplified via OpenCC t2s,
│ then looked up — one consistent frequency ruler
│ ③ Merge (merged only): Simplified tier first, Traditional tier after,
│ identical-form duplicates removed
▼
head ⇥ continuation ⇥ weight (src/predict-*.tsv)
│ ④ compiled to binary by librime-predict's build_predict tool
▼
dist/predict-*.db (Rime::Predict/1.0)
The .db files are binary and cannot be hand-edited. To change content, edit the matching .tsv and recompile, or rerun the whole pipeline.
- Fine-tune ordering / add / remove words: edit
src/predict-*.tsv(head ⇥ continuation ⇥ weight; the row order under a head = the candidate display order), then recompile withbuild_predict. - New upstream list from chinesecj.com: replace
raw/jtlx.txt/raw/ftlx.txtand rerun the pipeline.
build_predictlinks against librime, and building it natively on Windows is fiddly; a Linux environment is the easy path. Build it inside a librime source tree — clone librime, putlibrime-predictinplugins/predict— so that it compiles against librime's owndarts.h. Abuild_predictcompiled against a distribution'sdartspackage produces a.dbthat loads on Weasel and Squirrel but returns no candidates. See Technical notes.
- Display order = the storage row order in the db, not re-sorted by weight.
librime-predictreads candidates sequentially up tomax_candidates. So "common words first" is achieved by the row order when generating the TSV; theweightcolumn is recorded for reference only. - Traditional coverage is 88.5% (lower than Simplified's 99.1%): rime-ice is Simplified-oriented, and a few Taiwan-specific terms don't match after t2s conversion (e.g. 愛滋病→爱滋病, 阿茨海默症). Those words get no frequency and sort after the common words of their head, but they remain in the candidate list. Common words (問題, 我們, 愛情 …) all convert and sort correctly.
- Merged heads with identical form trail a few Traditional "ride-along" candidates near the end of
max_candidates; Simplified input barely notices. - librime versions. The
.dbfiles were compiled withbuild_predictfrom librime 1.10, and are used daily on Weasel 0.17.4 (librime 1.13.1) and Squirrel 1.1.2. TheRime::Predict/1.0layout has not changed since October 2023 —librime-predictlast touchedpredict_db.hin February 2024, and today's definition still parses these files exactly. Note that the loader only checks theRime::Predict/prefix, so a future format change would not be rejected loudly; it would surface as "no candidates". - Keep
simplificationOFF (default 漢字 state), otherwise everything is forced to Simplified, breaking bidirectional Simplified/Traditional lookup. (This is a schema setting unrelated topredict.db, noted here for completeness.)
A predict.db is a memory-mapped image of three things:
- librime
MappedFilemetadata — 32-bit relative offsets, so it does not depend on the pointer size of the machine that wrote it; - a Darts double-array mapping each head to the offset of its candidate list;
- a marisa string table holding the candidate texts.
Byte order aside, what really decides compatibility is which darts.h build_predict and the
plugin were compiled against:
- librime vendors its own
include/darts.h, which is darts-clone — 4 bytes per unit. That file is byte-identical in librime 1.10.0, 1.13.1, 1.17.0 and master, so every official build agrees with every other, and with the.dbfiles here. - Debian and Ubuntu's
dartspackage installs a different implementation at/usr/include/darts.h— Taku Kudo's original Darts, 8 bytes per unit. Same class name, same methods, so code compiles cleanly against either one.
The metadata records the trie size in units, not bytes, and the loader never validates it. When
the two sides disagree, the database "loads successfully", every lookup misses, and you get no
candidates and no error. That is what happens on Debian and Ubuntu, because librime-dev does not
install librime's darts.h while the installed rime/dict/prism.h still includes it — so an
out-of-tree plugin build picks up the system darts package instead. Distributions that build the
plugin inside the librime source tree (Arch, Fedora, Alpine) get darts-clone and are unaffected.
This project would not exist without the work of others. Sincere thanks to:
- chinesecj.com (倉頡之友) — the original Chinese association word lists (
jtlx.txt/ftlx.txt) that form the backbone of these dictionaries. - iDvel/rime-ice (雾凇拼音) — word-frequency data from
cn_dicts/base.dict.yaml, used to rank the continuations. - rime/librime-predict — the prediction engine and the
build_predicttool that compiles the.dbfiles. - RIME / librime — the underlying input method engine.
- OpenCC — Traditional↔Simplified conversion (
t2s). - Hunt-hash7 — worked out and tested the whole Debian 13 + Fcitx 5 procedure in Using on Linux.
If you redistribute or build upon this work, please keep this attribution.
Released under the GNU General Public License v3.0 (see LICENSE), following the license of the upstream rime-ice frequency data this work is derived from.
The upstream association word lists come from the Cangjie Platform 2022 (chinesecj.com), whose authors state on their official forum that the platform and its code tables are "completely free and open, welcoming everyone to help promote Cangjie" (source). This project redistributes the raw/ lists in that spirit, with attribution. The underlying Cangjie input method is patent-free — released by Chu Bong-Foo (朱邦復) for free use and modification. The sibling project Jackchows/Cangjie5, likewise derived from the Cangjie Platform tables, follows the same approach.
Last updated: 2026-09-20