UBPE Tokenizer
UBPE -- Universal Byte-Pair Encoding. Universal means that it works not only with strings, but with general sequences too.
The package provides Universal Byte-Pair Encoding tokenizers:
UBPEClassic-- optimized version of classic BPE algorithmUBPE-- novel approach to BPE tokenization which allows you to choose between multiple different variants of encodings according to scores of tf-idf metric or something else; the most optimal encoding from this implementation was shorter than the encoding from classic implementation
Guides and theory
- Description of tokenizer fitting algorithms
- Description of encoding and decoding algorithms for classic and novel approaches
- Google Colab Demo for
ubpe v0.2(with precomputed cells) - Google Colab Demo for
ubpe v0.3(with precomputed cells)
Roadmap
- Python native implementation
- Cython implementation with C++ backend
- Publish standalone C++ library (it is already usable)
- Other types than
uint32_tas inner token type
- Rust backend with standalone package
- Subdocument tokenization (since v0.3)
- RegEx support
- Support for known word tokens in alphabet
- Ignored tokens
- Collaborative training
- Training checkpoints
- Training on large datasets
- Training on splitted datasets
- Other Features:
- One token -- Many subsequences
- Spelling correction support
- Vocabulary pruning
- Examples:
- Demo with visualizaton of pros of the UBPE novel algorithm
- Subdocument tokenization example
Installation
It is planned to deliver different implementations for the algorithm, so the package is divided into general import package (this one), and implementations (for now, Python native and Cython with C++20 backend). To install use:
pip install ubpe[native]
Or,
pip install ubpe[cython]
Bug reports
If you find a bug that occurs under certain circumstances in some tests, please report it.
Contribution
Bugfixes and optimizations are welcomed!
P.S. if you are working at Hugging Face or OpenAI, you can write me and hire me. Please.
Metadata
Release files for ubpe 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ubpe-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for ubpe-0.3.0-py3-none-any.whl |
Release files / ubpe-0.3.0-py3-none-any.whl
| Download URL | ubpe-0.3.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e73d9b7d863466823cfa34b8d1fd8e160d8efe3859ceb6585948a45201436a71
|
|
BLAKE2b-256 checksum How to use checksums |
ff793f2d5896487c997b4e55d5e55ebc8032927e6e232b767d6d0abaa8bb4765
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.
Transparency logSecurity for ubpe 0.3.0
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.
Full provenance
1 file in this release has been uploaded with provenance metadata.
Attestation for ubpe-0.3.0-py3-none-any.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.
Transparency logA 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.