🔤 LexiByte Engine ("Lexi")
LexiByte is a production-grade, algorithmically optimized Byte-Pair Encoding (BPE) tokenizer, inspired by the architecture used in modern Large Language Models (LLMs) like GPT-2, GPT-4, and Llama.
Built entirely in Python, LexiByte bridges the gap between raw text and Neural Networks by safely compressing UTF-8 byte streams into integer token sequences.
✨ Production-Grade Features
- Sennrich Frequency Optimization: Escapes the $O(N^2)$ training bottleneck by compressing the corpus into a frequency dictionary. It trains on millions of words in seconds by mathematically weighting unique pairs.
- Inference Memoization Cache: Bypasses BPE loops during inference by caching tokenized sequences, delivering $O(1)$ constant time lookups for previously seen words.
- Regex Pre-Splitting Guardrails: Implements GPT-2/GPT-4 style regex boundaries to prevent unnatural merges (e.g., merging punctuation with words, or trailing spaces with letters).
- UTF-8 Byte Level Base: Starts with a base vocabulary of 256 standard UTF-8 bytes, meaning it can theoretically encode any string (including emojis and non-English scripts) without out-of-vocabulary (OOV) errors.
- Special Token Support: Safely handles control tokens (e.g.,
<|endoftext|>).
📚 Documentation
Detailed documentation has been separated into the following guides:
- Architecture & Internal Mechanics - Understand how BPE works, why regex guardrails matter, and view visual pipeline diagrams.
- Training & Inference Deep Dive -
A concrete, step-by-step look at how the
mergesandvocabmaps are built and how production optimization works. - Usage Guide - Step-by-step instructions on training, encoding, decoding, and saving your tokenizer.
🚀 Quick Start
Installation (For Users)
You can install LexiByte directly from PyPI using pip.
pip install lexibyte
(If you are developing locally from the source repository, run pip install -r requirements.min.txt instead).
Basic Example
from lexibyte import LexiByteTokenizer
# Initialize tokenizer
tokenizer = LexiByteTokenizer()
# Sample corpus
text = "hello world! 👋 This is the LexiByte engine."
# Train the tokenizer to reach a vocabulary of 276 (256 base bytes + 20 learned merges)
tokenizer.train(text, vocab_size=276, verbose=True)
# Encode text to token IDs
encoded = tokenizer.encode("hello world!")
print("Encoded:", encoded)
# Decode token IDs back to text
decoded = tokenizer.decode(encoded)
print("Decoded:", decoded)
🧠 Context
This project was developed as an advanced Systems Engineering project to bridge the gap between educational tokenizers and scalable production logic.
Metadata
Release files for lexibyte 0.3.1
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 |
|---|---|---|---|---|
| lexibyte-0.3.1.tar.gz | 6.2 kB | Without provenance | Details for lexibyte-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lexibyte-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for lexibyte-0.3.1-py3-none-any.whl |
Total release size: 12.8 kB
Release files / lexibyte-0.3.1.tar.gz
| Download URL | lexibyte-0.3.1.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
718168b2d03b3a129c9eb4e52d4ca875b185def291686fce6b187aa5ff9ac51f
|
|
BLAKE2b-256 checksum How to use checksums |
b3ab3d38b2475271c083538dcfa5f6bc8cb7e05a41024118bbef686cb18e1b33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.0
|
Release files / lexibyte-0.3.1-py3-none-any.whl
| Download URL | lexibyte-0.3.1-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0a53b45a815807a2a9751ea2930fb6fe11746bbd8c6a8dccb115453d37f494e7
|
|
BLAKE2b-256 checksum How to use checksums |
f020eab6e0ce64d98313a0dea7d8d0eeab4c811caff9d36df911fe55441a0a83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.0
|
Security for lexibyte 0.3.1
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.