SmolDocling is a multimodal Image-Text-to-Text model designed for efficient document conversion. It retains Docling's most popular features while ensuring full compatibility with Docling through seamless support for
DoclingDocuments
.
๐ Features:
๐ท๏ธ
DocTags for Efficient Tokenization
โ Introduces DocTags an efficient and minimal representation for documents that is fully compatible with
DoclingDocuments
.
๐
OCR (Optical Character Recognition)
โ Extracts text accurately from images.
๐
Layout and Localization
โ Preserves document structure and document element
bounding boxes
.
๐ป
Code Recognition
โ Detects and formats code blocks including identation.
๐ข
Formula Recognition
โ Identifies and processes mathematical expressions.
๐
Chart Recognition
โ Extracts and interprets chart data.
๐
Table Recognition
โ Supports column and row headers for structured table extraction.
๐ผ๏ธ
Figure Classification
โ Differentiates figures and graphical elements.
๐
Caption Correspondence
โ Links captions to relevant images and figures.
๐
List Grouping
โ Organizes and structures list elements correctly.
๐
Full-Page Conversion
โ Processes entire pages for comprehensive document conversion including all page elements (code, equations, tables, charts etc.)
๐ฒ
OCR with Bounding Boxes
โ OCR regions using a bounding box.
๐
General Document Processing
โ Trained for both scientific and non-scientific documents.
๐
Seamless Docling Integration
โ Import into
Docling
and export in multiple formats.
๐จ
Fast inference using VLLM
โ Avg of 0.35 secs per page on A100 GPU.
๐ง
Coming soon!
๐
Better chart recognition ๐ ๏ธ
๐
One shot multi-page inference โฑ๏ธ
๐งช
Chemical Recognition
๐
Datasets
โจ๏ธ Get started (code examples)
You can use
transformers
or
vllm
to perform inference, and
Docling
to convert results to variety of ourput formats (md, html, etc.):
๐ Single page image inference using Tranformers ๐ค
# Prerequisites:# pip install vllm# pip install docling_core# place page images you want to convert into "img/" dirimport time
import os
from vllm import LLM, SamplingParams
from PIL import Image
from docling_core.types.doc import DoclingDocument
from docling_core.types.doc.document import DocTagsDocument
# Configuration
MODEL_PATH = "ds4sd/SmolDocling-256M-preview"
IMAGE_DIR = "img/"# Place your page images here
OUTPUT_DIR = "out/"
PROMPT_TEXT = "Convert page to Docling."# Ensure output directory exists
os.makedirs(OUTPUT_DIR, exist_ok=True)
# Initialize LLM
llm = LLM(model=MODEL_PATH, limit_mm_per_prompt={"image": 1})
sampling_params = SamplingParams(
temperature=0.0,
max_tokens=8192)
chat_template = f"<|im_start|>User:<image>{PROMPT_TEXT}<end_of_utterance>\nAssistant:"
image_files = sorted([f for f in os.listdir(IMAGE_DIR) if f.lower().endswith((".png", ".jpg", ".jpeg"))])
start_time = time.time()
total_tokens = 0for idx, img_file inenumerate(image_files, 1):
img_path = os.path.join(IMAGE_DIR, img_file)
image = Image.open(img_path).convert("RGB")
llm_input = {"prompt": chat_template, "multi_modal_data": {"image": image}}
output = llm.generate([llm_input], sampling_params=sampling_params)[0]
doctags = output.outputs[0].text
img_fn = os.path.splitext(img_file)[0]
output_filename = img_fn + ".dt"
output_path = os.path.join(OUTPUT_DIR, output_filename)
withopen(output_path, "w", encoding="utf-8") as f:
f.write(doctags)
# To convert to Docling Document, MD, HTML, etc.:
doctags_doc = DocTagsDocument.from_doctags_and_image_pairs([doctags], [image])
doc = DoclingDocument(name="Document")
doc.load_from_doctags(doctags_doc)
# export as any format# HTML# doc.save_as_html(output_file)# MD
output_filename_md = img_fn + ".md"
output_path_md = os.path.join(OUTPUT_DIR, output_filename_md)
doc.save_as_markdown(output_path_md)
print(f"Total time: {time.time() - start_time:.2f} sec")
DocTags
DocTags create a clear and structured system of tags and rules that separate text from the document's structure. This makes things easier for Image-to-Sequence models by reducing confusion. On the other hand, converting directly to formats like HTML or Markdown can be messyโit often loses details, doesnโt clearly show the documentโs layout, and increases the number of tokens, making processing less efficient.
DocTags are integrated with Docling, which allows export to HTML, Markdown, and JSON. These exports can be offloaded to the CPU, reducing token generation overhead and improving efficiency.
SmolDocling-256M-preview huggingface.co is an AI model on huggingface.co that provides SmolDocling-256M-preview's model effect (), which can be used instantly with this ds4sd SmolDocling-256M-preview model. huggingface.co supports a free trial of the SmolDocling-256M-preview model, and also provides paid use of the SmolDocling-256M-preview. Support call SmolDocling-256M-preview model through api, including Node.js, Python, http.
SmolDocling-256M-preview huggingface.co is an online trial and call api platform, which integrates SmolDocling-256M-preview's modeling effects, including api services, and provides a free online trial of SmolDocling-256M-preview, you can try SmolDocling-256M-preview online for free by clicking the link below.
ds4sd SmolDocling-256M-preview online free url in huggingface.co:
SmolDocling-256M-preview is an open source model from GitHub that offers a free installation service, and any user can find SmolDocling-256M-preview on GitHub to install. At the same time, huggingface.co provides the effect of SmolDocling-256M-preview install, users can directly use SmolDocling-256M-preview installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
SmolDocling-256M-preview install url in huggingface.co: