Instructions to use kerasformers/t5_small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use kerasformers/t5_small with KerasFormers:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Keras
How to use kerasformers/t5_small with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://kerasformers/t5_small") - Notebooks
- Google Colab
- Kaggle
T5-small in Keras 3: JAX, PyTorch, or TensorFlow
kerasformers/t5_small
Pure-Keras 3 conversion of google-t5/t5-small 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_small")
tokenizer = T5Tokenizer.from_weights("kerasformers/t5_small")
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_small") (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_small")
Special Thanks
Thank you to the Google T5 team for creating and releasing the T5 models.
- Downloads last month
- 1
Model tree for kerasformers/t5_small
Base model
google-t5/t5-small