[Paper Review] Pix2Struct: Screenshot Parsing as Pretraining for Visual Language Understanding
Pix2Struct is a pretrained image-to-text model that learns to parse masked screenshots into HTML-like structures and transfers this knowledge across nine visually-situated language tasks spanning four domains.
Visually-situated language is ubiquitous -- sources range from textbooks with diagrams to web pages with images and tables, to mobile apps with buttons and forms. Perhaps due to this diversity, previous work has typically relied on domain-specific recipes with limited sharing of the underlying data, model architectures, and objectives. We present Pix2Struct, a pretrained image-to-text model for purely visual language understanding, which can be finetuned on tasks containing visually-situated language. Pix2Struct is pretrained by learning to parse masked screenshots of web pages into simplified HTML. The web, with its richness of visual elements cleanly reflected in the HTML structure, provides a large source of pretraining data well suited to the diversity of downstream tasks. Intuitively, this objective subsumes common pretraining signals such as OCR, language modeling, image captioning. In addition to the novel pretraining strategy, we introduce a variable-resolution input representation and a more flexible integration of language and vision inputs, where language prompts such as questions are rendered directly on top of the input image. For the first time, we show that a single pretrained model can achieve state-of-the-art results in six out of nine tasks across four domains: documents, illustrations, user interfaces, and natural images.
Motivation & Objective
- Motivate the need for general-purpose visually-situated language understanding beyond domain-specific pipelines.
- Introduce a pixel-only pretraining objective that maps masked screenshots to HTML parses.
- Propose variable-resolution ViT inputs and a method to render textual prompts directly on input images.
- Demonstrate transfer of a single pretrained model to multiple downstream tasks with strong results.
Proposed method
- Pretrain two ViT-based image-to-text models (Base: 282M params; Large: 1.3B params) on 80M web-page screenshots paired with HTML-derived parses.
- Use a screenshot parsing objective: predict an HTML-based parse from a masked screenshot, with 50% text masking to encourage context use.
- Condense the HTML DOM to visible elements and a largest subtree fitting the target sequence length; draw a bounding box around the subtree on the screenshot.
- Adopt 2D absolute positional embeddings and variable-resolution inputs to preserve aspect ratios and handle varying resolutions.
- Warm up with a reading curriculum (text-only decoding on colored/random-font text) before fine-tuning on downstream tasks.
- During fine-tuning, render prompts (questions, bounding boxes) onto the input image and train a single image-to-text model end-to-end on task data.
Experimental results
Research questions
- RQ1Can a single pixel-only model trained with a screenshot parsing objective transfer effectively to multiple visually-situated language tasks across domains?
- RQ2How do variable-resolution inputs and on-image rendering of prompts affect performance and robustness across tasks?
- RQ3To what extent does the screenshot parsing pretraining signal subsume OCR, language modeling, and image captioning signals for downstream transfer?
Key findings
- Pix2Struct outperforms the Donut baseline on 8 of 9 benchmarks across four domains.
- The Large model achieves strong gains over the Base model, improving several task scores.
- Pix2Struct reaches state-of-the-art results on multiple UI and illustration tasks without domain-specific pipelines.
- On natural images and documents, Pix2Struct is competitive with or close to domain-optimized methods, despite lacking in-domain pretraining data.
- A key ablation shows removing the screenshot-parsing objective significantly degrades performance, underscoring its central role.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.