vibrato

daac-toolsApache-2.0活跃维护

基于 Viterbi 算法的日语分词器,用 Rust 实现,适合需要高性能形态素分析的 NLP 场景。

🎤 vibrato: Viterbi-based accelerated tokenizer

v0.5.3发布于 2026-10-25 01:31 UTC430star +2 / 7 天27fork同步于 2026-11-10 23:58 UTC

怎么上手

由 README 提炼,执行前请确认
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.zst
硬件要求按 README 说明

README 未说明硬件要求,仅需安装 rustc 与 cargo 即可编译运行

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

基于 Viterbi 算法的快速分词与形态分析器,用 Rust 重写 MeCab 并针对大矩阵词典做缓存优化

基于 Viterbi 算法的日语分词器,用 Rust 实现,适合需要高性能形态素分析的 NLP 场景。

核心能力

  • 用 Rust 重实现 MeCab 的 Viterbi 分词算法
  • 用缓存友好的 id 映射加速大矩阵词典
  • 提供 -S、-M 等选项对齐 MeCab 输出
  • 支持 CSV 格式用户词典扩展词条
  • 支持从自有语料训练词典参数

容易踩的坑

需自行从 Releases 页下载预编译词典并把 VERSION 换成实际发布标签;发布的词典是 zstd 压缩格式,用 vibrato API 加载前必须在外部解压;默认会把空格当作 token 输出,要与 MeCab 一致需加 -S -M 24

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.5.3
  1. v0.5.3最新正式版2026-10-25 · 2026-10-25 01:31 UTC

    What's Changed

    New Contributors

    Full Changelog: https://github.com/daac-tools/vibrato/compare/v0.5.2...v0.5.3

  2. v0.5.22025-03-19 · 2025-03-19 02:18 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/daac-tools/vibrato/compare/v0.5.1...v0.5.2

  3. v0.5.12023-05-12 · 2023-05-12 02:54 UTC
    查看更新说明

    Main changes

    Precompiled model files

    You can use those distributed in https://github.com/daac-tools/vibrato/releases/tag/v0.5.0

  4. v0.5.02023-02-22 · 2023-02-22 04:52 UTC
    查看更新说明

    Main changes

    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 vibrato APIs, 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 the dual-connector technique.
    • 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: The dual-connector version.

    These models were trained with L1-regularization.

    Models converted from publicly-available resources

    Statistics for compressed UniDic models

    The following table shows UniDic model sizes in the two versions: without and with +compact or +compact-dual (not in zstd format).

    ModelsStandardCompactCompact-dual
    bccwj-suw+unidic-cwj-3_1_1618 MB248 MB275 MB
    unidic-cwj-3_1_1717 MB252 MB300 MB
  5. v0.4.02023-02-03 · 2023-02-03 04:23 UTC
    查看更新说明

    Main changes

    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:

    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.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    🎤 vibrato: VIterbi-Based acceleRAted TOkenizer

    Crates.io Documentation Build Status Slack

    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.

    License

    Licensed under either of

    at your option.

    Contribution

    See the guidelines.

    References

    Technical details of Vibrato are available in the following resources: