#nlp #sentence-piece #machine-learning #tokenizer

no-std sentencepiece-model

SentencePiece model parser generated from the SentencePiece protobuf definition

5 releases

0.1.4 Oct 8, 2024
0.1.3 Jul 16, 2024
0.1.2 Jul 4, 2024
0.1.1 Jul 2, 2024
0.1.0 Nov 18, 2023

#1386 in Parser implementations

Download history 7/week @ 2024-11-16 63/week @ 2024-11-23 1/week @ 2024-11-30 20/week @ 2024-12-07 91/week @ 2024-12-14 7/week @ 2025-01-11 114/week @ 2025-01-18 1363/week @ 2025-01-25 1173/week @ 2025-02-01 908/week @ 2025-02-08 475/week @ 2025-02-15 1306/week @ 2025-02-22 670/week @ 2025-03-01

3,657 downloads per month
Used in kitoken

BSD-2-Clause

8KB
78 lines

sentencepiece-model

Crates.io Docs.rs

SentencePiece model parser generated from the SentencePiece protobuf definition.

use sentencepiece_model::SentencePieceModel;

let model = SentencePieceModel::from_file("tests/t5-spiece.model")?;
assert_eq!(model.pieces.len(), 32000);
assert_eq!(model.trainer()?.unk_id(), 2);

Usage

[dependencies]
sentencepiece-model = "0.1"

sentencepiece-model uses prost-build and protox to generate Rust code from the SentencePiece protobuf definition at build time. protoc is not required.


lib.rs:

SentencePiece model parser generated from the SentencePiece protobuf definition.

See SentencePieceModel for the entry point for parsing and accessing sentencepiece models.

use sentencepiece_model::SentencePieceModel;

let model = SentencePieceModel::from_file("tests/t5-spiece.model")?;
assert_eq!(model.pieces.len(), 32000);
assert_eq!(model.trainer().unwrap().unk_id(), 2);

Dependencies

~0.3–2.5MB
~36K SLoC