docling-project / docling-project/docling

Cross-page Table Merging Using LLMs

Open
#2,060 2 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

### Requested feature

#### Problem
In processing PDFs where tables are split across sequential pages, I encountered a recurring issue: tables that are visually contiguous get split during conversion. This results in broken table data that is hard to parse or use effectively.

Docling currently processes each table independently, even if a table continues on the next page. This often leads to split tables that should actually be merged into one logical table. While this is expected behavior, it becomes problematic for downstream use cases where clean, unified tables are needed.

#### Proposal
I've implemented a prototype class that introduces an LLM-assisted heuristic to detect and merge split tables across pages. It works as follow:

1. **Heuristic-based filtering**: For each page pair, I select the last table of the current page and the first table of the next page. A heuristic based on bounding box position is used to filter candidate table pairs that might be continuations.
2. **LLM validation and merging**: The selected Markdown tables are passed to an LLM with a prompt to check whether they are two parts of the same table. If confirmed, the LLM merges them; otherwise, they are kept as-is.
3. **Table markers and merging logic**: I insert temporary markers around tables in the Markdown output to locate and replace them cleanly after merging.
4. **Result**: The resulting Markdown output includes unified tables across pages when appropriate, improving downstream usability.

#### Feature Request
I'd love to propose this as an optional feature for Docling. I would allow users to configure whether to use an LLM, the provider and the thresholds for bounding box heuristics.

### Alternatives
An alternative could be to explicitly concatenate the tables if the heuristic returns true.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.