Doc2Dict: Information Extraction as Text Generation

Benjamin Townsend, Eamon Ito-Fisher, Lily Zhang, Madison MayarXiv 2021

Abstract

Traditional information extraction (IE) relies on complex pipelines involving token-level labeling and rule-based standardization. Doc2Dict reframes IE as a sequence-to-sequence text generation task. By leveraging the T5 architecture and a Fusion-in-Decoder approach, the model directly generates structured JSON from raw document text, bypassing the need for expensive span annotations and brittle post-processing.

Introduction: Moving Beyond Sequence Labeling

Information Extraction has long been dominated by the "sequence labeling" paradigm. In this setup, models are trained to identify specific spans of text—such as dates, names, or amounts—and assign them labels. However, extracting a string like "May 7th, 2019" is rarely the end goal; businesses need that data in a standardized format like "2019-05-07" for database entry.

This traditional approach introduces two significant bottlenecks. First, it requires "gold standard" token-level annotations, where humans must manually highlight exact spans in thousands of documents. Second, it necessitates a secondary "standardization" step, often involving complex regular expressions or heuristics to convert varied human-readable text into canonical data.

Comparison of Sequence Labeling vs. Text Generation framing.

Doc2Dict proposes a simpler alternative: if the desired output is a database record, why not train the model to generate that record directly? By treating the document as a source sequence and the JSON record as a target sequence, the model learns to extract and format data simultaneously.

Methods: Architecture and Innovations

The core of Doc2Dict is the T5 (Text-to-Text Transfer Transformer). Unlike BERT-style models that classify individual tokens, T5 is designed to map any text input to a text output.

Fusion-in-Decoder (FiD) for Long Documents

A major challenge in document processing is sequence length. Standard transformers struggle with documents exceeding 512 or 1024 tokens. Doc2Dict employs the Fusion-in-Decoder (FiD) architecture to overcome this. The document is split into overlapping chunks, each processed by an independent encoder. The decoder then attends to the concatenated representations of all chunks to generate the final JSON output.

The Fusion-in-Decoder (FiD) architecture for handling long documents.

Technical Refinements

To make this generative approach viable, the authors introduced several key techniques:

  • Gradient Checkpointing: This allowed the model to process up to 32,000 tokens on hardware with limited VRAM (11GB), making it accessible for practical use cases.
  • Entity Order Randomization: Since JSON keys are unordered, the model was trained to generate fields in random sequences. This prevents the model from over-relying on a specific output structure and improves robustness.
  • Numeric Tokenization: The authors found that standard subword tokenizers struggle with numbers. By modifying the tokenizer to treat digits as individual characters, the model's ability to perform numeric standardization improved drastically.

Evaluation and Results

The researchers tested Doc2Dict against established baselines across several diverse datasets, including Kleister-NDA (business contracts), DeepForm (political disclosures), and standard NLP benchmarks like OntoNotes.

The results were compelling. On the DeepForm dataset, Doc2Dict achieved an F1 score of 0.900, a massive improvement over the 0.761 achieved by traditional pipeline methods. On Kleister-NDA, it reached an F1 of 0.809, again surpassing the baseline.

Crucially, the model demonstrated an innate ability to learn standardization rules. For instance, it learned to format dates with near-perfect accuracy after seeing only a few thousand examples, effectively replacing hundreds of lines of custom regex code.

Discussion: The Power of Implicit Supervision

The most significant insight from Doc2Dict is the utility of "pre-existing data." Many organizations already have databases filled with information extracted from documents. Doc2Dict allows them to use this data for training without needing to go back and manually label where each piece of information was found in the original files. This "weak supervision" significantly lowers the barrier to building high-quality IE systems.

Limitations and Future Directions

While powerful, the generative approach is not without risks. Like all large language models, Doc2Dict can hallucinate. In one instance, it "corrected" a town name based on its internal knowledge rather than the document text. Future iterations could benefit from constrained decoding, ensuring the model only outputs values present in the source text or valid within a specific schema.

Additionally, the current model is "blind" to the visual layout of documents. Incorporating spatial coordinates (OCR boxes) into the input could further improve performance on complex forms where the relative position of text is a vital semantic cue.

Conclusion

Doc2Dict represents a paradigm shift in Information Extraction. By moving from labeling to generation, it simplifies the development pipeline, reduces annotation costs, and provides a more robust path toward end-to-end document understanding.

Summary updated

BibTeX
@misc{townsend2021doc,
  author = {Benjamin Townsend and Eamon Ito-Fisher and Lily Zhang and Madison May},
  title = {{Doc2Dict: Information Extraction as Text Generation}},
  year = {2021},
  eprint = {2105.07510},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2105.07510},
}
Figure