diff --git a/docling/cli/main.py b/docling/cli/main.py index 82c57efb..67afe69a 100644 --- a/docling/cli/main.py +++ b/docling/cli/main.py @@ -63,6 +63,8 @@ from docling.datamodel.vlm_model_specs import ( GOT2_TRANSFORMERS, GRANITE_VISION_OLLAMA, GRANITE_VISION_TRANSFORMERS, + GRANITEDOCLING_MLX, + GRANITEDOCLING_TRANSFORMERS, SMOLDOCLING_MLX, SMOLDOCLING_TRANSFORMERS, SMOLDOCLING_VLLM, @@ -655,6 +657,18 @@ def convert( # noqa: C901 "To run SmolDocling faster, please install mlx-vlm:\n" "pip install mlx-vlm" ) + elif vlm_model == VlmModelType.GRANITEDOCLING: + pipeline_options.vlm_options = GRANITEDOCLING_TRANSFORMERS + if sys.platform == "darwin": + try: + import mlx_vlm + + pipeline_options.vlm_options = GRANITEDOCLING_MLX + except ImportError: + _log.warning( + "To run SmolDocling faster, please install mlx-vlm:\n" + "pip install mlx-vlm" + ) elif vlm_model == VlmModelType.SMOLDOCLING_VLLM: pipeline_options.vlm_options = SMOLDOCLING_VLLM diff --git a/docling/datamodel/vlm_model_specs.py b/docling/datamodel/vlm_model_specs.py index 54d81978..fd3c347d 100644 --- a/docling/datamodel/vlm_model_specs.py +++ b/docling/datamodel/vlm_model_specs.py @@ -18,6 +18,29 @@ from docling.datamodel.pipeline_options_vlm_model import ( _log = logging.getLogger(__name__) +# Granite-Docling +GRANITEDOCLING_TRANSFORMERS = InlineVlmOptions( + repo_id="ds4sd/granite-docling-258m-2-9-2025-v2", + prompt="Convert this page to docling.", + response_format=ResponseFormat.DOCTAGS, + inference_framework=InferenceFramework.MLX, + supported_devices=[AcceleratorDevice.MPS], + scale=2.0, + temperature=0.0, + stop_strings=["", ""], +) + +GRANITEDOCLING_MLX = InlineVlmOptions( + repo_id="ds4sd/granite-docling-258m-2-9-2025-v2-mlx-bf16", + prompt="Convert this page to docling.", + response_format=ResponseFormat.DOCTAGS, + inference_framework=InferenceFramework.MLX, + supported_devices=[AcceleratorDevice.MPS], + scale=2.0, + temperature=0.0, + stop_strings=["", ""], +) + # SmolDocling SMOLDOCLING_MLX = InlineVlmOptions( repo_id="ds4sd/SmolDocling-256M-preview-mlx-bf16", @@ -272,3 +295,4 @@ class VlmModelType(str, Enum): GRANITE_VISION_VLLM = "granite_vision_vllm" GRANITE_VISION_OLLAMA = "granite_vision_ollama" GOT_OCR_2 = "got_ocr_2" + GRANITEDOCLING = "granite_docling"