MayaTok
MayaTok is a Byte-Pair Encoding (BPE) tokenizer written in Rust. Built with performance and extensibility in mind. I made this project just because I wanted to study how Byte Pair Encoding Works.
Version: 2.1.4
⚡️ Features
-
Multithreaded training for fast vocab generation
-
Persistent merges
-
Checkpoint saving
-
Focus on raw speed — built for performance benchmarking
🚀 Installation
Prerequisites
- Rust (required for 'from source' approach)
- Python 3.9+ (for Python bindings)
PIP Installation
pip install mayatok
From Source
git clone https://github.com/AlgoBrother/MayaTok-BPE.git
cd mayatok-bpe
Use maturin for building wheels.
pip install maturin
maturin build --release
pip install target/wheels/*.whl
Quick Start
Using with Python
To use MayaTok with Python:
import mayatok as bpe
my_tokenizer = bpe.get_tokenizer("vb100k") # or 'mayatok-base' if you wish to use v1 tokenizer
test = "Hello, world!"
tokens = my_tokenizer.encode(test)
print(tokens)
decoded_text = my_tokenizer.decode(tokens)
print(decoded_text)
Output of the sample code above
[11617, 77, 3646, 62]
Hello, world!
If you want to create your own Vocab
If you are using HuggingFace Datasets, refer to this for creating your own vocab.
If your dataset is in your local machine
Make sure you have forked/cloned the rust tokenizer code and have built the /target/wheels as mentioned in previous steps
stream method - If you have a large dataset and want to stream your data in chunks to not overload your machine. Use this.
non-stream method - If you have a dataset which your RAM can handle after being loaded, use this for much faster training.
📈 Benchmarks
Batch Encoding
| Tokenizer | Tokens/sec | Avg Compression Ratio |
|---|---|---|
| MayaTok-BPE | 2,277,698 | 3.92 |
| tiktoken-cl100k | 284,016 | 4.11 |
| tiktoken-p50k | 268,657 | 4.08 |
| GPT2 | 1,107,899 | 4.04 |
| Falcon-7B | 938,424 | 4.07 |
Normal Encoding
| Tokenizer | Tokens/sec | Compression Ratio |
|---|---|---|
| MayaTok | 302,276 | 3.92 |
| tiktoken-cl100k | 678,801 | 4.11 |
| tiktoken-p50k | 750,891 | 4.08 |
| GPT2 | 215,831 | 4.04 |
| Falcon-7B | 177,707 | 4.07 |
Note: For [Tokens/sec], the benchmark is general average of multiple runs of examples\benchmark.py resulted in. You may find different results when you test it in your own systems.
Performance optimizations are ongoing
💽 Corpus Used for V2
cosmopedia-v2
c4-english
wikipedia
openwebtext
github-top-code
arxiv-papers
Check dataset_training/train.py for more details
🙌 Contributing
Pull requests and suggestions are welcome! Feel free to open issues for bugs, feature requests, or optimizations.
📄 License
Apache-2.0
Future Targets [3.0]
- Training a multilingual vocab
- Better Compression
- Still Thinking
Metadata
Release files for mayatok 2.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mayatok-2.1.5.tar.gz | 485.5 kB | Without provenance | Details for mayatok-2.1.5.tar.gz |
Built distributions (wheels)
Total release size: 102.8 MB
Release files / mayatok-2.1.5.tar.gz
| Download URL | mayatok-2.1.5.tar.gz |
|---|---|
| Size | 485.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db7c43cc2f117af5a0469199498b156866d74f3c416139e7bfe8b376ecc812af
|
|
BLAKE2b-256 checksum How to use checksums |
ded45993b3677a25ba1a9d9690403c2435148b7d3fdb9e1ca73ea21f16ee17a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp312-cp312-win_amd64.whl
| Download URL | mayatok-2.1.5-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
609473ac167b0b79427c1f1b416a7f1b1a2fd88ccd47d2d5ec0b206fcbfec881
|
|
BLAKE2b-256 checksum How to use checksums |
bf2ed4e17cfdc892adda29301ed05e9700b178dce9b0247987d674d34177f857
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mayatok-2.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 20.2 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
2dd7b8bc0d9fd3a304b8192cc02c45ab6ab12b5adcc950ac0f3690b897e3ff65
|
|
BLAKE2b-256 checksum How to use checksums |
0150fd5e650e7b3fecd45925b4ffc3103af1e730a713657e1b80fd8033e2e524
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | mayatok-2.1.5-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
23831a64740207e565967cdb20ee846136b09129a947b82f23ded2f27ba626bc
|
|
BLAKE2b-256 checksum How to use checksums |
1a06bcc296be0d8e5c1c76da69446acea5132fff16b839e4cb1a378ad13c78f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp312-cp312-macosx_10_12_x86_64.whl
| Download URL | mayatok-2.1.5-cp312-cp312-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.12 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
e4814be8dfc77c06fdac92a3eecac02b240a37a709fd605e1db5662aaaf38969
|
|
BLAKE2b-256 checksum How to use checksums |
95e726d1efa71bfbc2b5114af1bc031fe5472ee64d614cd752638a14f36a1bea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mayatok-2.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 20.2 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
14976000d68fc3bfa32796cff0a0b499b285a269e2c24471132ac4530c891ee5
|
|
BLAKE2b-256 checksum How to use checksums |
ee44ac0e97da3f57619d636cd40dc584814df4ac81c97bf0a62e24caade7c036
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | mayatok-2.1.5-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e9736c856fdec8730ebdfa2fadd772b0a6ffb726b03e86e705ccfe9dd0a539b9
|
|
BLAKE2b-256 checksum How to use checksums |
2c3efe22f05b31cac4fecb1fd82904c76c1a29a413d40712121b13d4b0f6dc69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp311-cp311-macosx_10_12_x86_64.whl
| Download URL | mayatok-2.1.5-cp311-cp311-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.11 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
b9772bfd2ae006a86318c9120063591c44d4d5ff7c3981187d5f1d758e5f885a
|
|
BLAKE2b-256 checksum How to use checksums |
39391b7165f34b262a96e8737151d9566362f0eb6a26cf4e232d57b12c9f712e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mayatok-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 20.2 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
2a9a20bc34415942e684cfd404f678b006ba3d7728a53723db03011f9c44f890
|
|
BLAKE2b-256 checksum How to use checksums |
de9d74d629bb76d75dd5701875249b6a26e7fd03ab2e5b652c380c8eb344b8aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | mayatok-2.1.5-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e8c571dff4ed51a558199bcb897fd43378cd4c58774d55bc6f3f222b7648a544
|
|
BLAKE2b-256 checksum How to use checksums |
200a6f227a8d01604c8567c548d0bc95b3884ba52d8194a6c692e9196ac86c3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp310-cp310-macosx_10_12_x86_64.whl
| Download URL | mayatok-2.1.5-cp310-cp310-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.10 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
7ffd4ff191dd323481b552066b47fa7868a1564d918e39cb570b9cd91e05a5d8
|
|
BLAKE2b-256 checksum How to use checksums |
f8bc4b97d6b6b378ee343ee49210c11a1f99f49f1b41b0c55a3515b0836c7f27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mayatok-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 20.2 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
b22f87a5b29c90e119e49b01e48da65f5e8b00df96f9c572dc569272e05b6c9c
|
|
BLAKE2b-256 checksum How to use checksums |
2aba9d010d0eab746434a9e6f5f2070bc2e9062f5717a5df0a2edc1d09fbb00b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp39-cp39-macosx_11_0_arm64.whl
| Download URL | mayatok-2.1.5-cp39-cp39-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.9 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
55e8e8f0adadc9a53b6c624cdfb2a0b0b4917322894fd66387280cd7bfd90206
|
|
BLAKE2b-256 checksum How to use checksums |
0a1f9293eac3cc2d3fd4c20f9d20b2f67e91ca33b069e10d7dac46a513d768aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / mayatok-2.1.5-cp39-cp39-macosx_10_12_x86_64.whl
| Download URL | mayatok-2.1.5-cp39-cp39-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.9 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
a6d8a08c18651fdb05cfa62a02b60181f0355d722a6ae976c017fc62993bfc2d
|
|
BLAKE2b-256 checksum How to use checksums |
9e5b1f601525850160336e9d4edd4811515aca9e72d2b6a3f85d354a1651f536
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Security for mayatok 2.1.5
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.