--- id: tokie version: "0.1.4" license: MIT OR Apache-2.0 license_treatment: permissive maintenance: active --- # tokie — Blazingly fast tokenizer — 50x faster, 10x smaller, 100% accurate License: permissive · Maintenance: active · Downloads: 487.3K/mo ## 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 above — 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 pip install tokie uv add tokie poetry add tokie ## Installing 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_current - Install friction: medium - Maintenance: active - Downloads: 487.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags fast tokenizer for transformers, huggingface tokenizer replacement, bpe wordpiece tokenization, rust tokenizer python, token encoding decoding, batch tokenization, bert gpt2 tokenizer, rust-backed, transformers, nlp [View on SkillFed](https://skillfed.io/packages/tokie) · [View on PyPI](https://pypi.org/project/tokie/)