vaporetto

daac-toolsApache-2.0活跃维护

Rust 写的超快日文分词器,用逐点预测模型做形态素分割,适合需要低延迟、高吞吐的 NLP 流水线。

🛥 Vaporetto: Very accelerated pointwise prediction based tokenizer

v0.7.0发布于 2026-10-24 07:50 UTC302star +2 / 7 天12fork同步于 2026-11-11 05:57 UTC

怎么上手

由 README 提炼,执行前请确认
cargo run --release -p predict -- --model path/to/bccwj-suw+unidic_pos+pron.model.zst
硬件要求按 README 说明

README 未说明

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

项目说明

由 README 自动翻译提炼

Rust 写的点预测日文分词器,比 KyTea 快 8.7 倍,可训练和改模型

Rust 写的超快日文分词器,用逐点预测模型做形态素分割,适合需要低延迟、高吞吐的 NLP 流水线。

核心能力

  • 用点预测法逐字符边界打分做分词
  • 提供 Rust crate API 和 CLI 前端
  • 支持转换 KyTea 模型为 Vaporetto 格式
  • 支持全标注和部分标注语料训练模型
  • 可导出词典改权重修正分词错误

容易踩的坑

需先装 rustc 和 cargo;发行模型是 zstd 压缩,API 加载前要自行解压;旧版发行模型格式不兼容,需用 convert_bincode_model 转换;训练语料不能含空行

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

最近发版

