feat(API): expose PDF heading-level inference in the service API#3874
Open
DanielNg0729 wants to merge 1 commit into
Open
feat(API): expose PDF heading-level inference in the service API#3874DanielNg0729 wants to merge 1 commit into
DanielNg0729 wants to merge 1 commit into
Conversation
Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
Contributor
|
✅ DCO Check Passed Thanks @DanielNg0729, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake 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.
Issue resolved by this Pull Request:
Part of docling-project/docling-serve#646
#3633 and #3688 added inference of section-header levels from PDF bookmarks, outline numbering and font style, configurable via
PdfPipelineOptions.heading_hierarchy_optionsand off by default. Those options were not reachable from the service API, so every heading returned by docling-serve stayed atlevel=1and the document hierarchy came back flat.Since docling-project/docling-serve#575 moved the service request models into docling core, the API options model lives here while the pipeline mapping lives in docling-jobkit. Exposing this therefore takes three coordinated PRs:
ConvertDocumentsOptionsPdfPipelineOptionsand retain parsed pages for the style signalThis PR adds
heading_hierarchy_optionstoConvertDocumentsOptions, typed as the existingHeadingHierarchyOptionsso the API mirrorsPdfPipelineOptions.heading_hierarchy_optionsfield-for-field rather than introducing a parallel flat schema. That keeps one place to learn and avoids drift as the pipeline options evolve, and it means the nested knobs (use_bookmarks,use_numbering,use_style,numbering_schemes,max_level,bookmark_match_threshold) come along for free, including theirge/lebounds and their descriptions in generated API docs.The nested model also works over
multipart/form-data, where docling-serve'sFormDependsaccepts nested models as JSON strings, verified in docling-project/docling-serve#662.Verification
Schema generation, defaults and validation:
ConvertDocumentsOptions().heading_hierarchy_options.enabledisFalsemodel_json_schema()resolves the$refand serializes bothexamples{"enabled": true, "max_level": 4}), unset keys keep their model defaultsmax_level: 0raises)End-to-end through docling-serve's
/v1/convert/file, converting2408.09869v5.pdfwith all three PRs applied:{1: 20}{"enabled": true}{1: 8, 2: 6, 3: 4, 4: 2}3.1 PDF backends→ level 2,Layout Analysis Model→ level 3,Abstract→ level 2. 12 of 20 headings corrected, and the default path is unchanged.Checklist: