SmolDocling-OCR: Lightweight Document OCR Pipeline
Lightweight Document OCR Pipeline
A Streamlit app that runs the SmolDocling-256M model on document images and returns structured text (tables, code, formulas and headings) as DocTags and Markdown.

- Year
- May 2025
- Timeline
- 3 months
- Type
- Machine Learning
- Status
- Completed
Overview
Plain OCR returns a flat block of text and loses the structure of the page. SmolDocling is a 256M-parameter vision-language model that reads a document image and emits DocTags, a markup that keeps tables, code blocks, formulas and headings intact. This project wraps the model in a small Streamlit app: upload one image or several, pick a task, and get the result as DocTags and as Markdown.
The hard parts
- 01
Keeping document structure (tables, code, formulas, headings) instead of flattening everything to plain text.
- 02
Offering different extraction tasks, such as table extraction, formula conversion to LaTeX and chart data, from one interface.
- 03
Processing several images in one run.
- 04
Making the output usable outside the app.
The approach
The app loads SmolDocling-256M-preview from Hugging Face with Transformers and PyTorch, using a token read from a .env file. A sidebar selects single or multiple upload mode and the processing task: table extraction, code recognition, formula conversion to LaTeX, chart data or section headers. The model's DocTags output is turned into a structured document with docling-core and rendered as Markdown. Both formats can be downloaded.
Outcome
Upload a document image and get back DocTags and Markdown that keep the page's structure, ready to download. The whole app runs locally with one command (streamlit run main.py) on Python 3.12 or newer.
What I'd do differently
The app depends on a preview model, so output quality is limited by that model. I would add a side-by-side view of the source image and the extracted Markdown so errors are easy to spot, and a small set of test documents to compare model versions.
Stack
Like what you see?
Let's build the next one.
Hiring, or have a problem that needs this kind of engineering? I read every message myself.

