kute-engine 0.9.0

Kannaka Universal Tokenization Engine: the engine facade with all built-in algorithms and adapters
Documentation

kute-engine

The Kannaka Universal Tokenization Engine: train, store and apply vocabularies for text, bytes, structured records and event sequences. The library is imported as kute.

[dependencies]
kute = { package = "kute-engine", version = "0.2" }
use kute::{AdapterConfig, Engine, Pretokenizer, TrainingConfig, VocabularyId};

let engine = Engine::new();
let mut config = TrainingConfig::new(VocabularyId::parse("example:words")?, 1000);
config.pretokenizer = Pretokenizer::Gpt4;
let corpus = vec![std::fs::read("corpus.txt")?];
let vocabulary = engine.train("bpe", "text", &AdapterConfig::default(), &corpus, &config)?;

let tokenizer = engine.tokenizer(vocabulary)?;
let tokens = engine.encode_raw(tokenizer.as_ref(), b"some text")?;
assert_eq!(engine.decode_raw(tokenizer.as_ref(), &tokens)?, b"some text");

The command line tool is kute-cli (cargo install kute-cli installs the kute command) and the Python package is kute-engine on PyPI.

Documentation, specifications and benchmark results are in the repository. Experimental: formats and APIs may change before 1.0.

Licensed under MIT or Apache-2.0, at your option.