Seg2Act: Global Context-aware Action Generation for Document Logical Structuring

Zichao Li, Shaojie He, Meng Liao, Xuanang Chen, Yaojie Lu, Hongyu Lin, Yanxiong Lu, Xianpei Han, Le Sun

Abstract

Document logical structuring is the process of transforming fragmented OCR text into a coherent hierarchical tree. Traditional approaches often rely on multi-stage pipelines or pairwise classification, which are prone to error propagation and fail to capture long-range dependencies. We introduce SEG2ACT, an end-to-end framework that treats document structuring as an action generation task. By leveraging a Large Language Model (LLM) integrated with a "Global Context Stack," SEG2ACT maintains a semantic map of the document's hierarchy. Our experiments demonstrate that SEG2ACT significantly outperforms existing state-of-the-art methods, particularly in handling deep structures and long-form documents.

Introduction

Real-world documents, such as financial reports, scientific papers, and legal filings, possess deep hierarchical structures with nested headings and paragraphs. However, Optical Character Recognition (OCR) typically outputs a flat, fragmented list of text segments. Reconstructing the original hierarchy—Document Logical Structuring—is critical for downstream tasks like information extraction and document understanding.

Existing methods often suffer from "short-sightedness." Pipeline-based systems accumulate errors across stages, while pairwise models fail to relate distant segments (e.g., a heading on page 1 and a sub-section on page 5). SEG2ACT addresses these challenges by reframing the problem as a sequence-to-sequence generation task where the model "acts" on text segments to build the document tree.

Methodology: The SEG2ACT Framework

SEG2ACT treats document structuring as a language generation problem, where the "language" consists of structural actions.

Action-Based Structuring

The model generates three primary actions to construct the hierarchy:

  • New Level-k Heading (+): Inserts a heading at a specific depth in the tree.
  • New Paragraph (*): Adds a leaf node containing body text.
  • Concatenation (=): Merges the current segment with the previous one, effectively handling OCR-induced line breaks within sentences.

Global Context Stack

To overcome the limitations of local context, SEG2ACT maintains a Global Context Stack. This stack stores the path from the document root to the current node, including the semantic content of parent headings. This stack is fed back into the LLM, providing a "global map" that informs the placement of subsequent segments.

Overview of the SEG2ACT architecture featuring the Global Context Stack and Action Generation Model.

Multi-segment Strategy

Efficiency and local context are improved through a multi-segment multi-action strategy. Instead of processing lines individually, the model analyzes a window of segments and predicts a corresponding sequence of actions simultaneously.

Experimental Evaluation

We evaluated SEG2ACT on two major benchmarks: ChCatExt (a Chinese corpus of 650 financial and administrative documents) and HierDoc (650 English scientific documents).

Key Results

  • State-of-the-Art Performance: On the ChCatExt dataset, SEG2ACT (using a Baichuan-7B backbone) achieved a 63.69% Document Accuracy (DocAcc), representing a substantial improvement over the previous state-of-the-art, TRACER (53.85%).
  • Zero-Shot Generalization: In zero-shot transfer tests from a Wiki-based pre-training corpus to bid announcements, SEG2ACT achieved an F1-score of 56.25, while the baseline TRACER struggled at 2.70.
  • Robustness to Complexity: As shown in the performance analysis, SEG2ACT maintains high F1-scores even as document depth and token length increase, outperforming baselines that degrade more rapidly in complex scenarios.
Performance comparison of SEG2ACT against baselines across varying document logical depths and token lengths.

Discussion and Insights

The success of SEG2ACT stems from treating document structure as a language. By representing hierarchy as a sequence of symbols (+, *, =), the model leverages the sequential reasoning capabilities of LLMs. Ablation studies confirmed that the semantic content within the Global Context Stack is vital; removing text from the stack leads to a significant performance drop, proving the model relies on the meaning of parent headings to determine logical placement.

Furthermore, SEG2ACT demonstrates high sample efficiency. In 5-shot learning scenarios, it achieved results comparable to full-dataset training, indicating that the action-generation framework is highly generalizable across different document domains.

Limitations and Future Work

Despite its performance, SEG2ACT is currently "blind" to visual layout cues such as font size, bolding, or indentation. These features are often primary indicators of hierarchy for human readers. Additionally, the generative nature of the model can occasionally lead to a mismatch between the number of generated actions and input segments. Future research will focus on integrating multi-modal LLMs to incorporate visual information and extending the model's capacity to handle extremely long documents.

Conclusion

SEG2ACT reimagines document logical structuring as a generative action task. By combining the reasoning power of LLMs with a global context mechanism, it provides a robust and efficient solution for transforming flat OCR outputs into structured, machine-readable hierarchies.

Summary updated

BibTeX
@inproceedings{li2024seg,
  author = {Zichao Li and Shaojie He and Meng Liao and Xuanang Chen and Yaojie Lu and Hongyu Lin and Yanxiong Lu and Xianpei Han and Le Sun},
  title = {{Seg2Act: Global Context-aware Action Generation for Document Logical Structuring}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.1003},
}
Figure