Skip to main content
QUICK REVIEW

[Paper Review] The Law of Large Documents: Understanding the Structure of Legal Contracts Using Visual Cues

Allison Hegel, Marina Shah|arXiv (Cornell University)|Jul 16, 2021
Artificial Intelligence in Law4 citations
TL;DR

This paper proposes a method that leverages OCR-derived visual and structural cues—such as layout, font, indentation, and page breaks—to improve long-document understanding in legal contracts. By integrating these visual features with transformer-based NLP models, the approach outperforms existing segmentation strategies on four tasks (document segmentation, entity extraction, attribute classification) using the CUAD dataset, demonstrating that visual metadata significantly enhances accuracy on long, complex legal documents.

ABSTRACT

Large, pre-trained transformer models like BERT have achieved state-of-the-art results on document understanding tasks, but most implementations can only consider 512 tokens at a time. For many real-world applications, documents can be much longer, and the segmentation strategies typically used on longer documents miss out on document structure and contextual information, hurting their results on downstream tasks. In our work on legal agreements, we find that visual cues such as layout, style, and placement of text in a document are strong features that are crucial to achieving an acceptable level of accuracy on long documents. We measure the impact of incorporating such visual cues, obtained via computer vision methods, on the accuracy of document understanding tasks including document segmentation, entity extraction, and attribute classification. Our method of segmenting documents based on structural metadata out-performs existing methods on four long-document understanding tasks as measured on the Contract Understanding Atticus Dataset.

Motivation & Objective

  • Address the challenge of understanding long legal contracts that exceed the context length of standard NLP models like BERT.
  • Overcome limitations of standard document segmentation methods that discard structural and contextual information.
  • Investigate whether visual cues from OCR—such as layout, font, and page breaks—can improve document understanding in long-form legal texts.
  • Develop and evaluate a method that integrates visual metadata with deep learning models to enhance downstream NLP tasks on legal contracts.
  • Demonstrate the effectiveness of visual features in reducing errors caused by page breaks, headers, and inconsistent formatting in legal documents.

Proposed method

  • Extract rich OCR metadata from scanned legal contracts, including text bounding boxes, font size, style, justification, and indentation levels.
  • Use this OCR metadata to reconstruct document structure and infer section boundaries, replacing simple token-based segmentation.
  • Integrate visual features into a BERT-based transformer model by encoding spatial and stylistic metadata as additional input embeddings.
  • Train and fine-tune the model on four downstream tasks: document segmentation, entity extraction, attribute classification, and span prediction.
  • Apply a structured segmentation strategy based on visual cues rather than fixed windowing or sliding tokens, preserving document-level context.
  • Evaluate performance on the Contract Understanding Atticus Dataset (CUAD), comparing with baseline methods that ignore visual structure.

Experimental results

Research questions

  • RQ1To what extent do OCR-derived visual cues improve the accuracy of document understanding in long legal contracts?
  • RQ2How does incorporating layout and formatting information affect performance on document segmentation and span prediction tasks?
  • RQ3Can visual features reduce errors caused by page breaks, headers, footers, and inconsistent formatting in legal documents?
  • RQ4How does document length impact the difficulty of understanding tasks, and does visual modeling mitigate this effect?
  • RQ5Does a structure-aware segmentation strategy outperform standard sliding-window or fixed-segmentation approaches on long legal documents?

Key findings

  • The proposed method outperforms existing segmentation strategies on all four tasks evaluated: document segmentation, entity extraction, attribute classification, and span prediction.
  • Incorporating OCR-derived visual cues significantly improves model accuracy, especially in handling complex formatting such as page breaks and multi-line spans.
  • The model achieves state-of-the-art performance on the CUAD dataset by leveraging visual metadata to maintain document-level context across long documents.
  • Visual features reduce errors caused by page breaks and extraneous text (e.g., headers, footers), such as correctly identifying 'State of Massachusetts' across a page boundary.
  • The study quantifies that document length increases task difficulty, but visual cues help mitigate this effect, improving robustness on longer contracts.
  • The ablation study confirms that visual features contribute meaningfully to performance, with significant accuracy gains when compared to text-only baselines.

Better researchstarts right now

From reading papers to final review, dramatically reduce your research time.

No credit card · Free plan available

This review was created by AI and reviewed by human editors.