mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-08 12:48:28 +00:00
docs: Describe examples (#2262)
* Update .py examples with clearer guidance, update out of date imports and calls Signed-off-by: Mingxuan Zhao <43148277+mingxzhao@users.noreply.github.com> * Fix minimal.py string error, fix ruff format error Signed-off-by: Mingxuan Zhao <43148277+mingxzhao@users.noreply.github.com> * fix more CI issues Signed-off-by: Mingxuan Zhao <43148277+mingxzhao@users.noreply.github.com> --------- Signed-off-by: Mingxuan Zhao <43148277+mingxzhao@users.noreply.github.com>
This commit is contained in:
26
docs/examples/minimal_vlm_pipeline.py
vendored
26
docs/examples/minimal_vlm_pipeline.py
vendored
@@ -1,3 +1,25 @@
|
||||
# %% [markdown]
|
||||
# Minimal VLM pipeline example: convert a PDF using a vision-language model.
|
||||
#
|
||||
# What this example does
|
||||
# - Runs the VLM-powered pipeline on a PDF (by URL) and prints Markdown output.
|
||||
# - Shows two setups: default (Transformers/SmolDocling) and macOS MPS/MLX.
|
||||
#
|
||||
# Prerequisites
|
||||
# - Install Docling with VLM extras and the appropriate backend (Transformers or MLX).
|
||||
# - Ensure your environment can download model weights (e.g., from Hugging Face).
|
||||
#
|
||||
# How to run
|
||||
# - From the repository root, run: `python docs/examples/minimal_vlm_pipeline.py`.
|
||||
# - The script prints the converted Markdown to stdout.
|
||||
#
|
||||
# Notes
|
||||
# - `source` may be a local path or a URL to a PDF.
|
||||
# - The second section demonstrates macOS MPS acceleration via MLX (`vlm_model_specs.SMOLDOCLING_MLX`).
|
||||
# - For more configurations and model comparisons, see `docs/examples/compare_vlm_models.py`.
|
||||
|
||||
# %%
|
||||
|
||||
from docling.datamodel import vlm_model_specs
|
||||
from docling.datamodel.base_models import InputFormat
|
||||
from docling.datamodel.pipeline_options import (
|
||||
@@ -6,6 +28,7 @@ from docling.datamodel.pipeline_options import (
|
||||
from docling.document_converter import DocumentConverter, PdfFormatOption
|
||||
from docling.pipeline.vlm_pipeline import VlmPipeline
|
||||
|
||||
# Convert a public arXiv PDF; replace with a local path if preferred.
|
||||
source = "https://arxiv.org/pdf/2501.17887"
|
||||
|
||||
###### USING SIMPLE DEFAULT VALUES
|
||||
@@ -26,7 +49,8 @@ print(doc.export_to_markdown())
|
||||
|
||||
|
||||
###### USING MACOS MPS ACCELERATOR
|
||||
# For more options see the compare_vlm_models.py example.
|
||||
# Demonstrates using MLX on macOS with MPS acceleration (macOS only).
|
||||
# For more options see the `compare_vlm_models.py` example.
|
||||
|
||||
pipeline_options = VlmPipelineOptions(
|
||||
vlm_options=vlm_model_specs.SMOLDOCLING_MLX,
|
||||
|
||||
Reference in New Issue
Block a user