text2text-generation · text · WASM · ~250 MB
This is the original T5 (Raffel et al., 2019), the model that reframed
every NLP problem as "text in → text out." It is not instruction-tuned like
FLAN-T5: it won't follow a chatty request. Instead
it was pre-trained to recognise a small set of task prefixes, and that prefix is the
only thing that tells the shared weights which job to do. Prepend
translate English to German: and it translates; swap in summarize: and it
summarises; cola sentence: judges grammar; stsb sentence1:… sentence2:… scores
similarity. Pick a task below and watch the exact prefixed string it gets fed — all on your device.
| Model | Xenova/t5-base (ONNX of google-t5/t5-base) |
|---|---|
| Task / pipeline | text2text-generation (T5 encoder-decoder, T5ForConditionalGeneration) |
| How you steer it | A task prefix at the front of the input — the pre-training format, not a natural-language instruction |
| Params | ~220M (12-layer encoder + 12-layer decoder) |
| Quantization | q8 (8-bit) ONNX — encoder + merged decoder |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~250 MB, cached after first load |
| License | Apache-2.0 |
| Web APIs | WebAssembly, Web Workers — all Baseline widely available |
T5-base is not a chat model. Its known tasks are the ones it saw in pre-training:
translation (EN→DE/FR/RO), summarize, the GLUE/SuperGLUE tasks (CoLA grammaticality,
STS-B similarity, MNLI, and more). Ask it something outside that set with no prefix and it will just
try to continue the text — shown honestly, never a canned answer.
The buttons don't change the model; they change the prefix prepended to your text. Everything below the picker is the same T5-base weights doing a different job.
Exact string fed to the encoder (prefix highlighted):
There is no hidden system prompt. The whole "instruction" is the highlighted prefix above,
concatenated with your text and tokenized by T5's SentencePiece tokenizer (a
leading · below marks a word boundary, T5's ▁). The decoder then writes the
answer one token at a time, feeding each token back in to choose the next — the bars are the real
millisecond gaps between those tokens.
Input tokens (SentencePiece):
Per-token decode timeline:
T5 is the archetype of the text-to-text idea that underlies almost every modern LLM: collapse translation, summarisation, classification, and scoring into one format so a single model — and a single training run — can do all of them. Seeing the prefix mechanism in the open makes that idea concrete, and a 250 MB model that ships four useful tools is genuinely handy on-device.
Keep the text, change only the prefix — feel how one model becomes a translator, summariser, or grammar judge.
A quick multi-tool: translate, TL;DR, grammar-check, and score two sentences' similarity in one panel.
Chain tasks (summarize → translate) and try unusual/unknown prefixes to probe what T5 really learned.
T5 translates or summarises, then SpeechT5 speaks the result aloud — a two-model on-device pipeline.
The whole trick is the string you pass — the pipeline is one line:
import { pipeline } from "@huggingface/transformers";
const t5 = await pipeline("text2text-generation", "Xenova/t5-base", {
device: "wasm", dtype: "q8",
}); // downloads + caches ~250 MB once
// The PREFIX is the task selector — the same weights, four different jobs:
await t5("translate English to German: The house is wonderful."); // → "Das Haus ist wunderbar."
await t5("summarize: <long article>"); // → a shorter text
await t5("cola sentence: The books is on the table."); // → "unacceptable"
await t5("stsb sentence1: A man plays guitar. sentence2: A person plays a guitar."); // → "3.2"
This page runs exactly that in a Web Worker so the UI never janks, streams the decoded tokens as they arrive, and shows the exact prefixed string + its SentencePiece tokens above.