需自行从 Releases 页下载预编译词典并把 VERSION 换成实际发布标签;发布的词典是 zstd 压缩格式,用 vibrato API 加载前必须在外部解压;默认会把空格当作 token 输出,要与 MeCab 一致需加 -S -M 24
wget https://github.com/daac-tools/vibrato/releases/download/VERSION/ipadic-mecab-2_7_0.tar.xz
tar xf ipadic-mecab-2_7_0.tar.xz
echo '本とカレーの街神保町へようこそ。' | cargo run --release -p tokenize -- -i ipadic-mecab-2_7_0/system.dic.zstREADME 未说明硬件要求,仅需安装 rustc 与 cargo 即可编译运行
基于 Viterbi 算法的快速分词与形态分析器,用 Rust 重写 MeCab 并针对大矩阵词典做缓存优化
基于 Viterbi 算法的日语分词器,用 Rust 实现,适合需要高性能形态素分析的 NLP 场景。
核心能力
- 用 Rust 重实现 MeCab 的 Viterbi 分词算法
- 用缓存友好的 id 映射加速大矩阵词典
- 提供 -S、-M 等选项对齐 MeCab 输出
- 支持 CSV 格式用户词典扩展词条
- 支持从自有语料训练词典参数
容易踩的坑
- v0.5.3最新正式版2026-10-25 · 2026-10-25 01:31 UTC
What's Changed
- Fix clippy error by @kampersanda in https://github.com/daac-tools/vibrato/pull/160
- Fix mismatched_lifetime_syntaxes by @kampersanda in https://github.com/daac-tools/vibrato/pull/162
- Fix clippy error for derivable_impls by @kampersanda in https://github.com/daac-tools/vibrato/pull/163
- Update MSRV to 1.88 by @kampersanda in https://github.com/daac-tools/vibrato/pull/164
- Fix Clippy failure in lattice debug formatting by @kampersanda in https://github.com/daac-tools/vibrato/pull/165
- Fix Trunk installation in deploy workflow by @kampersanda in https://github.com/daac-tools/vibrato/pull/166
- Replace deprecated cloudflare/pages-action with wrangler-action by @kampersanda in https://github.com/daac-tools/vibrato/pull/168
- Fix several Clippy errors by @kampersanda in https://github.com/daac-tools/vibrato/pull/169
- Detect final stdout flush errors by @kampersanda in https://github.com/daac-tools/vibrato/pull/170
- Skip Cloudflare deploys for fork pull requests by @kampersanda in https://github.com/daac-tools/vibrato/pull/171
- fix(dictionary): allocate connection matrix gracefully from untrusted matrix.def header by @li-jin-quan in https://github.com/daac-tools/vibrato/pull/167
- fix(dictionary): accept CRLF CSV and optional features by @dajiaohuang in https://github.com/daac-tools/vibrato/pull/172
- Bump version to 0.5.3 by @kampersanda in https://github.com/daac-tools/vibrato/pull/173
New Contributors
- @li-jin-quan made their first contribution in https://github.com/daac-tools/vibrato/pull/167
- @dajiaohuang made their first contribution in https://github.com/daac-tools/vibrato/pull/172
Full Changelog: https://github.com/daac-tools/vibrato/compare/v0.5.2...v0.5.3
- v0.5.22025-03-19 · 2025-03-19 02:18 UTC
查看更新说明
What's Changed
- MSRV 1.67 by @vbkaisetsu in https://github.com/daac-tools/vibrato/pull/142
- MSRV 1.70 by @vbkaisetsu in https://github.com/daac-tools/vibrato/pull/143
- Remove unchecked functions by @vbkaisetsu in https://github.com/daac-tools/vibrato/pull/144
- Update example code in doc comment by @akiomik in https://github.com/daac-tools/vibrato/pull/145
- Fix typo by @akiomik in https://github.com/daac-tools/vibrato/pull/146
- Fix clippy errors by @kampersanda in https://github.com/daac-tools/vibrato/pull/147
- Update to MSRV 1.74 by @kampersanda in https://github.com/daac-tools/vibrato/pull/149
- Remove unnecessary clone() by @vbkaisetsu in https://github.com/daac-tools/vibrato/pull/152
- Add const hint to fix clippy error by @kampersanda in https://github.com/daac-tools/vibrato/pull/153
- Fix CI error by @kampersanda in https://github.com/daac-tools/vibrato/pull/155
- Fix clippy error by @kampersanda in https://github.com/daac-tools/vibrato/pull/156
- Fix compile errors by @kampersanda in https://github.com/daac-tools/vibrato/pull/157
- Bump up to v0.5.2 by @kampersanda in https://github.com/daac-tools/vibrato/pull/159
New Contributors
- @akiomik made their first contribution in https://github.com/daac-tools/vibrato/pull/145
Full Changelog: https://github.com/daac-tools/vibrato/compare/v0.5.1...v0.5.2
- v0.5.12023-05-12 · 2023-05-12 02:54 UTC
查看更新说明
Main changes
- Update MSRV to 1.65 https://github.com/daac-tools/vibrato/pull/138
- Update bincode version to 2.0.0-rc.3 https://github.com/daac-tools/vibrato/pull/140
Precompiled model files
You can use those distributed in https://github.com/daac-tools/vibrato/releases/tag/v0.5.0
- v0.5.02023-02-22 · 2023-02-22 04:52 UTC
查看更新说明
Main changes
- Add a Wasm demo https://github.com/daac-tools/vibrato/pull/115
- Handle locale on the Wasm demo https://github.com/daac-tools/vibrato/pull/119
- Add bi-gram feature info generator for MeCab models https://github.com/daac-tools/vibrato/pull/121
- Embed a magic number into a model https://github.com/daac-tools/vibrato/pull/129
Precompiled model files
We provide precompiled models for Vibrato, allowing you to get started with tokenization easily. You can download them from Assets in this release. The licenses are contained in each file.
All models were compiled and modified in the manners described in compile.md and map.md. We trained the mappings of connection ids using CORE data in BCCWJ v1.1 (except the PN category).
Note that all the models are compressed in zstd format. You can directly input them to Vibrato CLIs, but if using
vibratoAPIs, you need to extract them outside the APIs (see README).Models trained using Vibrato
The three variants are trained using BCCWJ v1.1 (except the PN category) and UniDic v3.1.1.
bccwj-suw+unidic-cwj-3_1_1: A standard version.bccwj-suw+unidic-cwj-3_1_1+compact: A smaller (but slower) version that compresses the connection matrix in the manner described in small-dic.md.bccwj-suw+unidic-cwj-3_1_1+compact-dual: An intermediate version of the above two by thedual-connectortechnique.bccwj-suw+unidic-cwj-3_1_1-extracted+compact: A further smaller version that contains only POS and pronunciation features.bccwj-suw+unidic-cwj-3_1_1-extracted+compact-dual: Thedual-connectorversion.
These models were trained with L1-regularization.
Models converted from publicly-available resources
ipadic-mecab-2_7_0from IPADIC v2.7.0jumandic-mecab-7_0from mecab-jumandic-utf8 v7.0naist-jdic-mecab-0_6_3bfrom NAIST Japanese Dictionary v0.6.3bunidic-mecab-2_1_2from UniDic v2.1.2unidic-cwj-3_1_1from UniDic v3.1.1unidic-cwj-3_1_1+compactfrom UniDic v3.1.1, whose connection matrix is compressed in a manner of mecab_smalldic.unidic-cwj-3_1_1+compact-dualfrom UniDic v3.1.1, which is thedual-connectorversion.
Statistics for compressed UniDic models
The following table shows UniDic model sizes in the two versions: without and with
+compactor+compact-dual(not in zstd format).Models Standard Compact Compact-dual bccwj-suw+unidic-cwj-3_1_1 618 MB 248 MB 275 MB unidic-cwj-3_1_1 717 MB 252 MB 300 MB - v0.4.02023-02-03 · 2023-02-03 04:23 UTC
查看更新说明
Main changes
- Handle zstd-compressed dictionaries in all CLIs https://github.com/daac-tools/vibrato/pull/112
Precompiled dictionary files
We provide precompiled dictionaries for Vibrato, allowing you to get started with tokenization easily. You can download them from Assets in this release.
The following variants are distributed:
ipadic-mecab-2_7_0/system.dic.zstfrom IPADIC v2.7.0ipadic-mecab-2_7_0-small/system.dic.zstfrom IPADIC v2.7.0- A smaller version that contains only the features
品詞-品詞細分類1and発音.
- A smaller version that contains only the features
jumandic-mecab-7_0/system.dic.zstfrom mecab-jumandic-utf8 v7.0naist-jdic-mecab-0_6_3b/system.dic.zstfrom NAIST Japanese Dictionary v0.6.3bunidic-mecab-2_1_2/system.dic.zstfrom UniDic v2.1.2unidic-cwj-3_1_1/system.dic.zstfrom UniDic v3.1.1
These system dictionaries were compiled and modified in the manners described in compile.md and map.md. We trained the mappings of connection ids using license-expired data obtained from Aozora Bunko, following the guideline.
The licenses are contained in each file.
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
🎤 vibrato: VIterbi-Based acceleRAted TOkenizer
Vibrato is a fast implementation of tokenization (or morphological analysis) based on the Viterbi algorithm.
A Python wrapper is also available here.
Wasm Demo (takes a little time to load the model.)
Features
Fast tokenization
Vibrato is a Rust reimplementation of the fast tokenizer MeCab,
although its implementation has been simplified and optimized for even faster tokenization.
Especially for language resources with a large matrix
(e.g., unidic-cwj-3.1.1 with a matrix of 459 MiB),
Vibrato will run faster thanks to cache-efficient id mappings.
For example, the following figure shows an experimental result of tokenization time with MeCab and its reimplementations. The detailed experimental settings and other results are available on Wiki.
MeCab compatibility
Vibrato supports options for outputting tokenized results identical to MeCab, such as ignoring whitespace.
Training parameters
Vibrato also supports training parameters (or costs) in dictionaries from your corpora. The detailed description can be found here.
Basic usage
This software is implemented in Rust.
First of all, install rustc and cargo following the official instructions.
1. Dictionary preparation
You can easily get started with Vibrato by downloading a precompiled dictionary. The Releases page distributes several precompiled dictionaries from different resources.
Here, consider to use mecab-ipadic v2.7.0.
(Specify an appropriate Vibrato release tag to VERSION such as v0.5.0.)
$ wget https://github.com/daac-tools/vibrato/releases/download/VERSION/ipadic-mecab-2_7_0.tar.xz
$ tar xf ipadic-mecab-2_7_0.tar.xz
You can also compile or train system dictionaries from your own resources. See the docs for more advanced usage.
2. Tokenization
To tokenize sentences using the system dictionary, run the following command.
$ echo '本とカレーの街神保町へようこそ。' | cargo run --release -p tokenize -- -i ipadic-mecab-2_7_0/system.dic.zst
The resultant tokens will be output in the Mecab format.
本 名詞,一般,*,*,*,*,本,ホン,ホン
と 助詞,並立助詞,*,*,*,*,と,ト,ト
カレー 名詞,固有名詞,地域,一般,*,*,カレー,カレー,カレー
の 助詞,連体化,*,*,*,*,の,ノ,ノ
街 名詞,一般,*,*,*,*,街,マチ,マチ
神保 名詞,固有名詞,地域,一般,*,*,神保,ジンボウ,ジンボー
町 名詞,接尾,地域,*,*,*,町,マチ,マチ
へ 助詞,格助詞,一般,*,*,*,へ,ヘ,エ
ようこそ 感動詞,*,*,*,*,*,ようこそ,ヨウコソ,ヨーコソ
。 記号,句点,*,*,*,*,。,。,。
EOS
If you want to output tokens separated by spaces, specify -O wakati.
$ echo '本とカレーの街神保町へようこそ。' | cargo run --release -p tokenize -- -i ipadic-mecab-2_7_0/system.dic.zst -O wakati
本 と カレー の 街 神保 町 へ ようこそ 。
Notes for Vibrato APIs
The distributed models are compressed in zstd format.
If you want to load these compressed models with the vibrato API,
you must decompress them outside of the API.
// Requires zstd crate or ruzstd crate
let reader = zstd::Decoder::new(File::open("path/to/system.dic.zst")?)?;
let dict = Dictionary::read(reader)?;
Tokenization options
MeCab-compatible options
Vibrato is a reimplementation of the MeCab algorithm, but with the default settings it can produce different tokens from MeCab.
For example, MeCab ignores spaces (more precisely, SPACE defined in char.def) in tokenization.
$ echo "mens second bag" | mecab
mens 名詞,固有名詞,組織,*,*,*,*
second 名詞,一般,*,*,*,*,*
bag 名詞,固有名詞,組織,*,*,*,*
EOS
However, Vibrato handles such spaces as tokens with the default settings.
$ echo 'mens second bag' | cargo run --release -p tokenize -- -i ipadic-mecab-2_7_0/system.dic.zst
mens 名詞,固有名詞,組織,*,*,*,*
記号,空白,*,*,*,*,*
second 名詞,固有名詞,組織,*,*,*,*
記号,空白,*,*,*,*,*
bag 名詞,固有名詞,組織,*,*,*,*
EOS
If you want to obtain the same results as MeCab, specify the arguments -S and -M 24.
$ echo 'mens second bag' | cargo run --release -p tokenize -- -i ipadic-mecab-2_7_0/system.dic.zst -S -M 24
mens 名詞,固有名詞,組織,*,*,*,*
second 名詞,一般,*,*,*,*,*
bag 名詞,固有名詞,組織,*,*,*,*
EOS
-S indicates if spaces are ignored.
-M indicates the maximum grouping length for unknown words.
Notes
There are corner cases where tokenization results in different outcomes due to cost tiebreakers. However, this would be not an essential problem.
User dictionary
You can use your user dictionary along with the system dictionary. The user dictionary must be in the CSV format.
<surface>,<left-id>,<right-id>,<cost>,<features...>
The first four columns are always required.
The others (i.e., <features...>) are optional.
For example,
$ cat user.csv
神保町,1293,1293,334,カスタム名詞,ジンボチョウ
本とカレーの街,1293,1293,0,カスタム名詞,ホントカレーノマチ
ようこそ,3,3,-1000,感動詞,ヨーコソ,Welcome,欢迎欢迎,Benvenuto,Willkommen
To use the user dictionary, specify the file with the -u argument.
$ echo '本とカレーの街神保町へようこそ。' | cargo run --release -p tokenize -- -i ipadic-mecab-2_7_0/system.dic.zst -u user.csv
本とカレーの街 カスタム名詞,ホントカレーノマチ
神保町 カスタム名詞,ジンボチョウ
へ 助詞,格助詞,一般,*,*,*,へ,ヘ,エ
ようこそ 感動詞,ヨーコソ,Welcome,欢迎欢迎,Benvenuto,Willkommen
。 記号,句点,*,*,*,*,。,。,。
EOS
More advanced usages
The directory docs provides descriptions of more advanced usages such as training or benchmarking.
Slack
We have a Slack workspace for developers and users to ask questions and discuss a variety of topics.
- https://daac-tools.slack.com/
- Please get an invitation from here.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
See the guidelines.
References
Technical details of Vibrato are available in the following resources:
- 神田峻介, 赤部晃一, 後藤啓介, 小田悠介. 最小コスト法に基づく形態素解析におけるCPUキャッシュの効率化, 言語処理学会第29回年次大会 (NLP2023).
- 赤部晃一, 神田峻介, 小田悠介. CRFに基づく形態素解析器のスコア計算の分割によるモデルサイズと解析速度の調整, 言語処理学会第29回年次大会 (NLP2023).
- MeCab互換な形態素解析器Vibratoの高速化技法, LegalOn Technologies Engineering Blog (2022-09-20).