Keras-Bio
Multi-backend biological sequence and structure foundation models implemented in Keras 3.
Runs seamlessly on TensorFlow, PyTorch, and JAX.
Roadmap & Domains
- Protein Sequences: ProtT5 (Implemented), ESM (Next)
- DNA Sequences: DNABERT, HyenaDNA
- Structures: AlphaFold, ESMFold
- Molecules/Drugs: ChemBERTa, MolFormer
- Single-Cell Omics: Geneformer, scGPT
Installation
git clone https://github.com/anas-rz/keras-bio.git
cd keras-bio
pip install -e .
To run on a specific backend, set the KERAS_BACKEND environment variable:
export KERAS_BACKEND=jax # or 'torch' or 'tensorflow'
ProtT5 Quickstart
1. Tokenize & Extract Protein Embeddings
from keras_bio.protein import ProtT5Config, ProtT5EncoderModel, ProtT5Tokenizer
# 1. Dependency-free protein sequence tokenizer
tokenizer = ProtT5Tokenizer()
sequences = ["PRTEINO", "MKTIIALSYIFCLVFA"]
# 2. Initialize model or load pretrained from Hugging Face Hub
model = ProtT5EncoderModel.from_hf("Rostlab/prot_t5_xl_half_uniref50-enc")
# 3. Extract pooled per-protein or per-residue embeddings
per_protein_emb = model.embed(sequences, tokenizer=tokenizer, pool="mean") # (2, 1024)
per_residue_emb = model.embed(sequences, tokenizer=tokenizer, pool="none") # (2, max_len, 1024)
2. Downstream Heads
from keras_bio.protein import ProtT5ForSequenceClassification, ProtT5ForTokenClassification
# Sequence classification (e.g. cellular localization, enzyme function)
classifier = ProtT5ForSequenceClassification(model.config, num_classes=5)
# Per-residue token classification (e.g. secondary structure, binding sites)
token_classifier = ProtT5ForTokenClassification(model.config, num_classes=3)
Architecture & Parity
- Multi-backend: Strict symbolic-safe operations (
keras.ops) across TensorFlow, PyTorch, and JAX. - Feed-Forward: Supports both ungated (ProtT5-XL) and gated (ProtT5-base-mt, T5-v1.1, mT5) projections.
- Parity Checked: Validated against PyTorch Hugging Face reference implementations with numerical difference $< 10^{-6}$.
- Serialization: Native
.keraszip-format serialization (model.save()/keras.saving.load_model()).
Running Tests
# Run layer and model tests
pytest tests/ -v
# Run across backends
KERAS_BACKEND=tensorflow pytest tests/protein/test_prot_t5_multibackend.py -v
KERAS_BACKEND=torch pytest tests/protein/test_prot_t5_multibackend.py -v
KERAS_BACKEND=jax pytest tests/protein/test_prot_t5_multibackend.py -v
Metadata
Release files for keras-bio 0.1.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 | |
|---|---|---|---|---|
| keras_bio-0.1.0.tar.gz | 85.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| keras_bio-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 185.4 kB
Release files / keras_bio-0.1.0.tar.gz
| Download URL | keras_bio-0.1.0.tar.gz |
|---|---|
| Size | 85.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c305cbe70897f01f5a622d3bf5b78bd4752c9c23416f9e93b4224b674f4d5f1
|
|
BLAKE2b-256 checksum How to use checksums |
a295d7a85c64dd08eddc27665a5c29851529705c58a0c3cc53c99a1bdb3483f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 25, 2026.
Transparency logRelease files / keras_bio-0.1.0-py3-none-any.whl
| Download URL | keras_bio-0.1.0-py3-none-any.whl |
|---|---|
| Size | 100.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0a158d124fbc2f291e4ba96fa4c90f9cac9cf40196423ed859a720a4c92f5f69
|
|
BLAKE2b-256 checksum How to use checksums |
18ebd0eee3fcf214b1979991653209bb96a4b048a93a26119dfbdf17913d51c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 25, 2026.
Transparency logSecurity for keras-bio 0.1.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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for keras_bio-0.1.0.tar.gz
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 Oct 25, 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.