Does Structure Matter? Encoding Documents for Machine Reading Comprehension

Hui Wan, Song Feng, R. Chulaka Gunasekara, Siva Sankalp Patel, Sachindra Joshi, Luis A. Lastras

Abstract

Traditional Machine Reading Comprehension (MRC) models typically process documents as flat sequences of tokens. This approach often fails for long, structured documents where crucial context—such as section headers—is lost when text is segmented into sliding windows. We introduce TreeJC (Joint model with Cascaded inference), a framework that treats documents as hierarchical trees. By encoding "tree slices" that include a paragraph's ancestor chain of headers, TreeJC preserves vital semantic context. Our experiments on the NQStruct and D2DStruct datasets demonstrate that TreeJC significantly outperforms standard flat-sequence models and long-context Transformers like Longformer, while being more training-efficient.

Introduction: The Limitations of Flat Encoding

Most state-of-the-art MRC models, including BERT and RoBERTa, ignore the inherent hierarchical structure of real-world documents like Wikipedia pages or technical manuals. When a document exceeds a model's token limit, the standard "sliding window" approach chops it into overlapping segments. This process can strip a paragraph of its context. For example, a requirement listed under an "Applying Online" header might be misinterpreted as a general requirement if the header is lost in a previous window.

Figure 2: Comparison between a flat sequence view and a hierarchical tree view, illustrating how structural context is preserved for a user query.

The authors argue that "vertical" context—the hierarchy of headers leading to a specific piece of information—is as important as "horizontal" word-level context for accurate navigation of complex documents.

Methods: The TreeJC Framework

TreeJC moves away from arbitrary text windows toward a structure-aware representation:

  1. Tree Slicing: Documents are parsed into "tree slices." Each slice contains a leaf node (e.g., a paragraph or list item) paired with its ancestor chain (the sequence of titles and subtitles). This ensures that every piece of text is always accompanied by its structural context.
  2. Joint Model Architecture: Utilizing a RoBERTa-base encoder, the model simultaneously performs Paragraph Scoring (relevance detection) and Span Selection (finding the exact answer).
  3. Cascaded Inference: During testing, the model employs a beam-search-style approach to identify the top n most relevant tree slices before selecting the final answer span based on a combined score from both modules.

Experimental Evaluation

The model was evaluated on two structured datasets: NQStruct (Wikipedia-based) and D2DStruct (goal-oriented dialogues). TreeJC consistently outperformed baseline models across both datasets. Notably, it showed greater resilience as document length increased, maintaining high accuracy on texts exceeding 8,000 tokens.

Figure 5: Performance metrics on the NQStruct dataset, showing TreeJC's superiority in F1 and Exact Match scores compared to other models.

As shown in the results for NQStruct (Figure 5), TreeJC achieved an F1 score of 54.9 and an Exact Match of 44.2, surpassing both the standard Sliding Window (SW) and the Longformer. Furthermore, TreeJC proved to be highly efficient, requiring only 16 training hours compared to Longformer's 46 hours. On the D2DStruct dataset, TreeJC similarly outperformed the Sliding Window approach with an F1 of 53.7.

Discussion and Insights

The success of TreeJC highlights that document structure is not just a formatting detail but a core semantic component. An ablation study, LeafJC, which removed headers while keeping the same paragraph segmentation, performed worse than TreeJC. This confirms that the headers themselves provide the critical information needed for precise answer retrieval.

While TreeJC currently relies on explicit HTML markup, future iterations could incorporate structural inference for plain-text documents. Additionally, exploring more dynamic ancestor chain selection could further optimize the model for extremely dense documents like legal contracts or scientific papers.

Summary updated

BibTeX
@inproceedings{wan2021does,
  author = {Hui Wan and Song Feng and R. Chulaka Gunasekara and Siva Sankalp Patel and Sachindra Joshi and Luis A. Lastras},
  title = {{Does Structure Matter? Encoding Documents for Machine Reading Comprehension}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.naacl-main.367},
}
Figure