Source-linked AI summary

Code as Representation: A Compilable Parsing Paradigm for Academic Documents

Rihui Jin, Jun Wang, chengyuan zhu, Liang Mingyu, Yue Gao, Li Yunxuan, Kuicai Dong, Guilin Qi, Lin Ren, Yongrui Chen, Xinbang Dai, Jiaqi Li, Tongtong Wu, Gholamreza Haffari

arXiv:2608.17550v1cs.CVcs.CL

TL;DR

Scientific knowledge in PDFs is difficult for MLLMs to represent faithfully when pages combine prose with structured academic elements. This paper introduces CADP and CADP-Bench for compilable LaTeX-plus-Python reconstruction, finding that high-fidelity executable reconstruction remains challenging even for current models.

  • Problem

    Existing document-parsing surrogates and benchmarks poorly preserve or evaluate page-level structure, data, and logic across tightly coupled academic elements.

  • Method

    CADP reconstructs full academic pages as contextual LaTeX plus executable Python, while CADP-Bench evaluates expert-verified multi-element pages through re-injection compilation.

  • Results

    Even with agentic scaffolding, current MLLMs struggle with high-fidelity executable reconstruction, while complex structural reasoning remains a pervasive bottleneck.

  • Takeaways & Limitations

    Compilable, structure-preserving representations improve downstream comprehension particularly for medium-tier models, while reconstruction remains an open challenge.

  • Takeaways & Limitations

    CADP is a page-level reconstruction task under limited compilation context rather than full source-code recovery.

Abstract

from arXiv · show

Academic papers are a primary carrier of scientific knowledge, yet most of this knowledge remains locked in PDFs that are optimized for human reading rather than machine use. For Multimodal Large Language Models (MLLMs), the core challenge is not only perception, but representation: scientific pages interleave text with Structured Academic Elements (SAEs) such as tables, formulas, charts, and pseudocode, whose structure, data, and logic are poorly preserved by common surrogates like Markdown. We therefore propose Compilable Academic Document Parsing (CADP), a paradigm that reconstructs a full page as contextual \LaTeX{} plus executable Python, so that structure-preserving elements and executable chart representations can be reconstructed, recompiled, and directly verified against the source page. To support this setting, we introduce CADP-Bench, an expert-verified benchmark of full academic pages containing tightly coupled text and multiple SAE types, evaluated through a re-injection compilation protocol. We further study current capabilities using SOTA MLLMs and an exploratory multi-agent baseline that incorporates common agentic techniques. Results show that even frontier models still struggle to produce high-fidelity executable reconstructions, highlighting substantial room for improvement in structure-aware scientific document parsing. CADP-Bench is released for future research.

1 Introduction

The paper frames academic document parsing as a representation problem: PDFs interleave prose with Structured Academic Elements whose structure and chart data are poorly preserved by common surrogates. It proposes CADP and CADP-Bench to reconstruct full pages as compilable dual code and evaluate executable fidelity, revealing substantial limitations in current models.

  • Motivation: Academic PDFs lock scientific knowledge into human-oriented pages where prose is tightly interleaved with tables, formulas, charts, and pseudocode.These heterogeneous elements are collectively termed Structured Academic Elements (SAEs).
  • Problem: Markdown surrogates obscure SAE topology, alignment, nesting, and chart data, making full-fidelity reconstruction fundamentally a representation problem.The missing information is not directly editable, executable, or verifiable as symbolic objects.
  • Method: CADP reconstructs raw full-page screenshots as contextual LATEX for text and SAEs plus executable Python for chart data and rendering logic.The dual-code formulation preserves nested structure and makes chart internals recoverable under limited compilation context.
  • Benchmark: CADP-Bench is an expert-verified benchmark for compilable academic parsing that evaluates multi-SAE pages through a re-injection compilation protocol.It addresses limitations of flat Markdown benchmarks and isolated element-level code generation without page context.
  • Results: Current SOTA MLLMs and an exploratory agentic baseline still struggle with high-fidelity executable reconstruction, leaving substantial room for improvement.The benchmark also supports evaluation of format-sensitive comprehension and exposes key reconstruction bottlenecks.

2 Related Work

