GenLM Bytes is a Python library for byte-level language modeling. It contains algorithms for turning token-level language models into byte-level language models.
See the docs for details and basic usage.
Note: This project is under active development — expect bugs, missing features, and breaking changes. Please report any issues or suggestions in the issue tracker.
Quick Start
This library requires python>=3.11 and can be installed using pip:
pip install genlm-bytes
For faster and less error-prone installs, consider using uv:
uv pip install genlm-bytes
See DEVELOPING.md for details on how to install the project for development.
Usage
from genlm.bytes import ByteBeamState, BeamParams
from genlm.backend import load_model_by_name
# Load a token-level language model from a huggingface model name
# (Note: for fast GPU inference, specify `backend="vllm"`)
llm = load_model_by_name("gpt2-medium")
# Initialize a beam state with a maximum beam width of 5 and a prune threshold of 0.05 (higher threshold values lead to more aggressive pruning).
beam = await ByteBeamState.initial(llm, BeamParams(K=5, prune_threshold=0.05))
# Populate the beam state with byte context.
beam = await beam.prefill(b"An apple a day keeps the ")
# Get the log probability distribution over the next byte.
logp_next = await beam.logp_next()
logp_next.pretty().top(5)
# Example output:
# b'd' -0.5766762743944795
# b'b' -2.8732729803080233
# b's' -2.9816068063730867
# b'w' -3.3758250127787264
# b'm' -3.528177345847574
# Prune the beam and extend it with a new byte
new_beam = await (beam.prune() << 100) # 100 is the byte value of 'd'
See basic usage for a more detailed example.
Metadata
Release files for genlm-bytes 0.2.0
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 |
|---|---|---|---|---|
| genlm_bytes-0.2.0.tar.gz | 3.5 MB | Without provenance | Details for genlm_bytes-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| genlm_bytes-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for genlm_bytes-0.2.0-py3-none-any.whl |
Total release size: 3.5 MB
Release files / genlm_bytes-0.2.0.tar.gz
| Download URL | genlm_bytes-0.2.0.tar.gz |
|---|---|
| Size | 3.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05690861b623aba1dbb0fedd636b376f8509adbfdb5960e5f64a90e497c980c1
|
|
BLAKE2b-256 checksum How to use checksums |
097db766357371633e082e3e87446f0d6b06322eaefda244bba37eca0437be8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / genlm_bytes-0.2.0-py3-none-any.whl
| Download URL | genlm_bytes-0.2.0-py3-none-any.whl |
|---|---|
| Size | 27.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b7ed7d82e5f8168d265a53576d6c7287f770120c04afe5eb56c66628eedb370
|
|
BLAKE2b-256 checksum How to use checksums |
f59035c0afccc5481baf2ea45184229f9b9d942520e573ab0aa6263ccdc62eb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for genlm-bytes 0.2.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.
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.