How to Turn Scanned PDFs Into Structured Documents for Free With Granite Docling V2
Your scanner gives you a picture of a page. Your OCR tool gives you a pile of words. Neither gives you the document. The table your invoice printed in neat rows comes back as numbers in a line. The heading that sat above a paragraph comes back floating somewhere in the middle. The formula your paper spent a page on comes back as symbols with no structure at all. If you have ever pasted that output into a document and spent an hour putting it back together by hand, you know the gap: reading the words is easy, keeping the document is the hard part.
On 30 November 2026, IBM's Docling team released something that closes that gap for free. Granite Docling V2 is a small open model that looks at a page image and writes the whole page back as a structured document in one pass: headings, paragraphs, tables with their cells intact, formulas, code, pictures and their captions, all in reading order. It is free, it is open under the Apache 2.0 licence, and the smaller version is only about half a billion parameters. This tutorial shows you how to try it with no install, how to run it on your own machine, and how to turn its output into Markdown, HTML or JSON you can actually use. The honest catches come first, because three of them change what you should expect: the headline speed figures were measured on one H100 GPU, not a laptop; the models only accept DocLang prompts, not free-form questions; and the faster Flash editions are paid watsonx only, not open weights.
Why does plain text OCR lose the document?
Think about what a scanned invoice actually is. It is not a paragraph. It is a layout: a company name at the top, a table of items with quantities and prices, a total in bold at the bottom, a payment address in a small box on the side. A plain text OCR tool reads the characters and hands you the characters. It does not tell you which numbers belong to which row, or that the bold total is a total and not just another number. You get the words and lose the meaning the layout was carrying.
That is the job Day 26's OCRia-nano-1 tutorial does well: it turns any PDF into clean plain text on a CPU, fast and free. If plain text is all you need, stop there and use it. Docling V2 is the next step up. It does not flatten the page. It reads the page the way you read it, as a set of elements with a type, a place and an order, and it writes that structure down. A table stays a table. A heading stays a heading. A formula stays a formula, written in LaTeX, not as a string of loose symbols.
The difference shows up the moment you want to do something with the output. Plain text goes into a search box or a chat window. A structured document goes into a database, a spreadsheet, a retrieval system for an AI agent, or a report you can reformat without retyping. If your stack of paper is research papers, invoices, forms, reports or old books, structure is the part you were actually missing.
What is Granite Docling V2, exactly?
Granite Docling V2 is two compact vision-language models from IBM's Docling team, released 30 November 2026. The 2B model is the accuracy model. The 500M model is the speed model. Both are Apache 2.0, both are on Hugging Face today, and both replace the older Granite-Docling 258M from September 2025 and the earlier SmolDocling.
Here is how it works, in plain language. You give the model a picture of a page. The model splits the page into tiles of 512 by 512 pixels, looks at each tile with a SigLIP2 vision encoder, and writes the page out in DocLang, an open document format. DocLang is the key idea, so it is worth a minute. It is an XML-style markup where every element opens with its type, then its bounding box as four location tokens on a 512 by 512 grid, then its content. A heading is a heading with coordinates. A table cell is a cell with coordinates. Captions sit inside the table, picture, code or formula they describe. Formulas are LaTeX. Inline bold, superscript and handwriting are marked inside the running text. Because every tag and every coordinate is a single token, a whole page costs far fewer tokens than the same page written as HTML.
DocLang comes from a working group founded by IBM, NVIDIA, Red Hat, ABBYY and HumanSignal under LF AI and Data, and it is the successor to DocTags, the format the old 258M model used. A DocLang page converts losslessly into a Docling document, and from there into Markdown, HTML or JSON with the docling-core library. Nothing in the chain is a black box: the format has a public 0.9 specification at doclang.ai, and the Benchmark Explorer lets you browse the actual pages and scores.
The 500M model has one clever trick the 2B does not need. A learned density router reads each page first and decides whether it is an ordinary page, which gets 64 vision tokens per tile, or a dense page, small print, newspapers, long tables, which gets re-encoded at 256 tokens per tile. The 2B model always uses the denser 256-token path. That router is why the small model stays fast on easy pages and still reads hard ones properly.
Step 1: try it with no install
The fastest way to see what this does is the Granite Docling V2 Playground, a Hugging Face Space at huggingface.co/spaces/ibm-granite/granite-docling-v2-playground. Upload a page image, or a scanned PDF page, and the demo converts it in the browser. No account, no install, no API key.
Pick a hard page on purpose. A page with a table and a formula will tell you more in thirty seconds than a clean paragraph ever will. Watch for three things: whether the table keeps its rows and columns, whether the formula comes back as readable LaTeX, and whether the reading order matches the page, headings first, then the body, then the footnote. If those three survive, the model is doing its job. If your page is a dense newspaper or a small-print form, try the 500M model and see whether the router's fine path kicks in; the demo is the cheapest way to learn what the model can and cannot read before you install anything.
Step 2: run it on your own machine
If the Playground convinces you, the next step is running the model yourself. There are two routes that are verified to work, and one honest hardware note that decides between them.
Start with the Hugging Face Transformers route, which is the one the model card documents in full. You need Python 3.11 or later and Transformers 5.23.0 or later, which includes the native GraniteDocling architecture. Install the pieces first:
pip install "transformers>=5.23.0" torch torchvision pillow docling-core
Then load the 500M model and convert one page. This is the model card's own quick start, trimmed to the essentials:
import torch
from PIL import Image
from transformers import AutoModelForImageTextToText, AutoProcessor
model_id = "ibm-granite/granite-docling-v2-500m"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForImageTextToText.from_pretrained(model_id, dtype=torch.bfloat16, device_map="cuda")
image = Image.open("page.png").convert("RGB")
messages = [{"role": "user", "content": [
{"type": "image", "image": image},
{"type": "text", "text": "<doclang>"},
]}]
inputs = processor.apply_chat_template(
messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt",
).to(model.device, dtype=torch.bfloat16)
output = model.generate(**inputs, max_new_tokens=16384, do_sample=False)
doclang = processor.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=False)
doclang = doclang.removesuffix(processor.tokenizer.eos_token)
print(doclang)
Two details in that code matter more than they look. First, decode with skip_special_tokens=False. The DocLang tags and location tokens are special tokens, and skipping them leaves you with bare text, which is exactly the output you were trying to escape. Second, the prompt is the literal string <doclang>. That is not a placeholder. It is the only prompt the model takes for a full page, and the model does not follow free-form instructions or answer questions, which we come back to in the limits section.
For a whole PDF, render each page to an image first, the model card suggests pypdfium2 at 144 DPI, and pass the pages as a batch. For the 500M model, the card also shows how to ask the density router which pages need the fine path, with model.model.predict_fine_route, so dense pages get the 256-token treatment and ordinary pages stay fast.
The hardware note: the Transformers example above uses device_map="cuda", which means an NVIDIA GPU. On a Windows or Linux PC, that is the verified route. On Apple silicon, the verified route is MLX-VLM. The Docling model catalog says mlx-vlm 0.8.1 or later loads the same Hugging Face repositories, no separate MLX weights are needed, and Docling picks the MLX engine automatically when mlx-vlm is installed. There is no verified plain-CPU route for these models in the card or the catalog, so do not plan on running them on a CPU-only laptop. The 500M model is about a gigabyte of weights in bf16, so it fits easily; the GPU is the requirement, not the disk space.
The second route is the Docling library itself, which wraps the model in a document converter. Install the latest docling, then use the VLM pipeline with the preset granite_docling_v2_500m for the small model or granite_docling_v2_2b for the large one. In Python, that is VlmConvertOptions.from_preset("granite_docling_v2_500m"), and the Docling CLI takes the same preset name with its --vlm-model flag. The catalog also documents a --doclang-tasks CLI flag, so you can ask for only some elements, for example --doclang-tasks table,layout to get just the tables with their positions. If you already use Docling, this is the route that drops straight into your existing workflow.
Step 3: turn DocLang into Markdown, HTML or JSON
Raw DocLang is useful to a machine and unreadable to a person, so the last step is converting it. The docling-core library does this in a few lines, again from the model card:
from docling_core.transforms.deserializer.doclang import DocLangDocDeserializer
document = DocLangDocDeserializer().deserialize_str(doclang)
print(document.export_to_markdown())
document.save_as_markdown("page.md")
document.save_as_html("page.html")
document.save_as_json("page.json")
That is the whole pipeline: page image in, DocLang out, Markdown or JSON out. The Markdown keeps the headings, the tables and the formulas. The JSON keeps the structure with coordinates, which is what you want if you are feeding pages into search, retrieval-augmented generation or an agent that needs to know where things were on the page. The HTML keeps the layout for display. Pick the format your next step needs, not the one that looks prettiest in a terminal.
One more useful trick from the model card: you do not have to convert the whole page. Task prompts ask for only what you need. <doclang> [<table>] returns only the tables. <doclang> [<table>, <formula>] returns tables and formulas. <doclang> [<detailed>] returns the full page plus a generated description of each picture. Write the prompt exactly as shown, one space after <doclang>, tasks in angle brackets separated by a comma and a space, because other spacing lowers quality. If the content you asked for is not on the page, the model returns an empty <doclang></doclang>, which is a feature, not a bug: it would rather say nothing than invent a table that is not there.
Which one should you pick, 500M or 2B?
The two models are a genuine trade-off, and IBM's own numbers make it easy to choose. Both figures below are IBM's own benchmarks, so treat them as maker-reported and unverified, and note that IBM re-annotated the ground truth in DocLang, so these scores are not comparable with the original benchmark leaderboards.
On accuracy, the 2B scores 96.5 and the 500M scores 94.9 on content accuracy, pooled over 16,205 pages from nine benchmarks in the Docling Benchmark Explorer. For context, the same table puts dots.mocr at 94.6, MinerU 2.5 Pro at 94.4, NVIDIA's Nemotron 3.5 Parse at 92.9, and the old Granite-Docling 258M at 79.4. The jump from the old model is the real story: the character error rate fell from 20.6 percent with the 258M to 5.1 percent with the 500M, and to 3.5 percent with the 2B. The small model alone is more accurate than every competing system IBM tested, including models up to ten times its size.
On speed, you will see two different pairs of numbers, and they are both real. IBM's own blog gives 3.8 pages per second for the 2B and 6 pages per second for the 500M on one H100. The model card's throughput table, measured with a tuned vLLM server and many pages in flight, gives 6.8 and 14.2 pages per second without speculative decoding, and 10.1 and 18.5 with multi-token prediction, the MTP trick where the model drafts three tokens per step and checks them. The blog figures are the plain-pipeline speed. The card figures are the fastest server setup. Quote the right one for your setup: if you are converting one page at a time on your own machine, expect something closer to the blog figures, not the 18.5 headline.
So the choice is simple. Use the 500M when you have a large collection to convert, a pile of scanned papers, a whole archive, and you want it done today. The accuracy gap is 1.6 points and the speed gap is roughly double. Use the 2B when accuracy matters more than speed: dense pages, small print, complex tables, forms where one wrong cell changes the answer. And use the 500M's fine route, or the 2B, for newspapers and multi-column documents, because that is where the extra vision tokens earn their keep.
What can it not do yet?
Four limits, stated plainly so none of them surprises you later.
First, the models only accept DocLang prompts. You cannot ask them a question about the page, or tell them in plain English to summarise the third paragraph. If you want a chatbot that reads documents, this is not it. It is a converter, and a very good one, but it converts.
Second, the speed figures are H100 figures. One H100 80GB is a data-centre GPU, not a laptop. On your own GPU the numbers will be lower, and on Apple silicon through MLX-VLM they will be lower still, though the models do run there. The 500M is small enough to fit almost anywhere; the speed you get depends on the hardware you actually own.
Third, the faster Flash editions are not open. Granite Docling V2 2B Flash and 500M Flash deliver the same accuracy, faster, but only inside Docling for IBM watsonx and watsonx Software. If you see a speed figure with "Flash" next to it, that speed is not available in the free open weights.
Fourth, handwriting is better than the old model but still weaker than print. The card says the new models read handwritten notes and forms far better than the 258M, though printed text remains more accurate. If your archive is handwritten, test a few pages in the Playground before you commit to converting the whole box.
The same release also brought two siblings worth one paragraph. Granite Vision 5.0 4B extracts data from complex visuals, the numbers behind a chart, the structure of a hard table, specific fields on a form, returned as JSON against a schema you provide. Granite Embedding 748M Vision R2 makes pages searchable straight from their image, with no OCR or chunking, averaging 0.721 nDCG across eight visual document retrieval benchmarks. Together with Docling V2, they are IBM's "agents put documents to work" set: Docling converts, Vision extracts, Embedding retrieves. All three are Apache 2.0 and on Hugging Face since 30 November 2026.
FAQ
Is Granite Docling V2 really free?
Yes. Both models are open weights under the Apache 2.0 licence, which covers commercial use. You can run them locally, build them into a product, and modify them, keeping the licence and copyright notice. The paid part is the Flash editions, which live only in IBM watsonx.
Can I run it on my laptop?
On Apple silicon, yes, through MLX-VLM with mlx-vlm 0.8.1 or later, loading the same Hugging Face repos. On Windows or Linux, you need an NVIDIA GPU with CUDA for the verified Transformers route. There is no verified plain-CPU route, so a CPU-only laptop is not the machine for this job.
How is this different from the Day 26 OCRia-nano-1 tutorial?
OCRia-nano-1 turns PDFs into clean plain text on a CPU, and it is the right tool when plain text is enough. Docling V2 turns pages into structured documents, tables, formulas, layout and reading order included. Use OCRia for text, Docling V2 for structure.
Will it read my handwriting?
Better than the old model, but printed text is still more accurate. Test handwritten pages in the Playground first.
What do I do with DocLang?
Convert it. The docling-core library turns a DocLang string into a document you can save as Markdown, HTML or JSON. Markdown is for reading, JSON is for search and agents, HTML is for display.
Can it answer questions about my documents?
No. The models only accept DocLang prompts, not free-form questions. Convert the document first, then use a search tool, a retrieval system or a language model on the converted output.
How fast is it, really?
On one H100, IBM's blog quotes 3.8 pages per second for the 2B and 6 for the 500M, and the model card's tuned vLLM server reaches 10.1 and 18.5 with multi-token prediction. On your own hardware, expect less. The honest test is converting ten of your own pages and timing it.
Sources
IBM Research blog, New Granite models help agents put documents to work (https://research.ibm.com/blog/new-granite-models-help-agents-put-enterprise-documents-to-work)
Hugging Face blog, Granite Docling V2: Compact Vision-Language Models for End-to-End Document Conversion (https://huggingface.co/blog/ibm-granite/granite-docling-v2-compact-vision-language-models)
Hugging Face model card, Granite Docling V2 500M (https://huggingface.co/ibm-granite/granite-docling-v2-500m)
Docling model catalog, VLM presets and engines (https://docling-project.github.io/docling/usage/model_catalog/)
Granite Docling V2 Playground (https://huggingface.co/spaces/ibm-granite/granite-docling-v2-playground)
Granite Docling V2 technical report, arXiv 2611.37727 (https://arxiv.org/abs/2611.37727)
DocLang 0.9 specification (https://doclang.ai)
Keep reading on RiseMe
How to Turn Any PDF Into Clean Text for Free With OCRia-nano-1 (https://riseme34.blogspot.com/2026/11/how-to-turn-pdf-into-clean-text-free-ocria-nano-1.html)
Run AI on Your Own PC: Ollama Tutorial (https://riseme34.blogspot.com/2026/11/ollama-tutorial-run-free-ai-on-your-pc.html)
Paid AI Tools and Their Free Alternatives (https://riseme34.blogspot.com/2026/11/paid-ai-tools-free-alternatives-save-900-a-year.html)