Related work has advanced from text-centric document pipelines toward structured, executable representations for individual scientific elements. However, existing approaches and benchmarks remain limited in their treatment of non-textual structure, especially charts and complex tables.

  • Document Parsing Pipelines: Existing document parsing pipelines remain largely text-centric, often using flat Markdown while treating graphical regions as inert raster crops.Localized HTML or LATEX may represent complex elements, but the primary output still relies on flat Markdown.
  • Executable Element Reconstruction: Specialized models recover isolated formulas as compilable LATEX, hierarchical tables as verifiable code, and charts as programmatic Python scripts.These approaches represent individual document elements as structured, executable code rather than character-level transcripts.
  • Benchmark Limitations: Current document-parsing benchmarks emphasize flat text extraction, commonly using Markdown and linking charts or complex tables to cropped screenshots.This design treats information-dense scientific charts as opaque pixels rather than evaluating recovery of their underlying data arrays or rendering logic.

3 The CADP-Bench Benchmark

CADP-Bench frames academic-page parsing as limited-context reconstruction into contextual LATEX and executable Python, targeting pages with multiple coupled structured elements. It evaluates these reconstructions through re-injection compilation, code-level metrics, and visual fidelity assessment.

  • 3.1 Task Formulation: The task maps a page image and package context to contextual LATEX plus executable Python for reconstructing text, structured elements, and charts.The model receives only I_p and Cpkg; the original source context is withheld during generation.
  • 3.2 Dataset Construction: CADP-Bench selects arXiv pages containing at least two distinct SAE categories and extracts aligned ground-truth LATEX for the included elements.PDFs and corresponding LATEX sources are collected across disciplines, with Mineru identifying page-level elements and their layouts.
  • 3.3 Chart Annotation: Charts are converted into verified executable annotations by cropping each chart, generating Python with Gemini-3-Pro, rendering SVG, and replacing the original image after expert review.The verified code is treated as ground truth and preserves consistency between visual representation and executable logic.
  • 3.4 Evaluation Protocol: Re-injection Compilation executes generated chart programs, reinserts LATEX into the excised source context, and recompiles the document to test structural, visual, and executable consistency.Compilation or severe visual failures expose issues such as hallucinated macros, unclosed environments, and incorrect Python data logic.
  • 3.5 Metrics: Evaluation combines code-level correctness with visual fidelity because code representations are non-unique, assigning score 0 to any sample that fails re-injection compilation.The benchmark includes Pseudocode Reconstruction Score for textual and control-flow fidelity and Visual Reconstruction Fidelity for holistic page quality.

4 Experiments & Analysis

Experiments evaluate leading MLLMs and an exploratory multi-agent baseline on CADP-Bench using averaged repeated runs and consistent PDFLaTeX compilation. Results show persistent weaknesses in high-fidelity structural reconstruction, with difficulty, agentic scaffolding, and input representation producing differentiated effects.

  • Experimental Setup: The study evaluates SOTA MLLMs and an exploratory multi-agent system combining task decomposition, role specialization, shared tools, and iterative feedback.The four-agent system includes a Planner, LATEX Coder, Python Coder, and Reviewer.
  • Experimental Setup: Models are evaluated three times with averaged metrics, officially provided APIs, temperature 0.7, and pdfLaTeX compilation for consistent rendering.These settings reduce variability and support consistent rendering of complex structures and non-standard fonts.
  • End-to-End Performance: Complex structural reasoning remains a pervasive bottleneck: Gemini-3-Pro leads overall, while runnable plotting code is easier than faithfully reproducing figures and strict VRF-S exposes weak table parsing.The results indicate that partial structural recovery is insufficient because only perfect reconstruction counts.
  • Complexity & Robustness: Increasing element difficulty degrades all four element types, with chart and pseudocode reconstruction remaining the dominant bottlenecks and higher-tier models retaining greater formula and table robustness.The tier gap widens particularly for difficult tables and charts, while weaker models decline more sharply on hard cases.
  • Complexity & Robustness: A challenging Gemini-3-Pro case scores VRF-A Layout 75.00, Table 58.33, Chart 43.75 and Pseudocode 100, alongside color, text, sizing, and layout errors.Chart parsing is described as especially problematic, with severe errors throughout.
  • Impact of Agent Techniques: The Full MA System improves performance by roughly 3 to 7 points over the static Base model, but removing Visual Feedback raises Formula from 74.20 to 75.30.Removing Multi-Agent collaboration also marginally improves Pseudocode reproduction, 62.50 vs. 61.80.
  • Format-Sensitive Comprehension: Representation effects depend on model capability: smaller Qwen3.5-35B-A3B gains little from LATEX+Python, whereas Qwen3.5-Plus benefits substantially and surpasses Gemini-3-Pro with Markdown.The QA benchmark contains 90 manually annotated questions evaluated with screenshots, Markdown, and structured LATEX+Python representations.

5 Discussion

