SmolToken
SmolToken is a fast library for tokenizing text using the Byte Pair Encoding (BPE) algorithm. Inspired by OpenAI's tiktoken, SmolToken is designed to fill a critical gap by enabling BPE training from scratch while maintaining high performance for encoding and decoding tasks.
Unlike tiktoken, SmolToken supports training tokenizers on custom data. Up to ~4x faster than the port of unoptimized educational implementation _educational.py in rust.
Benchmark Results
SmolToken is already faster than baseline educational implementation of BPE training:
| Implementation | Runtime (sec) |
|---|---|
| Unoptimized Implementation | 36.94385 |
| SmolToken Optimized | 17.63223 |
| SmolToken (with rayon) | 7.489850 |
Tested on:
- Vocabulary size: 500
- Dataset: Tiny Stories (~18 MB)
Installation
Add smoltoken to your Rust project via crates.io:
cargo add smoltoken
Or add smoltoken to your Python project via PyPI:
pip install smoltoken
Features
- Concurrency: Multi-threading support with rayon for accelerated training, encoding, and decoding processes.
- Python Bindings: Seamless integration with Python via PyO3, enabling accessibility for Python developers.
- Serialization: Support for saving and loading trained tokenizer vocabulary through serialization.
Contributing
We very much welcome contributions to make Smoltoken fast, robust and efficient. Make a fork, create a feature branch if needed and sumbit your pull request. Since, the library itself is in its early release stage, I also expect to get community feedback to improve on. Just raise an issue here and we will fix them promptly.
License
SmolToken is open source and licensed under the MIT License.
Acknowledgements
Special thanks to OpenAI's tiktoken for inspiration and foundational ideas.
Metadata
Release files for smoltoken 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 18.6 MB
Release files / smoltoken-0.1.4-cp313-cp313-win_amd64.whl
| Download URL | smoltoken-0.1.4-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9769f60fad99605dd9571d1de41f950fb1c0ddf6b0401d2ce061220aa282312f
|
|
BLAKE2b-256 checksum How to use checksums |
cee9a55b10e930c7655d97f366fc85f034f9c926e20036aa3c15529e90b52665
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp313-cp313-musllinux_1_2_x86_64.whl
| Download URL | smoltoken-0.1.4-cp313-cp313-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.13 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
907c8394f11fe4b614a76e4b90d0433b2685549b34126fe0d62db22a36b85ce1
|
|
BLAKE2b-256 checksum How to use checksums |
30ff09e002fdf2243f2f5b02e94e5c406c83db802d2f6c2dbe7f4598bb2838df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | smoltoken-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
98da8e72a401d1fe7eb16c86ee670df66d03f159b0d86cbe6b268e3de2d418f2
|
|
BLAKE2b-256 checksum How to use checksums |
9555254ca9772a5474158b8b218c10de09818a647c5b624073a10723d65534af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | smoltoken-0.1.4-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0e794f66c93a8bc1c3616ba8717027415f8ddf08dd5f6c9f2bae9231c8798d34
|
|
BLAKE2b-256 checksum How to use checksums |
a17d63c659dac48051fdccea60f6695c01c12406c9bd47800230af5a73ab4219
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | smoltoken-0.1.4-cp313-cp313-macosx_10_13_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.13 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
1fdf83d41ae0d07babd2384b86574d6c756cb347548a524f888f1368644196ac
|
|
BLAKE2b-256 checksum How to use checksums |
e02bfeb943f4741819e14c4228101dfd47d3b4f96f99c6c01f4566ead8bad3ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp312-cp312-win_amd64.whl
| Download URL | smoltoken-0.1.4-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9a20a73fbe5fd45a5b76ef5f9ee7eae4b3f148497da5aedc4c7432f39a4bdb06
|
|
BLAKE2b-256 checksum How to use checksums |
220235dd3fa0594830d8bd1079d0b3fdb27c51c44221fe3b1a2b11f7904df8f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp312-cp312-musllinux_1_2_x86_64.whl
| Download URL | smoltoken-0.1.4-cp312-cp312-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
a04d3009f9df6376eee81f29d164f0a711e37529be23184b387571687b942ec5
|
|
BLAKE2b-256 checksum How to use checksums |
0e364cb6b5b544fe8563881299946aa44258c71851cd4bb0acecc3e8e5fa14ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | smoltoken-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
ee49442cc72cea63af358e425f475589ef66b584a8d0ce9d6186b948737c874f
|
|
BLAKE2b-256 checksum How to use checksums |
527650a75afb299a74a1eca0fada90d24eb89f8fc3aa0c222e37bf2ecf01d90b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | smoltoken-0.1.4-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d9ae7e2af8a5636ef49084eb52d5c3292050a834dbe7143cb324503c7c705668
|
|
BLAKE2b-256 checksum How to use checksums |
c91a75c80057db50232de45dc24a0538b8be628ecc12e80f157a981beb2df519
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | smoltoken-0.1.4-cp312-cp312-macosx_10_13_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.12 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
ba05ea1dfbc36a0bed00852cd2395aff39d244de304b8fd2e13a469dc9211aa2
|
|
BLAKE2b-256 checksum How to use checksums |
08d37dc11c3dfe5a1e46074664a61c974c5ff69b6dc93ea87b17929d4f47badc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp311-cp311-win_amd64.whl
| Download URL | smoltoken-0.1.4-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fea6a733de27983a90639041bc3f294da706488af8658f76d9a3435026d1d5be
|
|
BLAKE2b-256 checksum How to use checksums |
40d1555d3f4e7c409d96fd48470a9976b5b957fe472e3bca21d8d0a1d6bad755
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp311-cp311-musllinux_1_2_x86_64.whl
| Download URL | smoltoken-0.1.4-cp311-cp311-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
feb99a7b1a102f678aaaab6dd2e2cf3af971c3d40941f78c5b9ca20960b79827
|
|
BLAKE2b-256 checksum How to use checksums |
ac3a1a76688d2edeee7e82375e1ef1b7a98a4a04fe8fb0419ac78d55953de866
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | smoltoken-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
23f1c9767016297be760e3ba59f5f1928bb9acd5006acda04ce3062a3f11ebc1
|
|
BLAKE2b-256 checksum How to use checksums |
626dbe57e7d97593391636625d56eeaeea7596b96a31bd4ae0b9fee6f88e3c0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | smoltoken-0.1.4-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
499aa0c6766e6f6f72ac879f6f7b6acdbb6f747a5430b9376bce2c3026fa6ef3
|
|
BLAKE2b-256 checksum How to use checksums |
e3506aef34602254b8c7494aa90bbb8a6274e0e6a3a4b1a331e06d09a5f7fbbd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / smoltoken-0.1.4-cp311-cp311-macosx_10_12_x86_64.whl
| Download URL | smoltoken-0.1.4-cp311-cp311-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.11 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
6ba90e96a504c5f6c97c0207fc32d24d6d965b2dee34b705c687b0eb700a46fd
|
|
BLAKE2b-256 checksum How to use checksums |
a1fbacd9dcdc27cbc1405ac5438cccb985be7943c731c2a244bfffdb65415402
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for smoltoken 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.