← All models

text2text-generation · text · WASM · ~95 MB

Grammar correction — rewrite messy text into clean prose

This is a encoder-decoder (T5) model fine-tuned on one job: grammatical error correction. Unlike a rule-based spellchecker that flags spans, it regenerates the whole sentence — so it fixes agreement, tense, word order, and typos all at once, and it is deliberately robust to very noisy input (ESL writing, ASR transcripts, keyboard mash). The entire input string is the sentence to fix; the encoder reads it, the decoder writes the corrected version one token at a time. Type something wrong and watch it get fixed — with a word-level diff of exactly what changed. Nothing leaves your device.

This is the small (~77M) checkpoint, so calibrate expectations: it is strong at everyday grammar, agreement and typo repair, but on very long or ambiguous input it can drop a clause or lightly paraphrase. The page shows you the real output, right or wrong — never a canned answer.

At a glance

ModelXenova/grammar-synthesis-small (ONNX of pszemraj/grammar-synthesis-small)
Task / pipelinetext2text-generation (sequence-to-sequence)
ArchitectureT5 encoder-decoder (~77M params) — encoder reads the messy input, decoder writes the correction
TrainingFine-tuned for grammatical error correction on the JFLEG-style / synthetic-noise corpora — robust to heavy errors
DecodingGreedy (deterministic, faithful) — streamed token-by-token
Quantizationq8 (8-bit) ONNX — encoder + merged decoder
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~95 MB, cached after first load
LicenseApache-2.0 / CC-BY-NC-SA-4.0 (dual, per model card)
Web APIsWebAssembly, Web Workers — all Baseline widely available

Run it

Type or paste text with mistakes, or pick a sample. The model rewrites it; the diff below highlights every word it removed (struck-through) or added (green).

Corrected text

See inside — the exact input, its tokens, and the seq2seq rewrite

There is no hidden prompt engineering. This is the literal string the encoder received, split into the sub-word tokens it actually saw (T5 uses SentencePiece — a leading · marks a word boundary). The decoder then rewrites the sentence from scratch; the timeline is its real per-token cadence.

Correct something to inspect the input the model was fed.

Why it matters

A private, offline proofreader that fits in a tab. No API key, no per-request bill, and — crucially — the text never leaves the device, so it is safe for drafts, private messages, medical or legal notes, and anything you would not paste into a cloud service.

Use cases

Basics

Fix one sentence at a time and read the diff — feel what the model catches (and misses).

Practical

A live proofreader: correct a whole message line by line with an edit count per line.

Wild

Throw truly mangled text at it — keyboard-mash, heavy ESL, no punctuation — and see it cope.

Multi-model

ASR → grammar: transcribe speech with Moonshine, then clean the raw transcript.

How the API works

The whole task is the input string — no template, no instruction verb needed:

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

const fix = await pipeline(
  "text2text-generation",
  "Xenova/grammar-synthesis-small",
); // downloads + caches ~95 MB once

await fix("i has went to the store yesterday and buyed three apple");
// → [{ generated_text: "I have gone to the store and bought three apples." }]

await fix("she dont has no time for to finish it");
// → [{ generated_text: "She doesn't have time to finish it." }]

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. The word-level diff is computed on the page from the input and the model's output.

References