text2text-generation · text · WASM · ~95 MB
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.
| Model | Xenova/grammar-synthesis-small (ONNX of pszemraj/grammar-synthesis-small) |
|---|---|
| Task / pipeline | text2text-generation (sequence-to-sequence) |
| Architecture | T5 encoder-decoder (~77M params) — encoder reads the messy input, decoder writes the correction |
| Training | Fine-tuned for grammatical error correction on the JFLEG-style / synthetic-noise corpora — robust to heavy errors |
| Decoding | Greedy (deterministic, faithful) — streamed token-by-token |
| Quantization | q8 (8-bit) ONNX — encoder + merged decoder |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~95 MB, cached after first load |
| License | Apache-2.0 / CC-BY-NC-SA-4.0 (dual, per model card) |
| Web APIs | WebAssembly, Web Workers — all Baseline widely available |
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).
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.
Exact input string fed to the encoder:
Input tokens (SentencePiece):
Per-token decode timeline (ms per token):
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.
Fix one sentence at a time and read the diff — feel what the model catches (and misses).
A live proofreader: correct a whole message line by line with an edit count per line.
Throw truly mangled text at it — keyboard-mash, heavy ESL, no punctuation — and see it cope.
ASR → grammar: transcribe speech with Moonshine, then clean the raw transcript.
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.