← All models

summarization Β· text Β· WASM Β· ~335 MB

LongT5 β€” the long-context gist machine

A different summarizer family from DistilBART: LongT5 uses transient-global attention to read far longer inputs, and it was pretrained with Pegasus's own gap-sentence objective β€” the closest browser-runnable relative of the Pegasus/XSum "one-sentence gist" style. Paste something and watch the gist stream in, token by token. Nothing leaves your device.

A quick, honest note on the model

The original ask was Pegasus XSum, but it has no transformers.js/ONNX build, so it can't run in a browser today. LongT5 is the closest distinct, runnable family: same Pegasus-style gap-sentence pretraining, plus long-input attention DistilBART lacks. This is the base checkpoint (not a summarization fine-tune), so its gists lean extractive β€” it tends to lift and lightly compress the single most salient sentence rather than freely rewrite. That's a real, useful behaviour; it just isn't the heavy abstraction a fine-tuned Pegasus would give.

At a glance

ModelXenova/long-t5-tglobal-base
Task / pipelinesummarization (sequence-to-sequence)
ArchitectureLongT5 (TGlobal) β€” a T5 encoder–decoder with transient-global attention for long inputs; ~250M params
PretrainingPegasus-style principle-sentence (gap-sentence) generation on C4
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~335 MB (encoder + decoder), cached after first load
LicenseApache-2.0
Web APIsWebAssembly, Web Workers β€” all Baseline widely available

Run it

Paste any text, set the length budget, and summarize. Greedy decoding streams the gist live and records real per-token timing; turn up the beams for a slower, often tighter result.

Gist

See inside β€” tokens, compression & decode timing

A summarizer is really a compressor. Here's what it actually did: how many tokens went in versus came out, how much shorter that is, and β€” for greedy decoding β€” the real time each output token took to generate. The model emits one token at a time, feeding each back in to pick the next.

Tokens in
–
Tokens out
–
Compression
–
Chars saved
–

Per-token decode timeline (ms per token):

Why it matters

Summarization turns a wall of text into something you can act on in seconds β€” and doing it on-device means you can summarize private, sensitive, or offline content without shipping a word to a server. LongT5's long-context attention makes it a natural fit for the big inputs a ~1024-token model can't take in one pass.

Use cases

Basics

Summarize a sample article and dial the length up and down to feel the trade-off.

Practical

Headline / TL;DR: turn a paragraph into a one-line gist for a feed or push notification.

Wild

Recursively summarize a summary until the whole thing collapses to one sentence.

Multi-model

Whisper transcribes a recording, then LongT5 gists it β€” audio in, TL;DR out.

How the API works

Summarization is one pipeline call; length is controlled with generation parameters:

import { pipeline } from "@huggingface/transformers";

const summarizer = await pipeline(
  "summarization",
  "Xenova/long-t5-tglobal-base",
); // downloads + caches ~335 MB once

const out = await summarizer(longText, {
  max_new_tokens: 45,
  min_new_tokens: 10,
  num_beams: 1,          // greedy; raise for tighter (slower) output
  no_repeat_ngram_size: 3,
});
// β†’ [{ summary_text: "…a concise gist…" }]

For the live token stream and the decode timeline, this page passes a TextStreamer so it can timestamp each generated token β€” all inside a Web Worker so the UI never janks.

References