fastokens
What it is and what it does
fastokens is a Rust-backed tokenizer designed to accelerate BPE encoding for large language models. It loads both HuggingFace tokenizer.json files and tiktoken model files, and ships prebuilt wheels for Python 3.9+ across major platforms, eliminating the need to compile Rust code during installation.
The main use case is speeding up tokenization in inference pipelines where prompt encoding becomes a bottleneck. It includes features like vocabulary extension through add_tokens and add_special_tokens, optional prefix caching for shared system prompts, and PCRE2 resource limits to guard against pathological regex patterns. The package can be used standalone or integrated with serving frameworks.
Use it for:
- Accelerate tokenization in inference pipelines to reduce encoding latency on large prompts.
- Tokenize long contexts faster by enabling the optional prefix cache for repeated system prompts.
- Load and use tiktoken models (e.g., cl100k_base or o200k_base) directly without additional dependencies.
- Extend model vocabularies by adding placeholder tokens to match padded embedding matrices.
- Replace default tokenizers in production serving to improve time-to-first-token metrics.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
fastokens is a high-performance BPE tokenizer for large language models, built on a Rust backend and compatible with HuggingFace tokenizer.json and tiktoken model formats.
Yes, if you need faster tokenization in LLM inference and your model is among the tested families (Qwen, Kimi, Minimax, Gemma, DeepSeek) or you verify compatibility. The prebuilt wheels and zero runtime dependencies make installation frictionless. However, verify the license status in the repository before use in proprietary projects, and confirm that unsupported tokenizer features do not block your use case.
Install
fastokens on PyPI
pip
pip install fastokensuv
uv add fastokenspoetry
poetry add fastokensInstalling fastokens
Before you install
Prebuilt wheels for Python 3.9+ across Linux, macOS, and Windows minimize installation friction. The package is actively maintained with a recent release and no known vulnerabilities.
License in practice
License status is unclear; no SPDX identifier or raw license text is available in the package metadata. Verify the repository's LICENSE file before adopting in proprietary or copyleft-sensitive projects.
Quickstart
pip install fastokens
from fastokens._native import Tokenizer
tokenizer = Tokenizer.from_model("deepseek-ai/DeepSeek-V3.2")
tokens = tokenizer.encode("A very long prompt that is now lightning fast.")
Requires Python 3.9 or later.
Verify before relying
- Whether the 10x+ performance improvement claim applies to your specific workload and model size.
- Exact scope of features not supported compared to the tokenizers library.
- Whether your target model is among the tested families (Qwen, Kimi, Minimax, Gemma, DeepSeek) or requires verification.
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 10 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 551,217/month — #6,051 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fastokens-0.3.1-cp39-abi3-macosx_10_12_x86_64.whl; fastokens-0.3.1-cp39-abi3-macosx_11_0_arm64.whl; fastokens-0.3.1-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl; fastokens-0.3.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; fastokens-0.3.1-cp39-abi3-manylinux_2_28_aarch64.whl; fastokens-0.3.1-cp39-abi3-manylinux_2_28_armv7l.whl; fastokens-0.3.1-cp39-abi3-manylinux_2_28_ppc64le.whl; fastokens-0.3.1-cp39-abi3-musllinux_1_2_aarch64.whl; fastokens-0.3.1-cp39-abi3-musllinux_1_2_armv7l.whl; fastokens-0.3.1-cp39-abi3-musllinux_1_2_i686.whl; fastokens-0.3.1-cp39-abi3-musllinux_1_2_x86_64.whl; fastokens-0.3.1-cp39-abi3-win_amd64.whl
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
tokieA fast, Rust-backed tokenizer library that…
permissive · top 15,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
pytorch-tokenizersProvides C++ implementations of multiple…
permissive · top 15,000 on PyPI
json-stream-rs-tokenizerA Rust-based JSON tokenizer that accelerates…
unclear · top 5,000 on PyPI
blingfireBlingfire provides fast tokenization and text…
permissive · top 5,000 on PyPI
pytokenspytokens is a Python tokenizer that parses…
permissive · top 1,000 on PyPI
curated-tokenizersProvides BPE, Byte BPE, Unigram, and Wordpiece…
permissive · top 5,000 on PyPI
toonstoons is a Rust-backed Python parser and…
unclear · top 5,000 on PyPI
outlines-coreOutlines-core provides structured text…
permissive · top 5,000 on PyPI