The Discussion presents Dual-Code as a practical representation that preserves page-level structure and executable semantics for scientific document understanding. It also highlights compatibility with reinforcement learning and Graph-RAG through compilation-based rewards and explicit structural relations.

  • Practical Value: Dual-Code preserves page-level structure and executable semantics, offering a stronger foundation than plain-text formats for full-page reconstruction and reasoning.The representation extends beyond benchmark performance toward downstream scientific document understanding.
  • Potential for Reinforcement Learning in Compilable Document Parsing: CADP supports reinforcement learning because generated code can be compiled and executed, rendered outputs compared with reference pages, and reconstruction metrics used as reward signals.The large-scale LATEX ecosystem, including arXiv, offers a setting for pretraining and post-training robust scientific document parsing.
  • Enabling Graph-Based Retrieval-Augmented Reasoning: Preserving LATEX cross-references, citations, table hierarchies, and section organization in Dual-Code can alleviate structure breaking in chunk-based RAG and improve intra-document and cross-document QA.These explicit structural signals encode relations across text and Structured Academic Elements such as tables and charts.

6 Conclusion

The paper presents CADP and CADP-Bench for reconstructing academic pages as contextual LaTeX plus executable Python and evaluating them through re-injection compilation. Experiments show that high-fidelity executable reconstruction remains challenging, while structured LaTeX+Python can improve downstream comprehension, particularly for medium-tier models.

  • Contributions: CADP reconstructs academic pages as contextual LaTeX and executable Python, paired with CADP-Bench, an expert-verified benchmark evaluated via re-injection compilation.The paradigm and benchmark are presented together as the paper’s main contributions.
  • Findings: High-fidelity executable reconstruction remains challenging for SOTA MLLMs and an exploratory multi-agent baseline.This conclusion follows from the reported experiments across both model settings.
  • Findings: Structured LaTeX+Python improves downstream comprehension, particularly for medium-tier models.The result highlights the potential of compilable, structure-preserving representations.

A Prompts · Prompt for Compilable Academic Document Parsing

The prompt requires converting a single-page academic-paper screenshot into a fixed sequence of runnable Python, package, and LaTeX outputs. It separates chart reproduction into Python and all other page content into structure-preserving LaTeX, with compilation-oriented file and package requirements.

  • Prompt for Compilable Academic Document Parsing: The input is a screenshot of a single-page academic paper to be converted according to specified requirements.The prompt frames the task as converting one screenshot into compilable representations.
  • Prompt for Compilable Academic Document Parsing: The response must contain three code blocks in fixed order: Python, package, then LaTeX.The package block may be empty when no additional packages are needed.
  • Prompt for Compilable Academic Document Parsing: If no charts appear, the Python block must contain only the comment # No charts detected.This provides an explicit no-chart fallback for the executable output.
  • Prompt for Compilable Academic Document Parsing: The package block must determine whether additional packages are needed beyond those already included in the external template, which is compiled with pdflatex.The template exposes its included packages through the USEPACKAGE_BLOCK placeholder.
  • Prompt for Compilable Academic Document Parsing: When charts exist, every figure and subfigure must be converted into Python reproduction code using savefig.Figures should be saved as fig1.pdf, fig2.pdf, and so on in top-to-bottom, left-to-right order; unspecified data or parameters may be reasonably approximated.
  • Prompt for Compilable Academic Document Parsing: All non-figure content must be converted into LaTeX while preserving structure, hierarchy, layout, mathematics, algorithms, and tables as much as possible.The LaTeX must also include image-insertion code with exact paths and filenames.

Prompt for Table Restoration Evaluation

The table-restoration evaluation compares predicted renderings with a ground-truth table image using structural, content, formatting, and advanced-style criteria. It requires integer rubric scores with objective justifications for each dimension.

  • Inputs and objective: The evaluator receives one ground-truth image and one or more predicted images or parsing-result renderings for the same sample.The comparison assesses restoration fidelity between the original table and predicted outputs.
  • Inputs and objective: Evaluation covers table topology and structure, cell-content accuracy, formatting and alignment, and advanced visual styling.These dimensions collectively assess both structural fidelity and visual appearance.
  • Inputs and objective: Large tables split across predicted pages must preserve all content and handle page breaks logically.The evaluator checks whether splitting introduces omissions or other logical errors.
  • Scoring dimensions: Table structure evaluates row and column organization, merged or split cells, and header hierarchy.The rubric ranges from exact structural restoration to errors involving misalignment, shifting, or incorrect header merges.
  • Scoring dimensions: Table content evaluates text, numbers, symbols, and empty-cell preservation, including errors such as altered numbers, missing words, or incorrect punctuation.The highest rubric level requires 100% accurate cell content with no missing, extra, or incorrect characters.
  • Scoring dimensions: Format and alignment assess alignment, line breaks, font hierarchy, emphasis styles, proportions, colors, borders, separators, and special symbols.Advanced styling includes fills, text colors, border weights, line styles, bullets, arrows, brackets, superscripts, and subscripts.

Prompt for Chart Restoration Evaluation

The chart-restoration evaluation prompt assesses consistency between ground-truth and predicted charts across data expression, text, visual style, and local layout. Each dimension receives an objective score from 0 to 4 with concise reasoning, returned in a fixed JSON structure.

  • Evaluation dimensions: Evaluation covers four dimensions: data expression and morphology, text and labels, color and visual style, and local layout and proportions.The evaluator focuses on data transmission, information completeness, visual encoding, and spatial composition.
  • Data expression and morphology: Data expression and morphology is the core metric, measuring agreement in trends, point distributions, extrema, clustering, and overall chart shape.A top score indicates deviations are difficult to discern visually, while a score of 3 permits extremely slight local deviations.
  • Text and labels: Text and labels evaluates the completeness and accuracy of titles, subtitles, legends, axes, tick values, and data labels, including spelling, casing, and position.Minor non-critical shifts or occasional errors can still correspond to a score of 3.
  • Visual style and layout: Color and visual style evaluates colors, opacity, line and point types, shadows, and fill patterns, while local layout evaluates proportions and spatial relationships.Layout criteria include plot aspect ratio, legend position, axis margins, grid density, and internal element relationships.

Prompt for Document Layout Restoration Evaluation

The evaluation prompt assesses whether predicted rendered pages faithfully restore a ground-truth page’s macro layout, alignment logic, and spacing proportions. It uses 0–4 scores with objective justifications while ignoring OCR, minor formula-content, and chart-data errors.

  • Inputs and constraints: The evaluator compares a ground-truth raw page image with one or more rendered predicted images from the same test sample.Predictions may span multiple pages because of font scaling or rendering differences, so element placement and cross-page flow must be considered.
  • Inputs and constraints: The prompt restricts evaluation to layout reconstruction fidelity, excluding OCR errors, minor formula deviations, and chart-data correctness.The focus is visual structure rather than semantic content accuracy.
  • Scoring criteria: macro_distribution evaluates column structure, module positions, and reading-flow continuity, including cross-page logic.A top score requires exact reproduction of single- or double-column structure and module positions; lower scores reflect drift, displacement, or page changes.
  • Scoring criteria: alignment_logic evaluates edges, baselines, indentation, and centering across text, formulas, lists, and charts.The rubric distinguishes perfect alignment from minor issues, multiple failures, and large-scale misalignment.
  • Scoring criteria: spacing_proportion evaluates whitespace and relative visual scale, including margins, line and paragraph spacing, font hierarchy, and chart scaling.The highest score requires close matching to the ground truth, while lower scores indicate imbalance or unreasonable blank space and scaling.

Prompt for Pseudocode Restoration Evaluation

The prompt defines an expert evaluation of predicted versus ground-truth pseudocode renders, scoring visual and structural consistency across three dimensions on a 0–4 scale. It assesses structure, mathematical and textual transcription, and styling and formatting fidelity.

  • Evaluation Task: An expert evaluator compares predicted and ground-truth algorithm renders for visual and structural consistency.The task explicitly targets pseudocode layout parsing and visual restoration evaluation.
  • Evaluation Criteria: Each of three dimensions receives an objective score from 0 to 4 with concise reasons.The dimensions are structure and indentation fidelity, math and content transcription, and style and formatting.
  • Structure and Indentation Fidelity: Structure and indentation fidelity examines code-line counts, line numbers, nested indentation, and code-block borders or guidelines.Higher scores require faithful control-flow hierarchy and complete line-number and separator restoration, while lower scores reflect flattening or chaotic structure.
  • Math Symbols and Content Transcription: Math and content transcription evaluates variable names, formulas, Greek letters, superscripts, subscripts, and logical or assignment operators.Scoring ranges from precise recognition without omissions to large-scale symbol or text failure that obscures the core formula.
  • Style and Formatting: Style and formatting evaluates keyword emphasis, math-versus-text font environments, comment symbols, and comment alignment.High fidelity preserves bold and italic distinctions and end-of-line comment alignment, whereas lower scores reflect neglected styling details.
Loading 2608.17550v1…