text2text-generation Β· text Β· WASM Β· ~290 MB
Almost every language model chops text into sub-word tokens from a fixed vocabulary β and that vocabulary decides what the model can even see. ByT5 throws the vocabulary away. It reads raw UTF-8 bytes: every character becomes one to four bytes, and each byte is a token. That one change makes it work identically across every language, script, emoji, and mangled input β nothing is ever "out-of-vocabulary." Type anything below and watch it become bytes, then watch the model fill in a blank β all locally, nothing uploaded.
This is the small (~300M) base checkpoint β pre-trained on byte-span denoising, not instruction-tuned. So calibrate expectations: it is genuinely good at showing the byte mechanism and does rough fill-in-the-blank completions, but it is not a chat model and its guesses are often loose. The page shows you the real output, right or wrong β never a canned answer.
| Model | onnx-community/byt5-small-ONNX (ONNX of google/byt5-small) |
|---|---|
| Task / pipeline | text2text-generation (sequence-to-sequence) |
| Architecture | T5 encoder-decoder, run via T5ForConditionalGeneration β but fed bytes, not sub-word tokens |
| "Vocabulary" | 384 ids total: 0 pad Β· 1 eos Β· 2 unk Β· 3β258 the 256 byte values Β· 258+ span sentinels. No learned vocab. |
| Quantization | q8 (8-bit) ONNX β encoder + merged decoder |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~290 MB, cached after first load |
| License | Apache-2.0 |
| Web APIs | WebAssembly, Web Workers, TextEncoder β all Baseline widely available |
Note: ByT5 has no tokenizer.json and Transformers.js ships no ByT5Tokenizer, so
the usual pipeline() can't build a tokenizer. Instead this page runs the real ONNX model
directly and does the byte mapping itself β which is exactly the mechanism the demo is about.
Put [BLANK] anywhere in the text; ByT5 replaces it with a byte span it
generates. Whatever is in the box is turned to bytes and fed verbatim β that byte sequence is the
"prompt". (Base model β completions are rough and that's honest.)
This is the whole tokenizer, live. As you type, each character is UTF-8 encoded to one or more bytes,
and each byte becomes a token id (byte + 3). There is no vocabulary file, no merges, no
[UNK] β a Latin letter, a Kanji, an emoji, and a math symbol all reduce to bytes the same
way. Type in any language or paste an emoji and the chips below never fail to encode.
char β UTF-8 bytes β token ids:
Compare: a sub-word tokenizer would split "π" or "δΈη"
into multiple learned tokens (or emit [UNK] for anything it never saw). ByT5 needs no such
table β every possible input is representable.
A model with no vocabulary is a different kind of tool. It can't be tripped up by a script it wasn't trained to tokenize, a novel emoji, a typo, or deliberately corrupted text β everything is bytes, so everything is in-domain. That robustness is why byte-level models are used where input is messy or multilingual.
[UNK], ever.Transform text and fill blanks β feel the byte-in, byte-out loop and how the model reads characters.
A byte-level tokenizer inspector: paste any user text and prove nothing is ever out-of-vocabulary.
Corrupt, mix scripts, and pile on emoji β watch encoding never break where a vocab model would.
ByT5 fills a masked span β MiniLM embeddings match the completed sentence to the closest intent.
Because ByT5 is token-free, we skip the tokenizer and feed byte ids straight to the real ONNX model:
import { T5ForConditionalGeneration, Tensor } from "@huggingface/transformers";
const model = await T5ForConditionalGeneration.from_pretrained(
"onnx-community/byt5-small-ONNX", { device: "wasm", dtype: "q8" },
); // downloads + caches ~290 MB once
// The ENTIRE tokenizer: UTF-8 encode, then add 3. No vocabulary, no [UNK].
const ids = [...new TextEncoder().encode("Roses are red, violets are ")]
.map((b) => b + 3);
ids.push(258); // <extra_id_0> β the span to fill
ids.push(1); // </s>
const input_ids = new Tensor("int64", BigInt64Array.from(ids.map(BigInt)), [1, ids.length]);
const attention_mask = new Tensor("int64", BigInt64Array.from(ids.map(() => 1n)), [1, ids.length]);
const out = await model.generate({ input_ids, attention_mask, max_new_tokens: 40 });
// Decode: subtract 3, back to bytes, back to text.
const bytes = [...out.data].map(Number).filter((id) => id >= 3 && id <= 257).map((id) => id - 3);
new TextDecoder().decode(new Uint8Array(bytes)); // β the filled text
This page runs exactly that in a Web Worker so the UI never janks, and the byte mapping is the single source of truth shared with the "see inside" view above.