5 个版本v0.7.0
  1. v0.7.00.7.0最新正式版2026-10-24 · 2026-10-24 07:50 UTC

    What's Changed

    Full Changelog: https://github.com/daac-tools/vaporetto/compare/v0.6.5...v0.7.0

    Model files

    This software contains the results of joint research with the National Institute for Japanese Language and Linguistics (NINJAL) and the National Institute of Information and Communications Technology (NICT).

    We provide multiple model files for Vaporetto that you can download and use in your work. These models have been trained using BCCWJ, CSJ, and UniDic.

    All of these models are trained with L1-regularization.

    See below for license terms of each model.

    (NOTE) Some of BCCWJ are not included in training data due to rights reasons.

    (NOTE) These models are for Vaporetto 0.7.0 or later. Since Vaporetto 0.7.0 changed the model format, models of 0.5.0 cannot be loaded by Vaporetto 0.7.0, and the models of this release cannot be loaded by Vaporetto 0.6 or earlier. The models trained only on BCCWJ are the same as those of 0.5.0, converted into the new format by convert_bincode_model of Vaporetto.

    Models with spoken language

    We newly provide models trained on both written language (BCCWJ) and spoken language (CSJ). These models are suitable for analyzing conversational text and transcriptions of speech.

    • bccwj+csj-suw+unidic_pron.model.zst: contains pronunciation tags of short unit words (SUW). This model contains UniDic, and estimates pronunciations closer to how words are actually spoken (For example, 私 is ワタシ (watashi) rather than ワタクシ (watakushi), and 言う is ユー (yū) rather than イウ (iu)). This model does not contain POS tags.
    • bccwj+csj-luw.model.zst: segments text into long unit words (LUW).

    (NOTE) These models are trained only on the core data of BCCWJ (excluding newspapers) and the 396 talks of CSJ whose morphological information was manually annotated.

    Models with dictionary

    We provide models containing UniDic. These models have the highest accuracy in our distributions.

    • bccwj-suw+unidic_pos+pron.model.zst: contains POS and pronunciation tags.
    • bccwj-suw+unidic_pos+kana.model.zst: contains POS and kana tags.

    (NOTE) "Pronunciation tags" are notations according to the actual pronunciation, whereas "kana tags" are notations used when printed. (For example, surface: 東京, pron: トーキョー (tōkyō), kana: トウキョウ (toukyou))

    Models without dictionary

    We also provide models that do not contain UniDic. These models have been trained over three model sizes and two word units.

    Short unit words (SUW)Long unit words (LUW)
    Tiny (C=0.003)bccwj-suw_c0.003.model.zstN/A
    Small (C=0.1)bccwj-suw_c0.1.model.zstN/A
    Middle (C=0.5)bccwj-suw_c0.5.model.zstN/A
    Large (C=1.0)bccwj-suw_c1.0.model.zstbccwj-luw.model.zst

    License

    The following models are licensed under 3-Clause BSD License.

    • bccwj+csj-suw+unidic_pron.model.zst
    • bccwj-suw+unidic_pos+pron.model.zst
    • `b
  2. v0.6.50.6.52025-03-17 · 2025-03-17 02:52 UTC
    查看更新说明

    Model Files

    You can use the following assets: https://github.com/daac-tools/vaporetto/releases/tag/v0.5.0

  3. v0.6.40.6.42024-11-05 · 2024-11-05 02:09 UTC
    查看更新说明

    Model Files

    You can use the following assets: https://github.com/daac-tools/vaporetto/releases/tag/v0.5.0

  4. v0.6.30.6.32023-04-01 · 2023-04-01 01:00 UTC
    查看更新说明

    Model Files

    You can use the following assets: https://github.com/daac-tools/vaporetto/releases/tag/v0.5.0

  5. v0.6.20.6.22023-03-07 · 2023-03-07 08:36 UTC
    查看更新说明

    This release fixes the following bug:

    • #86 Cannot deserialize predictor (@rabbit19981023)

    Model Files

    You can use the following assets: https://github.com/daac-tools/vaporetto/releases/tag/v0.5.0

用户点评

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

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

    README 原文

    未翻译

    🛥 Vaporetto: Very accelerated pointwise prediction based tokenizer

    Vaporetto is a fast and lightweight pointwise prediction-based tokenizer. This repository includes both a Rust crate that provides APIs for Vaporetto and CLI frontends.

    Crates.io Documentation Build Status Slack

    日本語のドキュメント

    Wasm Demo (takes a little time to load the model.)

    A Python wrapper is also available here.

    Example Usage

    Try Word Segmentation

    This software is implemented in Rust. Install rustc and cargo following the documentation beforehand.

    Vaporetto provides three ways to generate tokenization models:

    Download Distribution Model

    The first is the simplest way, which is to download a model we have trained. Models are available here.

    We chose bccwj-suw+unidic_pos+pron:

    % wget https://github.com/daac-tools/vaporetto-models/releases/download/v0.5.0/bccwj-suw+unidic_pos+pron.tar.xz
    

    Each file is a compressed file containing a model file and license terms, so you need to decompress the downloaded file as shown in the following command:

    % tar xf ./bccwj-suw+unidic_pos+pron.tar.xz
    

    The distribution models were created by Vaporetto 0.6 or earlier, whose model format is not compatible with the current version. Convert the model into the current format using the following command:

    % cargo run --release -p convert_bincode_model -- --model-in ./bccwj-suw+unidic_pos+pron/bccwj-suw+unidic_pos+pron.model.zst --model-out path/to/bccwj-suw+unidic_pos+pron.model.zst
    

    To perform tokenization, run the following command:

    % echo 'ヴェネツィアはイタリアにあります。' | cargo run --release -p predict -- --model path/to/bccwj-suw+unidic_pos+pron.model.zst
    

    The following will be output:

    ヴェネツィア は イタリア に あり ます 。
    
    Notes for Vaporetto APIs

    The distribution models are compressed in the zstd format. If you want to load these compressed models with the vaporetto API, you must decompress them outside of the API.

    // Requires zstd crate or ruzstd crate
    let reader = zstd::Decoder::new(File::open("path/to/model.zst")?)?;
    let model = Model::read(reader)?;
    

    You can also decompress the file using the unzstd command, which is bundled with modern Linux distributions.

    Convert KyTea's Model

    The second is also a simple way, which is to convert a model trained by KyTea. First of all, download the model of your choice from the KyTea Models page.

    We chose jp-0.4.7-5.mod.gz:

    % wget http://www.phontron.com/kytea/download/model/jp-0.4.7-5.mod.gz
    

    Each file is a compressed file, so you need to decompress the downloaded model file as shown in the following command:

    % gunzip ./jp-0.4.7-5.mod.gz
    

    To convert a KyTea model into a Vaporetto model, run the following command in the Vaporetto root directory.

    % cargo run --release -p convert_kytea_model -- --model-in path/to/jp-0.4.7-5.mod --model-out path/to/jp-0.4.7-5-tokenize.model.zst
    

    Now you can perform tokenization. Run the following command:

    % echo 'ヴェネツィアはイタリアにあります。' | cargo run --release -p predict -- --model path/to/jp-0.4.7-5-tokenize.model.zst
    

    The following will be output:

    ヴェネツィア は イタリア に あ り ま す 。
    
    Train Your Model

    The third way, which is mainly for researchers, is to prepare a training corpus and train your tokenization models.

    Vaporetto can train from two types of corpora: fully annotated corpora and partially annotated corpora.

    Fully annotated corpora are corpora in which all character boundaries are annotated with either token boundaries or internal positions of tokens. This is the data in the form of spaces inserted into the boundaries of the tokens, as shown below:

    ヴェネツィア は イタリア に あり ます 。
    火星 猫 の 生態 の 調査 結果
    

    Besides, partially annotated corpora are corpora in which only some character boundaries are annotated. Each character boundary is annotated in the form of | (token boundary), - (not token boundary), and (unknown). Here is an example:

    ヴ-ェ-ネ-ツ-ィ-ア|は|イ-タ-リ-ア|に|あ り ま す|。
    火-星 猫|の|生-態|の|調-査 結-果
    

    To train a model, use the following command:

    % cargo run --release -p train -- --model ./your.model.zst --tok path/to/full.txt --part path/to/part.txt --dict path/to/dict.txt --solver 5
    

    The --tok argument specifies a fully annotated corpus, and the --part argument specifies a partially annotated corpus. You can also specify a word dictionary with the --dict argument. A word dictionary is a file that lists words line by line and can be tagged as needed:

    トスカーナ
    パンツァーノ
    灯里/名詞-固有名詞-人名-名/アカリ
    形態/名詞-普通名詞-一般/ケータイ
    

    The trainer does not accept empty lines. Therefore, remove all empty lines from the corpus before training.

    You can specify all arguments above multiple times.

    Model Manipulation

    Sometimes, your model will output different results than what you expect. For example, 外国人参政権 is split into wrong tokens in the following command. We use the --scores option to show the score of each character boundary:

    % echo '外国人参政権と政権交代' | cargo run --release -p predict -- --scores --model path/to/bccwj-suw+unidic_pos+pron.model.zst
    外国 人 参 政権 と 政権 交代
    0:外国 -10784
    1:国人 17935
    2:人参 5308
    3:参政 3833
    4:政権 -3299
    5:権と 14635
    6:と政 17653
    7:政権 -12705
    8:権交 11611
    9:交代 -5794
    

    The correct is 外国 人 参政 権. To split 外国人参政権 into correct tokens, manipulate the model in the following steps so that the sign of score of 参政権 becomes inverted:

    1. Dump a dictionary by the following command:

      % cargo run --release -p manipulate_model -- --model-in path/to/bccwj-suw+unidic_pos+pron.model.zst --dump-dict path/to/dictionary.csv
      
    2. Edit the dictionary.

      The dictionary is a CSV file. Each row contains a string pattern, a corresponding weight array, and a comment in the following order:

      • word - A string pattern (usually a word)
      • weights - A weight array. When the input string contains the pattern, these weights are added to the character boundaries of the range of the pattern found.
      • comment - A comment that does not affect the behavior.

      Vaporetto splits a text when the total weight of the boundary is a positive number, so we add a new entry as follows:

       参撾,3328 -5545 3514,
       参政,3328 -5545 3514,
      +参政権,0 -10000 10000 0,参政/権
       参朝,3328 -5545 3514,
       参校,3328 -5545 3514,
      

      In this case, -10000 will be added between 参 and 政, and 10000 will be added between 政 and 権. Because 0 is specified at both ends of the pattern, no scores are added at those positions.

      Note that Vaporetto uses 32-bit integers for the total weight, so you have to be careful about overflow.

      In addition, The dictionary cannot contain duplicated words. When the dictionary already contains the word, you have to edit existing weights.

    3. Replaces weight data of a model file

      % cargo run --release -p manipulate_model -- --model-in path/to/bccwj-suw+unidic_pos+pron.model.zst --replace-dict path/to/dictionary.csv --model-out path/to/bccwj-suw+unidic_pos+pron-new.model.zst
      

    Now 外国人参政権 is split into correct tokens.

    % echo '外国人参政権と政権交代' | cargo run --release -p predict -- --scores --model path/to/bccwj-suw+unidic_pos+pron-new.model.zst
    外国 人 参政 権 と 政権 交代
    0:外国 -10784
    1:国人 17935
    2:人参 5308
    3:参政 -6167
    4:政権 6701
    5:権と 14635
    6:と政 17653
    7:政権 -12705
    8:権交 11611
    9:交代 -5794
    

    Tag prediction

    Vaporetto experimentally supports tagging (e.g., part-of-speech and pronunciation tags).

    To train tags, add slashes and tags following each token in the dataset as follows:

    • For fully annotated corpora

      この/連体詞/コノ 人/名詞/ヒト は/助詞/ワ 火星/名詞/カセイ 人/接尾辞/ジン です/助動詞/デス
      
    • For partially annotated corpora

      ヴ-ェ-ネ-ツ-ィ-ア/名詞|は/助詞|イ-タ-リ-ア/名詞|に/助詞|あ-り ま-す
      

    You can also specify tag information to dictionaries as well as corpora. When the predictor cannot predict a tag using the model, the tag specified in the dictionary will be annotated to the token.

    If the dataset contains tags, the train command automatically trains them.

    In prediction, tags are not predicted by default, so you have to specify the --predict-tags argument to the predict command if necessary.

    If you specify the --tag-scores argument, the score of each candidate calculated during tag prediction is displayed. If there is only one candidate, the score becomes 0.

    % echo "花が咲く" | cargo run --release -p predict -- --model path/to/bccwj-suw+unidic_pos+pron.model.zst --predict-tags --tag-scores
    花/名詞-普通名詞-一般/ハナ が/助詞-格助詞/ガ 咲く/動詞-一般/サク
    花	名詞-普通名詞-一般:18613,接尾辞-名詞的-一般:-18613	ハナ:19973,バナ:-20377,カ:-20480,ゲ:-20410
    が	助詞-接続助詞:-20408,助詞-格助詞:23543,接続詞:-25332	ガ:0
    咲く	動詞-一般:0	サク:0
    

    Speed Comparison of Various Tokenizers

    Vaporetto is 8.7 times faster than KyTea.

    Details can be found here.

    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 the whole tokenizer system:

    Technical details of DAACs, the pattern match algorithm underlying the tokenizer system: