Skip to main content

UBPE Tokenizer

Project description

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 algorithm
  • UBPE -- 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

Roadmap

  • Python native implementation
  • Cython implementation with C++ backend
    • Publish standalone C++ library (it is already usable)
    • Other types than uint32_t as 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]

[!NOTE] Starting with version 0.3, the C++ backend has become faster while the native one has become slower, so there's no reason to use the native backend except for educational purposes.

[!NOTE] While Google Colab is supported, interactive logging doesn't work in it due to complications with redirecting stderr to the cell output.

[!WARNING] Encoding candidates from different backends of the novel tokenizer (UBPE) may differ in order, i.e. two encodings with the same length and weight may be returned in different ordered, but are still valid.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ubpe-0.3.0rc0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file ubpe-0.3.0rc0-py3-none-any.whl.

File metadata

  • Download URL: ubpe-0.3.0rc0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ubpe-0.3.0rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 ecc9babdf1a48812aeca8b6b1410760f9ab11c906a94d2330727274f23b1cd3c
MD5 c51bb63935c9263e835091035b9e4c78
BLAKE2b-256 02d6ebe297b70c808fe7a99c40c22b2a59c2e3dd7be68fe52d5e54bd525e4ce7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ubpe-0.3.0rc0-py3-none-any.whl:

Publisher: pypi-publish.yml on Scurrra/ubpe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page