tokie
Blazingly fast tokenizer — 50x faster, 10x smaller, 100% accurate
What it is and what it does
tokie is a tokenizer library written in Rust with Python bindings that converts text into token IDs and metadata for transformer models. It supports BPE (used by GPT-2 and tiktoken), WordPiece (BERT), and Unigram encoders, and can load any HuggingFace tokenizer model directly. The library is designed as a drop-in replacement for HuggingFace's tokenizers package, offering substantially faster encoding and decoding through its Rust implementation.
The package handles common tokenization workflows: single-text encoding, batch encoding across multiple CPU cores, pair encoding for cross-encoder models, padding and truncation, byte-offset tracking, and token counting. It also provides a compact binary .tkz format for model storage that is significantly smaller than the standard tokenizer.json format. No runtime dependencies are required beyond Python itself.
Use it for:
- Accelerate batch tokenization in production NLP pipelines where throughput matters (e.g., preprocessing large datasets for model training).
- Replace HuggingFace tokenizers in latency-sensitive applications like real-time inference or API endpoints.
- Reduce model artifact size by storing tokenizers in .tkz format instead of tokenizer.json for deployment.
- Tokenize text for BERT, GPT-2, Llama, Mistral, and other transformer models without rewriting tokenization logic.
- Count tokens quickly without creating full encoding objects, useful for prompt length validation in LLM applications.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A fast, Rust-backed tokenizer library that encodes and decodes text using BPE, WordPiece, and Unigram algorithms, compatible with HuggingFace tokenizer models.
Yes, if you are tokenizing text for transformer models and speed or model size matters. The package is actively maintained, has no known vulnerabilities, supports current Python versions, and offers a permissive dual license. Install friction is moderate due to compiled wheels, but prebuilt binaries cover common platforms. Not necessary if your tokenization is already fast enough or if you need features not yet documented in the fact sheet.
Install
tokie on PyPI
pip
pip install tokieuv
uv add tokiepoetry
poetry add tokieInstalling tokie
Before you install
Medium install friction due to compiled wheels, but prebuilt binaries are available for modern Python versions (3.10–3.14) across macOS, Linux, and Windows. Repository is active with a recent release (21 days old) and no known vulnerabilities.
License in practice
Dual-licensed under MIT OR Apache-2.0, both permissive; you may choose either license when using or distributing this package.
Quickstart
pip install tokie
import tokie
tokenizer = tokie.Tokenizer.from_pretrained("bert-base-uncased")
encoding = tokenizer("Hello, world!")
print(encoding.ids) # [101, 7592, 1010, 2088, 999, 102]
Requires Python 3.10 or later; prebuilt wheels are available for CPython on common platforms.
Verify before relying
- Whether .tkz format is backward-compatible across tokie versions or requires re-serialization after updates.
- Performance characteristics on very large batches or streaming use cases beyond the provided benchmarks.
- Whether all HuggingFace tokenizer edge cases (custom tokens, special token handling) are fully supported.
Package facts
| License | MIT OR Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 21 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 487,336/month — #6,386 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tokie-0.1.4-cp310-cp310-macosx_10_12_x86_64.whl; tokie-0.1.4-cp310-cp310-macosx_11_0_arm64.whl; tokie-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; tokie-0.1.4-cp310-cp310-manylinux_2_28_aarch64.whl; tokie-0.1.4-cp310-cp310-win_amd64.whl; tokie-0.1.4-cp311-cp311-macosx_10_12_x86_64.whl; tokie-0.1.4-cp311-cp311-macosx_11_0_arm64.whl; tokie-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; tokie-0.1.4-cp311-cp311-manylinux_2_28_aarch64.whl; tokie-0.1.4-cp311-cp311-win_amd64.whl; tokie-0.1.4-cp312-cp312-macosx_10_12_x86_64.whl; tokie-0.1.4-cp312-cp312-macosx_11_0_arm64.whl; tokie-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; tokie-0.1.4-cp312-cp312-manylinux_2_28_aarch64.whl; tokie-0.1.4-cp312-cp312-win_amd64.whl; tokie-0.1.4-cp313-cp313-macosx_10_12_x86_64.whl; tokie-0.1.4-cp313-cp313-macosx_11_0_arm64.whl; tokie-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; tokie-0.1.4-cp313-cp313-manylinux_2_28_aarch64.whl; tokie-0.1.4-cp313-cp313-win_amd64.whl
Keywords: tokenizer, tokenization, bpe, wordpiece, sentencepiece, bert, gpt2, llama, nlp, embedding, rag, transformers, huggingface, fast, rust
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
curated-tokenizersProvides BPE, Byte BPE, Unigram, and Wordpiece…
permissive · top 5,000 on PyPI
fastokensfastokens is a high-performance BPE tokenizer…
unclear · top 15,000 on PyPI
pytorch-tokenizersProvides C++ implementations of multiple…
permissive · top 15,000 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
blingfireBlingfire provides fast tokenization and text…
permissive · top 5,000 on PyPI
openvino-tokenizersConverts HuggingFace tokenizers into OpenVINO…
permissive · top 15,000 on PyPI
sentencepieceSentencePiece is an unsupervised text tokenizer…
permissive · top 1,000 on PyPI
spacy-alignmentsAligns tokenizations between spaCy and…
permissive · top 15,000 on PyPI
stop-sequencerAdds stop-sequence support to Huggingface…
unclear · top 15,000 on PyPI