T5-base in Keras 3: JAX, PyTorch, or TensorFlow

GitHub Docs HuggingFace

kerasformers/t5_base

Pure-Keras 3 conversion of google-t5/t5-base for kerasformers. One implementation runs unmodified on TensorFlow / Torch / JAX, bit-exact with the Hugging Face original. T5 is a text-to-text encoder-decoder; this repo hosts the full backbone (kf_config.json declares T5Model), and every T5 class (T5ConditionalGenerate, T5EncoderModel, and the classification / QA heads) loads its subset from the one model.weights.h5.

For model details, license, and usage terms, see the upstream model card.

Paper: Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer

Quick start

import os
os.environ["KERAS_BACKEND"] = "torch"  # or "jax" / "tensorflow"

from kerasformers.models.t5 import T5ConditionalGenerate, T5Tokenizer

model = T5ConditionalGenerate.from_weights("kerasformers/t5_base")
tokenizer = T5Tokenizer.from_weights("kerasformers/t5_base")

inputs = tokenizer("translate English to German: The house is wonderful.")
output_ids = model.generate(
    inputs["input_ids"], inputs["attention_mask"], max_new_tokens=40
)
print(tokenizer.decode(output_ids[0]))

Load any T5 variant the same way with from_weights("kerasformers/<variant>"). Browse them all in the T5 collection.

Available classes

Load any of these from this repo with from_weights("kerasformers/t5_base") (or on the fly via the hf: prefix). The pretrained backbone is shared; task heads not stored in this checkpoint start randomly initialized, ready for fine-tuning (or load a hf: fine-tune).

Class Task
T5Model Encoder backbone
T5ConditionalGenerate Text-to-text generation
T5EncoderModel Encoder-only features
T5SequenceClassify Sequence classification
T5TokenClassify Token classification (NER / POS)
T5QnA Extractive question answering
from kerasformers.models.t5 import T5SequenceClassify
model = T5SequenceClassify.from_weights("kerasformers/t5_base")

Special Thanks

Thank you to the Google T5 team for creating and releasing the T5 models.

Downloads last month
28
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for kerasformers/t5_base

Finetuned
(739)
this model

Collection including kerasformers/t5_base

Paper for kerasformers/t5_base