← All models

image-text-to-text Β· document understanding Β· WebGPU Β· ~265 MB

SmolDocling β€” a document image becomes structured DocTags

Most doc models give you flat text. SmolDocling gives you structure: hand it a page image and it emits DocTags β€” a compact markup that tags every element with its type and bounding box β€” headings, paragraphs, tables (as OTSL cells) and formulas (as LaTeX). It's the 256M-parameter model behind IBM's Docling toolkit, running end-to-end on your GPU with nothing uploaded.

At a glance

Modeldocling-project/SmolDocling-256M-preview
Taskimage-text-to-text (document image β†’ structured DocTags)
ArchitectureIdefics3ForConditionalGeneration (idefics3) β€” a SmolVLM-family VLM: SigLIP vision encoder + SmolLM2 decoder, fine-tuned on synthetic document / table / formula / chart data
OutputDocTags: <text>, <section_header_level_1>, <otsl> tables (<ched>/<fcel> cells), <formula> (LaTeX), <picture>, <caption> β€” each with <loc_x> bounding-box coords
Params / dtype256M Β· q4 (4-bit) β€” the q4f16 / fp16 / int8 exports are degenerate for this model, so q4 is the honest runnable one
Transformers.jsv4.3.0, pinned locally in this model's worker (SmolDocling's ONNX doesn't load under the shared 3.7.5 pin β€” same version-pin pattern as the SAM2 demo)
BackendWebGPU (required β€” needs a GPU adapter)
Download~265 MB, cached after first load
LicenseCDLA-Permissive-2.0
Web APIsWebGPU, Web Workers, FileReader, Canvas

Not the same as the other document demos: Nougat outputs Markdown, Donut answers a question about a form, and TrOCR does line OCR. SmolDocling outputs a full structured document (layout + tables + formulas) in one pass.

Run it

Document to convert

The document image the model will read

Pick a sample, or drop your own page image:

A business report page with headings and a bullet list A document containing a four-column data table A page with headings and mathematical formulas
Drop / choose a page image

Structured document

The parsed structure (headings, paragraphs, tables, formulas) will appear here.

See inside β€” the raw DocTags stream

Under the structured view above is a plain autoregressive VLM. The document image is split into tiles, each turned into image tokens, and the decoder generates one long string of DocTags β€” interleaving element tags (<text>, <otsl>, <formula>) with <loc_n> coordinate tokens. Below is the exact tag stream the model emits, token by token, plus the real input tensor shape β€” so you can watch it lay out the page.

pixel_values shape–
prompt tokens (text + image tiles)–

DocTags output

Run a conversion to see the raw DocTags stream.

Why it matters

A flat OCR dump loses the thing that makes a document useful: its structure. DocTags keep the table a table, the formula a formula, and the heading a heading β€” with coordinates β€” so a document becomes queryable, convertible, and re-flowable. And it happens on-device, privately, for free:

Use cases

Basics

One page in, DocTags out — the plain document→structure loop, with the parsed elements shown.

Practical

Export the structure: turn the DocTags into clean Markdown you can copy β€” a private document converter.

Wild

Tables & formulas: extract a data table as rows and a printed equation as LaTeX.

Multi-model

SmolDocling reads the page β†’ an on-device LLM summarises the structured document into a plain-language brief.

How the API works

SmolDocling uses the standard vision-to-text classes. Build a chat message with the page image and the "Convert this page to docling." instruction, template it, run the processor, then generate β€” streaming the DocTags as they come. Note the v4 pin: its ONNX doesn't load under Transformers.js 3.x.

import { AutoProcessor, AutoModelForVision2Seq, load_image, TextStreamer }
  from "@huggingface/transformers@4.3.0";   // v4 β€” 3.x can't load SmolDocling's ONNX

const processor = await AutoProcessor.from_pretrained("docling-project/SmolDocling-256M-preview");
const model = await AutoModelForVision2Seq.from_pretrained(
  "docling-project/SmolDocling-256M-preview",
  { dtype: "q4", device: "webgpu" },   // q4 is the runnable export; q4f16/fp16/int8 are degenerate
);

const image = await load_image(pageURL);
const messages = [{ role: "user", content: [
  { type: "image" }, { type: "text", text: "Convert this page to docling." },
]}];
const text = processor.apply_chat_template(messages, { add_generation_prompt: true });
const inputs = await processor(text, [image]);
// inputs.pixel_values.dims === [1, numTiles, 3, H, W]  ← the split page

const streamer = new TextStreamer(processor.tokenizer,
  { skip_prompt: true, skip_special_tokens: false, callback_function: (t) => append(t) });
await model.generate({ ...inputs, max_new_tokens: 512, streamer });
// β†’ "<doctag><section_header_level_1><loc_43>…Regional Sales Summary</section_header_level_1><otsl>…"

This page runs exactly that, in a Web Worker, and gates on a real WebGPU adapter first β€” if none exists it shows a labelled needs-WebGPU state instead of a fake answer.

References