feat: add layout_model per-request option for layout analysis model selection#113
Open
b-g-d wants to merge 1 commit intodocling-project:mainfrom
Open
feat: add layout_model per-request option for layout analysis model selection#113b-g-d wants to merge 1 commit intodocling-project:mainfrom
b-g-d wants to merge 1 commit intodocling-project:mainfrom
Conversation
…election Add a `layout_model` enum field to `ConvertDocumentsOptions` so users can select between docling's 6 layout analysis models without manually constructing verbose `layout_custom_config` dicts. A model_validator(mode="before") expands `layout_model` into the existing `layout_custom_config` dict, maintaining full backward compatibility. When `layout_custom_config` is explicitly provided, it takes precedence. Signed-off-by: bryan <b-g-d@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: bryan <b-g-d@users.noreply.github.com>
Contributor
|
✅ DCO Check Passed Thanks @b-g-d, all your commits are properly signed off. 🎉 |
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
layout_modelenum field toConvertDocumentsOptionsso users can select between docling's 6 layout analysis models (docling_layout_heron,docling_layout_heron_101,docling_layout_egret_medium,docling_layout_egret_large,docling_layout_egret_xlarge,docling_layout_v2) without manually constructing verboselayout_custom_configdicts.A
@model_validator(mode="before")expandslayout_modelinto the existinglayout_custom_configdict, maintaining full backward compatibility. Whenlayout_custom_configis explicitly provided, it takes precedence.Context
This was originally submitted as docling-serve#540, but @dolfim-ibm directed it here since the datamodel belongs in docling-jobkit. The docling-serve side (Gradio UI dropdown,
DOCLING_SERVE_DEFAULT_LAYOUT_MODELenv var, docs) will be submitted as a follow-up PR once this is merged.Changes
docling_jobkit/datamodel/convert.pyLayoutModelType+ 6 model spec constants; addLAYOUT_MODEL_SPECSmapping; addlayout_modelfield; addexpand_layout_modelmodel validator; updatelayout_custom_configdescription noting precedencetests/test_layout_model.pyTest plan
uv run pytest tests/test_layout_model.py— all 7 tests passuv run pytest tests/test_kind_selection.py tests/test_convert_options.py— all existing tests still passtest_options_validatorfailure is pre-existing on main (unrelatedInlineVlmOptionscomparison)Note on upcoming ONNX changes
@dolfim-ibm mentioned upcoming layout model changes with different ONNX runtimes. This PR only adds the
layout_model→layout_custom_configexpansion at the request options level and doesn't touch the runtime/converter layer, so it should be compatible with those changes. If theLayoutModelTypeenum orLayoutModelConfigshape changes in docling, theLAYOUT_MODEL_SPECSmapping here would need a corresponding update.