text-generation (structured) · text · WebAssembly (CPU) · ~770 MB
NuExtract is not a chatbot. It's a small LLM (a fine-tune of Qwen2.5-0.5B) trained
for exactly one job: you hand it a block of text and a JSON template
naming the fields you want, and it returns JSON that fills the template — copying values verbatim
from the text, not paraphrasing or inventing. Give it an invoice, a résumé, a support email; get
back a clean object you can JSON.parse(). All on your device, no key, no server.
| Model | onnx-community/NuExtract-1.5-tiny-ONNX (base: numind/NuExtract-1.5-tiny) |
|---|---|
| Task | text-generation — but constrained to template-conditioned extraction, not open chat |
| Architecture | Qwen2 decoder-only transformer, 0.5B params, fine-tuned on a private high-quality extraction dataset. Multilingual (EN/FR/ES/DE/PT/IT). |
| Params / dtype | 0.5B · q4 (4-bit weights, onnx/model_q4.onnx) — the q8/int8 exports of this fine-tune are degenerate (empty output); q4 is the honest runnable one |
| Backend | WebAssembly (CPU) — no WebGPU required |
| Download | ~770 MB, cached after first load |
| License | MIT |
| Web APIs | WebAssembly, Web Workers |
NuExtract has no special "extraction API" — the magic is entirely in the prompt format
the model was fine-tuned on. Your template and text are slotted into a fixed scaffold, and the model
is trained to continue it with the filled JSON after the <|output|> marker. This is
the exact string sent to the model on your last run, plus the raw decoded output —
nothing pre-computed.
Run an extraction to see the prompt the model receives.
The raw generation appears here.
"Turn this text into structured data" is one of the most common real jobs for an LLM — and it's usually done by sending your documents to a cloud API. NuExtract shows it can run entirely on-device: private by construction (contracts, medical notes, PII never leave the machine), free per call, and offline once cached. Because it's template-driven, the output shape is predictable — you define the schema, so the JSON is ready for a form, a database, or an API without a second parsing step.
Extract a few named fields from a sentence — the core template → JSON loop.
Real documents: invoice, résumé, and support email → schema-shaped JSON.
Nested templates and deliberately messy, multi-entity text.
OCR a receipt image with TrOCR → NuExtract structures the text into JSON.
There is no bespoke library — it's the standard text-generation pipeline with a
specific prompt. Build the template-conditioned string, generate greedily (the card recommends
temperature ≈ 0 for pure extraction), and take everything after <|output|>:
import { pipeline } from "@huggingface/transformers";
const gen = await pipeline(
"text-generation",
"onnx-community/NuExtract-1.5-tiny-ONNX",
{ device: "wasm", dtype: "q4" }, // q4 is the runnable export
);
const template = JSON.stringify({ Name: "", Role: "", Company: "" }, null, 4);
const text = "Maria Garcia is the CTO at Northwind Robotics, based in Berlin.";
const prompt = `<|input|>\n### Template:\n${template}\n### Text:\n${text}\n\n<|output|>`;
const out = await gen(prompt, { max_new_tokens: 256, do_sample: false });
const json = out[0].generated_text.split("<|output|>")[1].trim();
JSON.parse(json); // → { Name: "Maria Garcia", Role: "CTO", Company: "Northwind Robotics" }
Everything runs in a Web Worker so the CPU-bound generation never blocks the page; the loader
auto-inits an already-cached copy and never silently re-downloads. The output is validated with
JSON.parse() on the page — if it isn't valid JSON, the page says so honestly.