[Feature Request]: Emit content_list-shaped blocks from the Docling parser adapter for LightRAG and LlamaIndex
Do you need to file a feature request?
- [x] I have searched the existing feature request and this feature request is not already filed.
- [x] I believe this is a legitimate feature request, not just a question or bug.
Feature Request Description
The Docling engine in DeepTutor produces markdown only. The LightRAG-native multimodal pipeline, added when PR #1069 replaced RAG-Anything (the migration requested in #943), works from structured blocks when they exist. A LightRAG knowledge base built with Docling as its parsing engine therefore silently ends up with a markdown-only index. It has no equation, table, or image blocks, no extracted image assets, and no block-level filtering of page chrome. It also uses fixed-token chunking where paragraph-semantic chunking would apply. The index-version panel shows a short prefix of each version's signature, not the parser's name.
Most of this is a wiring gap in DeepTutor's adapter, but the evidence below also shows where Docling has limits of its own. The adapter's docstring defers the block mapping:
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/engines/docling/engine.py#L1-L10
LightRAG is wired now. The adapter schema is 2, the parser bridge schema is 1, and the sidecar consumes frozen blocks. The condition the docstring names, wiring LightRAG, is therefore met, but the block mapping was never written. The IR contract docstring already lists Docling among the sources of blocks:
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/types.py#L30
Docling's documented capabilities, including image processing
Docling's documentation covers most of what the block pipeline needs, so the request is mainly a mapping task. Two details need extra care, and both are covered below: page numbers have no label of their own, and formula enrichment acts only on items labeled formula. Image processing is documented upstream. The Enrichments page describes figure extraction and classification as pipeline options:
pipeline_options.generate_picture_images = True # crops each PictureItem into an image file
pipeline_options.images_scale = 2 # resolution of the crops
pipeline_options.do_picture_classification = True # DocumentFigureClassifier: chart types,
# flow diagrams, logos, signatures, ...
In Docling 2.148.0, generate_picture_images and do_picture_classification both default to False, so each one has to be enabled explicitly.
The same page covers do_picture_description. It captions PictureItems with a local Granite or SmolVLM model, or with an OpenAI-compatible endpoint through PictureDescriptionApiOptions, and it can record usage metadata from the response. DeepTutor's global image_caption and image_description_model settings could map onto these options, but they never reach the Docling worker.
The Docling document concepts page describes DoclingDocument as a pydantic tree of typed items: texts (paragraphs, section headings, and equations), tables (TableItem, which "can carry structure annotations"), and pictures (PictureItem). Headers and footers belong to a separate furniture layer, apart from the body. Items also carry bounding boxes when available, along with provenance. These fields could map onto the bridge IR's type, text, latex, table_body, bbox, and page_idx fields. The chrome labels map only partly, as gap 4 explains.
The Enrichments page says that, with do_formula_enrichment = True, the formula step "will analyze the equation formulas in documents and extract their LaTeX representation". The page configures that step with a VLM option, CodeFormulaVlmOptions.from_preset("codeformulav2", ...). Its feature table lists the processed item as a TextItem labeled FORMULA. The code enforces that filter, so math that the layout stage labels some other way would not reach the step. The mapper has to account for that.
The Serialization page says the JSON form is lossless, including the full TableData.grid span metadata. Doclang and DocTags serialize tables as OTSL, and HTML emits native rowspan and colspan attributes. Markdown flattens spans. The page also warns:
If your downstream workflow depends on accurate table structure (e.g. merged header cells), prefer
export_to_html()orexport_to_dict()overexport_to_markdown().
DeepTutor's worker calls export_to_markdown(), which the page advises against when table structure matters. The same page notes that a table serializer can be replaced by subclassing BaseTableSerializer, so table blocks could carry HTML or OTSL instead of flattened pipes.
The API reference page is generated from docling_core.types.doc, and its DoclingDocument class provides save_as_json and load_from_json, as well as save_as_doctags and load_from_doctags. The worker already runs in a fresh interpreter, started with sys.executable, so structured output could come back through one of these formats without pickling model objects.
The following checks were run against Docling 2.148.0 and docling-core 2.106.0. PdfPipelineOptions exposes generate_picture_images, images_scale, do_picture_classification, do_picture_description, and do_formula_enrichment. The serializers are MarkdownDocSerializer and DocTagsDocSerializer. They are defined in the markdown and doctags modules of docling_core.transforms.serializer, because the package's __init__.py exports nothing. The default figure classifier is DocumentFigureClassifier-v2.5, and remote picture description requires enable_remote_services=True.
Concrete gaps in the current adapter (DeepTutor 1.7.2, Docling 2.148.0)
Gaps 1 to 7 are in DeepTutor's own code. Gap 8 concerns the format table. The shipped Docling floor is 2.123.1. The author also reproduced the gaps on 2.133.0.
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/engines/docling/local_worker.py#L117-L131 https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/cache.py#L162-L189 https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/rag/pipelines/lightrag/ingress.py#L257
The worker writes no blocks. It writes only <stem>.md, produced by export_to_markdown(). cache.load_ir finds no *_content_list.json and returns blocks=None. ingress.freeze_document then takes the block-less branch, which sets process_options to "F" and chunks with {"fixed_token": {}}. No blocks.json is written, so every Docling bundle records "process_options": "F".
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/engines/docling/local_worker.py#L96-L114
The Docling path produces no image assets. _build_converter never sets generate_picture_images, and nothing in the Docling adapter collects picture crops. load_ir reads an images/ directory when one exists, but the Docling path never creates one. In a local 46-document Docling knowledge base, the registered asset count is 0, while the equivalent MinerU bundles carry 29 to 41 figure crops each. Without assets, the default markdown export leaves an <!-- image --> placeholder where each picture was.
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/engines/docling/local_worker.py#L105-L107
The formula and picture enrichments are never enabled. _build_converter sets only do_ocr and do_table_structure. do_formula_enrichment and do_picture_description exist upstream, but the adapter never sets them. Equations that MinerU emits as equation blocks with LaTeX come through the Docling path as OCR text or not at all. In local tests, RapidOCR returned empty output on math glyphs.
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/rag/pipelines/lightrag/block_policy.py#L102-L103 https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/rag/pipelines/lightrag/block_policy.py#L39-L45
Page chrome is not filtered at the block level. Docling already labels headers and footers as page_header and page_footer, and its reading-order stage moves them into the furniture layer. The default markdown export includes only the body layer, so the indexed markdown already leaves them out. What is missing is DeepTutor's own block filter. prepare_content_list returns early for any engine other than mineru, so blocks from Docling would pass through unfiltered if they existed. Docling has no page_number label, so a page number is excluded only when the layout model tags it as a header or footer. The V2_AUXILIARY_EQUIVALENTS table maps MinerU's legacy filter names onto its newer page_header and page_footer names. Docling uses the same strings, so the table is a possible starting point for the mapper. It was written for MinerU, however, and its comment says it exists because MinerU renamed its auxiliary block types.
- The Docling settings hold no picture options. The Docling section of
document_parsing.jsonstores onlymode,api_base_url,api_token,do_ocr,do_table_structure, andallow_local_model_download. The globalimage_captionandimage_description_modelsettings are read by other code paths, such asdeeptutor/reading/captions.pyanddeeptutor/services/llm/image_description.py. The Docling worker never receives them, even though they could map onto Docling's picture-description options.
Secondary problems in the same component are worth fixing in the same pass.
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/engines/docling/local_worker.py#L111-L114
Option-setup errors are swallowed, and it logs nothing. That fallback runs on Docling's own defaults. In Docling 2.148.0 and 2.123.1, do_ocr defaults to True, while DeepTutor's default is False. A failed option setup therefore turns OCR on without any log entry, which makes misconfigured OCR hard to diagnose.
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/engines/docling/engine.py#L92-L100 https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/engines/docling/remote.py#L72-L89 https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/engines/docling/remote.py#L96-L120
The remote-mode signature ignores the server version. [signature() builds the remote version string from the static floor, remote-{MIN_DOCLING_VERSION}:{api_base_url}. verify_remote reads the server's /version, but only to build the readiness message. Upgrading a Docling Serve host therefore leaves the parser signature unchanged, so cached parses from the old server keep being reused. _convert_file requests to_formats: "md" only, so remote mode has the same no-blocks limit.
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/engines/docling/formats.py#L18-L23
The format table has drifted from Docling 2.148.0. formats.py pins Docling 2.123.1's extension set, which has 74 entries, and the engine reports that set as its supported formats. Docling 2.148.0's FormatToExtensions lists 88 distinct extensions after lowercasing, from 92 raw entries. Fourteen of them are missing from the table: .afp, .gif, .ical, .icalendar, .ics, .ifb, .key, .markdown, .mht, .mhtml, .numbers, .rtf, .xltm, and .xltx. Matching is case-insensitive, so .Rmd is covered by the table's .rmd entry. For an implicitly selected engine, ParseService sends an unlisted file to the first installed fallback engine that supports it, trying text_only, markitdown, and tika in that order. If none does, or if the caller pinned Docling, parsing raises an error. Either way, those uploads never reach Docling. (Same bug class, different table: #2338.)
The 11 DeepTutor files linked above are byte-identical to the v1.7.2 wheel contents. The permalinks point to the v1.7.2 tag commit, so the anchors stay valid.
Motivation
- Docling is an optional extra,
deeptutor[parse-docling], and the default engine istext_only. Docling is the lighter install, because it avoids the multi-GB MinerU weights. In local testing it was also the only working parser for documents where MinerU's pipeline mode fails. In one local corpus, single-page slide-export PDFs e.x. (596×12930 pt) collapse to a single empty table under MinerU 3.4.5 and parse cleanly under Docling, while MinerU's multimodal blocks made the same corpus searchable elsewhere. Users pick one engine globally. The fallback from #1502 covers unsupported file types only, so the choice trades better handling of scanned and odd-geometry pages against the whole multimodal pipeline. - The failure is silent. Knowledge bases report
status: readywith normal statistics, and the bundle manifests record the difference, throughprocess_options: "F"and empty asset lists. In a local audit of a six-knowledge-base LightRAG install, five knowledge bases holding 97 documents show"F"with zero assets. Only the MinerU-built knowledge base has blocks, with 146 assets. - The chunking difference is structural, but this issue does not measure its effect on retrieval quality. Paragraph-semantic chunking with
chunk_token_size1200 runs over typed equations, tables, and figures. Fixed-token windows run over flat markdown.
Proposed implementation
The bridge IR contract can stay as it is, and the change is local to the Docling adapter. Docling supplies most of the structure, and the adapter maps it. The mapper has to handle two details: Docling has no label for page numbers, and formula enrichment acts only on items labeled formula.
_build_converter:
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/engines/docling/local_worker.py#L96-L114
Set generate_picture_images=True and images_scale. Gate do_formula_enrichment, do_picture_classification, and do_picture_description behind new Docling config keys and the existing global image_caption and image_description_model settings. Replace the broad except Exception with a logged, narrow fallback.
_convert:
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/engines/docling/local_worker.py#L117-L131
Walk result.document, whose items are described on the concepts page above. Use body reading order, keep furniture separate, and write the PictureItem crops that generate_picture_images produces. Write a MinerU-shaped *_content_list.json and an images/ directory into the workdir. Docling's labels are close to MinerU v2's. V2_AUXILIARY_EQUIVALENTS can guide the chrome names, because its page_header and page_footer values match Docling's labels. Tables can carry HTML or OTSL through a serializer override instead of flattened pipes.
- The downstream code already reads blocks.
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/cache.py#L162-L189
cache.load_ir already loads *_content_list.json and images/. ingress.freeze_document already routes blocks through prepare_content_list and _freeze_asset_paths, and the sidecar reads the frozen blocks from the bundle manifest. No module in the LightRAG pipeline imports visual_assets.
signature()
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/engines/docling/engine.py#L92-L100
Include the enrichment flags, so that changing them invalidates the parse cache. The signature covers only do_ocr and do_table_structure today. In local mode it already includes the installed Docling version. In the author's environment, the 2.133 to 2.148 upgrade changed the hash from cb2a2297473acbe0 to 2435dc723dd1f760, so version upgrades already invalidate stale parses.
-
Remote mode: request a structured export (
to_formats, as docling-serve defines it), and include the server's/versionin the signature. The adapter already reads that value. Alternatively, document in Settings that remote mode produces markdown only. -
Refresh the static format table for the current floor, and pin both the table and the floor with a test.
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/rag/pipelines/lightrag/block_policy.py#L102-L103
The block-policy gate at block_policy.py#L102-L103 can stay, because POLICY_ID names the MinerU legacy content-list policy (mineru-legacy-content-list-v1). The mapper should either emit blocks that are already sanitized, or the gate should be widened with a Docling-specific policy ID and its own audit-ledger entry.
Alternatives considered
- Using MinerU for multimodal content is the de facto answer today. On the points measured locally, it is also heavier and slower. It needs multi-GB weights and first-run downloads, takes about five times longer on small excerpts (161 s vs 31 s on the same two pages), and fails outright on extreme page geometry that Docling handles. It also leaves the silent degradation in place for users who chose the Docling extra.
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/rag/pipelines/lightrag/storage.py#L221 https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/rag/pipelines/lightrag/storage.py#L337 https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/knowledge/manager.py#L1429-L1460 https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/api/routers/knowledge.py#L2854
- A UI warning for a LightRAG knowledge base built from a block-less engine is cheap, because the data is already recorded.
storage._parser_inputsbuilds a sorted, de-duplicated list of{engine, parser_signature}pairs, and the index metadata stores that list inmeta.json. Each flat version entry starts from a copy of its stored metadata (services/rag/index_versioning.py, around line 143).manager.get_inforeports those versions understatistics.index_versions, and the list endpoint passesstatisticsthrough. The list therefore sits understatistics, notmetadata. This is only a stopgap. It tells users they got a weaker index, but it does not fix the adapter.
https://github.com/HKUDS/DeepTutor/blob/60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db/deeptutor/services/parsing/types.py#L30
- Dropping the LightRAG compatibility that Docling advertises would be a worse experience than finishing the mapping that
types.py#L30already describes.
Additional context
The related work includes #943 (the request to migrate the local LightRAG provider to LightRAG's native multimodal pipeline, completed by PR #1069 and closed on 2026-08-30), #831 (remote Docling and Tika), #1502 (parser routing fallback), #2164 (parser install guidance that names a CLI command the official Docker image lacks, fixed by PR #2180), and #2327 (the Docling parser extra fails to install in that image). PR #2328, merged on 2026-11-05, keeps Docling's format-video extra out of the parser manifest, because its resemblyzer → webrtcvad chain ships only as source. #2327 is still open. #2338 covers legacy Office formats (.doc, .xls, .ppt) that pass upload validation but that the built-in extractor cannot parse. In DeepTutor's parsing engines, only Tika, Docling, and LiteParse list .doc. This is the same class as gap 8. #431 reports scanned PDFs that come back empty with a "Skipped empty document" error. The reporter traced the empty result to PyMuPDF text extraction in document_loader.py, with no OCR fallback at the time. Two merged PRs followed, #1073 explaining the failure and #1386 adding a LiteParse OCR fallback, but the issue itself is still open.
Once the mapper lands, HKUDS/LightRAG#4226 (MinerU and Docling IR builders list non-ancestor headings in parent_headings when heading levels skip or start below 1) applies to any new IR builder that emits heading context. DeepTutor's own sidecar builder already uses the same level-indexed heading stack, so the same skip case can already affect its parent headings.
The Settings → Document Parsing description for Docling reads "Structured conversion across Docling's current document, image, e-book…". That description is accurate for Docling itself, but it overstates what DeepTutor delivers until this lands. The knowledge base documentation's engine notes need an update as well.
Versions
DeepTutor 1.7.2 (deeptutor-parsing 1.7.2, deeptutor-parser-docling 1.7.2), Docling and docling-slim 2.148.0 (the author also reproduced on 2.133.0), docling-core 2.106.0 for the serializer and default-layer checks, lightrag-hku 1.5.7, Linux x86_64, local mode. The shipped Docling floor is 2.123.1. Code permalinks are pinned to tag v1.7.2, commit 60fb3bdfddb30b7740c7ce3bd9b28d908f2af6db. Each of the 11 linked DeepTutor files matches the v1.7.2 wheel contents byte for byte.
Docling documentation cited
- https://docling-project.github.io/docling/usage/enrichments/ (picture extraction, classification, and description; formula to LaTeX)
- https://docling-project.github.io/docling/concepts/docling_document/ (typed block tree, furniture and body layers, bounding boxes, provenance)
- https://docling-project.github.io/docling/concepts/serialization/ (JSON is lossless; DocTags and HTML preserve table spans; markdown flattens them)
- https://docling-project.github.io/docling/reference/docling_document/ (
save_as_jsonandload_from_json, plus the DocTags round-trip methods)
Related Module
Knowledge Base Management
Use Case
No response
Additional Context
Deeptutor v1.7.2 using pypi web.
Gap 6 (the swallowed option-setup failure) is small and self-contained, so I can take that one without touching the block mapper in gaps 1-3.
The problem as I read it: _build_converter catches Exception and silently returns a default DocumentConverter(). Docling 2.148.0 defaults do_ocr to True while DeepTutor's default is False, so a failed option setup silently turns OCR on and the parse still succeeds, leaving nothing in the log to explain the slower, different output.
The fix I am planning, scoped to _build_converter in local_worker.py:
- keep the upstream-default fallback (a compatible Docling release with a shifted option API should still convert);
- emit exactly one stderr line naming the exception type, the message, and the two options that are being dropped, since the worker runs under python -m and the parent already relays every stdout/stderr line through on_output;
- catch the import errors for InputFormat / PdfPipelineOptions / PdfFormatOption separately from the option-assignment errors, so a genuinely missing Docling install keeps raising rather than silently degrading.
Tests: no Docling install is needed. _build_converter imports Docling inside the function, so a test can inject a stub docling package into sys.modules and assert (a) the configured path returns a converter with both options applied, (b) a failing option API still returns a converter and writes the diagnostic line, (c) a missing docling.datamodel submodule propagates instead of being swallowed.
I am not touching gaps 1-5, 7 or 8 here: the block mapper is the substantive part of this issue and deserves its own design review, and gap 8 is a separate data refresh. If a maintainer would rather have gap 6 folded into the larger mapper change, say so and I will wait instead of opening a PR.
Fixed on local dev (e96cba219c55cbf2da454c47f35fbbbe65fd4028). feat(docling): expose optional enrichments and version remote cache. 245 Python tests passed, 1 skipped; optional model enrichments tested with stubs, no live models or paid inference; remote Markdown limitation disclosed in settings.
will be fixed in the next releases!