Skip to main content

🔤 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:

🚀 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.


Release files for lexibyte 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lexibyte 0.2.0
File Size Uploaded
lexibyte-0.2.0.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lexibyte 0.2.0
File Interpreter ABI Platform
lexibyte-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / lexibyte-0.2.0.tar.gz

Download URL lexibyte-0.2.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
558803eedab36c1e1420c387f7fc028c0bcf6126a29f1cee52d1c919210e80c5
BLAKE2b-256 checksum
How to use checksums
c79f77e2ba3bea2a3648ab794a7ca54620563e8c29f0fa6767851b40631b4bed
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.2.0-py3-none-any.whl

Download URL lexibyte-0.2.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1f9d087cf999b9bbb91d90beeec1dc219676baf6431bb9269f9a5df843b8647
BLAKE2b-256 checksum
How to use checksums
6131f5a3dec87b3b9b09f55a4743d3fbd747672eea4c4258a1cad85ab5432075
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release history Release notifications | RSS feed

0.3.1

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page