Skip to content
All projects
Machine LearningMay 2025

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.

SmolDocling-OCR
Year
May 2025
Timeline
3 months
Type
Machine Learning
Status
Completed
01

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.

02

The hard parts

  1. 01

    Keeping document structure (tables, code, formulas, headings) instead of flattening everything to plain text.

  2. 02

    Offering different extraction tasks, such as table extraction, formula conversion to LaTeX and chart data, from one interface.

  3. 03

    Processing several images in one run.

  4. 04

    Making the output usable outside the app.

03

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.

04

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.

05

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.

06

Stack

model
SmolDocling-256M-preview (Hugging Face)PyTorchTransformers
documents
docling-corePyMuPDFPillow
ui
Streamlit

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.