Image2Struct: Benchmarking Structure Extraction for Vision-Language Models

Josselin Somerville Roberts, Tony Lee, Chi Heem Wong, Michihiro Yasunaga, Yifan Mai, Percy Liang

Abstract: Image2Struct is a new benchmark that evaluates Vision-Language Models (VLMs) on their ability to convert images—such as screenshots of webpages, mathematical equations, or sheet music—back into their underlying structured code (HTML, LaTeX, or LilyPond). By using a "round-trip" evaluation that renders the model's generated code back into an image and compares it to the original, the benchmark provides a fully automated way to measure performance on complex, real-world tasks without requiring human graders.

The Challenge of Evaluating Structure Extraction

As Vision-Language Models (VLMs) like GPT-4o and Claude 3.5 Sonnet become more capable, evaluating them becomes increasingly difficult. Traditional benchmarks often rely on Multiple Choice Question Answering (MCQA), which fails to capture the complexity of real-world workflows, or they require expensive human experts to grade long-form outputs.

A particularly high-value use case for VLMs is structure extraction: taking a screenshot of a website, a complex mathematical formula, or a musical score and generating the code required to recreate it. However, benchmarking this is notoriously difficult because there are often dozens of "correct" ways to write the same code. A simple string comparison against a ground-truth file would unfairly penalize a model that produces perfectly functional but syntactically different code.

The Round-Trip Evaluation Method

To solve the syntax variation problem, the authors propose a round-trip evaluation pipeline. Instead of grading the raw code itself, the system evaluates the visual output that the code produces.

The Image2Struct round-trip evaluation pipeline.

The process works as follows:

  1. Feed an input image ($x$) to a VLM.
  2. Collect the predicted structure ($y$), which is the generated code.
  3. Pass that code through a renderer (like a browser engine or a TeX compiler) to create a new rendered image ($\hat{x}$).
  4. Quantitatively compare the original image ($x$) to the rendered image ($\hat{x}$) using automated similarity metrics.

To make this visual comparison robust, the researchers introduce two new metrics alongside standard ones like SSIM and LPIPS:

  • Cosine Similarity between Inception vectors (CIS): Uses a deep neural network to compare high-level visual features.
  • Earth Mover Similarity (EMS): A novel adaptation of the Earth Mover’s Distance that compares image patches. This is highly effective because it doesn't penalize a model too harshly if it gets the content right but shifts it by a few pixels.

Datasets and Domains

The Image2Struct benchmark consists of 2,400 test instances across three distinct domains:

  • Webpages: 900 instances (HTML, CSS, and Javascript) sourced from GitHub Pages.
  • LaTeX: 1,200 instances covering equations, tables, algorithms, and plots sourced from recent arXiv papers.
  • Musical Scores: 300 instances of sheet music sourced from the IMSLP digital library.
Examples of input images, predicted structures, and rendered outputs for the LaTeX and Musical Scores domains.

Crucially, the authors scraped "fresh" data uploaded between January and February 2024. This "renewable stream" approach minimizes the risk of data leakage, ensuring models perform well due to actual capability rather than having memorized the test data during training.

Key Findings

The researchers evaluated 14 prominent VLMs, revealing several critical insights into the current state of structure extraction:

  • Overall Leader: GPT-4o emerged as the overall leader with a mean win rate of 0.923.
  • Domain Difficulty Gap: There is a massive disparity in how VLMs handle different structures. Models are relatively proficient at LaTeX equations (max EMS 0.830), likely due to the abundance of training data. However, they struggle significantly with musical scores. Even the best-performing model on sheet music (Gemini 1.0 Pro Vision) only achieved an EMS of 0.402, with many models failing to produce any renderable code at all.
  • Closed vs. Open: At the time of testing, closed-API models (GPT, Claude, Gemini) significantly outperformed open-weight models (like LLaVA or IDEFICS).
  • The "Aha" Moment: The study found that while models are great at extracting text and basic elements, they frequently fail at "visual nuances" like precise alignment, font sizes, and complex layout positioning.
  • Refusal Issues: Interestingly, some models (like GPT-4V) initially refused to generate code for sheet music, citing potential copyright concerns, even when the music was in the public domain. The authors had to tweak prompts to bypass these "false positive" refusals.

Limitations and Future Work

The authors acknowledge that their image similarity metrics, while vastly superior to string matching, are still imperfect. They do not always capture the "semantics" of a mistake—for example, a small typo in a math variable might be visually tiny but mathematically catastrophic.

Future directions for the benchmark include using a highly capable VLM as an evaluator to "critique" the similarity between images to better capture semantic errors, expanding beyond static screenshots to interactive or 3D structures, and testing model robustness against "noisy" inputs like blurry photos or skewed document scans.

Summary updated

BibTeX
@inproceedings{roberts2024image,
  author = {Josselin Somerville Roberts and Tony Lee and Chi Heem Wong and Michihiro Yasunaga and Yifan Mai and Percy Liang},
  title = {{Image2Struct: Benchmarking Structure Extraction for Vision-Language Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=8m6zw8Jur0},
}
Figure