mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-08 12:48:28 +00:00
adding granite-docling preview
Signed-off-by: Peter Staar <taa@zurich.ibm.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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=["</doctag>", "<end_of_utterance>"],
|
||||
)
|
||||
|
||||
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=["</doctag>", "<end_of_utterance>"],
|
||||
)
|
||||
|
||||
# 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"
|
||||
|
||||
Reference in New Issue
Block a user