pytorch-tokenizers
A package with common tokenizers in Python and C++
What it is and what it does
pytorch-tokenizers is a Meta-maintained package that bundles C++ implementations of multiple tokenizer algorithms—SentencePiece, Tiktoken, Huggingface-compatible, Llama2.c, and Tekken—with Python bindings. It's designed to support PyTorch-based LLM inference pipelines, particularly within the ExecuTorch and AOT Inductor stacks. The package wraps existing tokenizer implementations (adapted from Google's SentencePiece, Mistral's Tekken, and others) and exposes them as a unified Python interface.
The package depends on tiktoken, tokenizers, and sentencepiece as runtime dependencies, meaning it acts as a thin wrapper and orchestration layer rather than reimplementing tokenization from scratch. Tekken support includes special token recognition, multilingual Unicode handling, and emoji support. The package is actively maintained, supports Python 3.10 through 3.14, and distributes precompiled wheels for common platforms, reducing build friction for most users.
Use it for:
- Building LLM inference engines with ExecuTorch by selecting and configuring the appropriate tokenizer for model deployment.
- Preprocessing text for Mistral-based models using Tekken tokenizer with special token and multilingual support.
- Integrating multiple tokenizer backends into a single PyTorch application without managing separate dependencies.
- Developing AOT Inductor-based LLM runners that require efficient, compiled tokenization.
- Handling multilingual and emoji-rich text in production LLM pipelines with Tekken's Unicode support.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides C++ implementations of multiple tokenizers (SentencePiece, Tiktoken, Huggingface, Llama2.c, Tekken) with Python bindings for use in PyTorch-based LLM applications and ExecuTorch runners.
Yes, with conditions. Install if you are building LLM inference on ExecuTorch or AOT Inductor and need a unified tokenizer interface with prebuilt wheels. The package is actively maintained, permissively licensed, and has no known vulnerabilities. Avoid if you need only a single tokenizer (use the underlying dependency directly) or if you require Python versions below 3.10. The early release status (Beta, first release 2025-10-20) suggests API stability should be verified for production use.
Install
pytorch-tokenizers on PyPI
pip
pip install pytorch-tokenizersuv
uv add pytorch-tokenizerspoetry
poetry add pytorch-tokenizersInstalling pytorch-tokenizers
Before you install
Medium install friction due to compiled C++ components; prebuilt wheels available for Python 3.10–3.14 across macOS ARM64, Linux x86_64/aarch64, and Windows. Recently active (last commit 2026-08-05, release 9 days old) with maintained repository status.
License in practice
BSD 3-Clause permissive license allows commercial and private use with attribution; additional code covered by MIT and Apache licenses. No restrictions on derivative works or redistribution.
Quickstart
pip install pytorch-tokenizers
from pytorch_tokenizers import SentencePieceTokenizer
tokenizer = SentencePieceTokenizer(model_path="model.model")
tokens = tokenizer.encode("Hello world")
Requires Python 3.10 or later; C++ build dependencies needed if installing from source (git clone and submodule setup required).
Verify before relying
- Performance characteristics and throughput compared to alternative tokenizer implementations.
- Specific version compatibility with ExecuTorch and torchchat ecosystems.
- Tekken tokenizer's claimed 100% decode accuracy and test coverage scope.
- Whether all tokenizer implementations (SentencePiece, Tiktoken, Huggingface, Llama2.c, Tekken) are production-ready or some remain experimental.
Package facts
| License | BSD 3-Clause License Copyright (c) 2024 Meta Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 3 — tiktoken, tokenizers, sentencepiece |
| Maintenance | actively maintained — 9 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 452,674/month — #6,581 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytorch_tokenizers-1.4.1-cp310-cp310-macosx_14_0_arm64.whl; pytorch_tokenizers-1.4.1-cp310-cp310-manylinux_2_28_aarch64.whl; pytorch_tokenizers-1.4.1-cp310-cp310-manylinux_2_28_x86_64.whl; pytorch_tokenizers-1.4.1-cp310-cp310-win_amd64.whl; pytorch_tokenizers-1.4.1-cp311-cp311-macosx_14_0_arm64.whl; pytorch_tokenizers-1.4.1-cp311-cp311-manylinux_2_28_aarch64.whl; pytorch_tokenizers-1.4.1-cp311-cp311-manylinux_2_28_x86_64.whl; pytorch_tokenizers-1.4.1-cp311-cp311-win_amd64.whl; pytorch_tokenizers-1.4.1-cp312-cp312-macosx_14_0_arm64.whl; pytorch_tokenizers-1.4.1-cp312-cp312-manylinux_2_28_aarch64.whl; pytorch_tokenizers-1.4.1-cp312-cp312-manylinux_2_28_x86_64.whl; pytorch_tokenizers-1.4.1-cp312-cp312-win_amd64.whl; pytorch_tokenizers-1.4.1-cp313-cp313-macosx_14_0_arm64.whl; pytorch_tokenizers-1.4.1-cp313-cp313-manylinux_2_28_aarch64.whl; pytorch_tokenizers-1.4.1-cp313-cp313-manylinux_2_28_x86_64.whl; pytorch_tokenizers-1.4.1-cp313-cp313-win_amd64.whl; pytorch_tokenizers-1.4.1-cp314-cp314-macosx_14_0_arm64.whl; pytorch_tokenizers-1.4.1-cp314-cp314-manylinux_2_28_aarch64.whl; pytorch_tokenizers-1.4.1-cp314-cp314-manylinux_2_28_x86_64.whl; pytorch_tokenizers-1.4.1-cp314-cp314-win_amd64.whl
Keywords: pytorch, machine learning, llm
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
mistral_commonProvides tokenizers, validation, and…
permissive · top 5,000 on PyPI
torchtexttorchtext provides text datasets, preprocessing…
permissive · top 15,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
tokieA fast, Rust-backed tokenizer library that…
permissive · top 15,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
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
pytorch-pretrained-bertProvides PyTorch implementations of BERT, GPT,…
permissive · top 15,000 on PyPI
llmcompressorllmcompressor optimizes large language models…
permissive · top 15,000 on PyPI
torchtunetorchtune is a PyTorch library for fine-tuning,…
permissive · top 15,000 on PyPI