Abstract: Semi-structured content in HTML tables, lists, and infoboxes accounts for a substantial share of factual data on the web, yet the formatting complicates usage, and reliably extracting structured information from them remains challenging. Existing methods either lack generalization or are resource-intensive due to per-page LLM inference. In this paper, we introduce SCRIBES (SCRIpt-Based Semi-Structured Content Extraction at Web-Scale), a novel reinforcement learning framework that leverages layout similarity across webpages within the same site as a reward signal. Instead of processing each page individually, SCRIBES generates reusable extraction scripts that can be applied to groups of structurally similar webpages. Our approach further improves by iteratively training on synthetic annotations from in-the-wild CommonCrawl data. Experiments show that our approach outperforms strong baselines by over 13% in script quality and boosts downstream question answering accuracy by more than 4% for GPT-4o, enabling scalable and resource-efficient web information extraction.
The Challenge of Web-Scale Data Extraction
A massive portion of the web’s factual data is trapped in semi-structured formats like HTML tables, lists, and infoboxes. Traditionally, researchers used "wrapper induction"—hand-crafted or automatically learned rules—to extract this data. However, these wrappers are notoriously brittle, often breaking the moment a site’s layout shifts.
Recently, Large Language Models (LLMs) have shown incredible talent at parsing HTML directly. The catch? Running an LLM on every single page of a massive website is prohibitively expensive and slow. The authors identify a middle ground: can we use the reasoning capabilities of an LLM to write a "tool" (a script) that handles the heavy lifting? The challenge is that LLMs often struggle to write scripts that generalize across different pages of the same site, frequently hard-coding values or failing to account for minor layout variations.
Introducing SCRIBES
To bridge the gap between LLM reasoning and programmatic efficiency, the authors propose SCRIBES, a novel Reinforcement Learning (RL) approach.
SCRIBES operates through several key mechanisms:
- Script Generation: Instead of outputting data triples directly, the model generates a Python script (using
BeautifulSoup) designed to extract triples from any page within a specific domain group. - HTML Deduplication (Dedup): To fit massive HTML files into context windows, SCRIBES collapses repeated structural blocks (e.g., long lists of similar items) into a compact representation, reducing token counts by over 85%.
- RL with Cross-Page Rewards: Using Group Relative Policy Optimization (GRPO), the model is rewarded based on two signals:
- Self-score: How well the script works on the input page.
- Cross-score: How well the script works on other pages from the same website. This "cross-page" signal is the secret sauce; it forces the model to learn generalizable structural patterns rather than memorizing a single page.
- Iterative "In-the-Wild" Training: The authors developed a pipeline to sample unlabeled data from CommonCrawl. They use a "failure-case" strategy, specifically training the model on pages where its current scripts fail, using direct LLM extractions as synthetic "silver" labels.
Datasets Used
- SemiBench: A high-quality annotated dataset of 268 webpages across 56 groups. This served as the primary benchmark for "gold" human annotations.
- CommonCrawl (CC): The authors processed a massive sample of the web, identifying nearly 20,000 groups of structurally similar pages. From this, they derived 1,898 training examples for their iterative RL phase.
- Downstream QA: A set of 416 question-answering pairs associated with the test webpages to evaluate how extracted data helps real-world tasks.
Key Insights and Results
Layout as a Reward Signal
The most elegant idea in the paper is using the inherent consistency of web design as a training signal. If a script works on Page A but fails on Page B (from the same site), the model receives a lower reward, learning that it hasn't truly understood the site's underlying "template."
Massive Computational Efficiency
The authors quantify the speedup as $k / \rho$, where $k$ is the number of similar pages and $\rho$ is the token ratio between a full script-generation prompt and a simple extraction prompt. As $k$ grows, the cost per page approaches the negligible cost of executing a Python script.
For a group of 100 pages, SCRIBES provides a computational saving of roughly $1.12 \times 10^{21}$ FLOPs compared to per-page LLM inference. It becomes more efficient than direct extraction as soon as a site has more than 4 similar pages.
Performance Gains
- Superior Script Quality: SCRIBES-trained models (based on Qwen2.5) outperformed strong agentic baselines by over 13% in $F_1$ score for script generation.
- Downstream Impact: Using SCRIBES-extracted triples boosted the QA accuracy of state-of-the-art models like GPT-4o by over 4% compared to using raw flattened HTML.
- Cross-Domain Transfer: A model trained on one set of domains (e.g., finance) still significantly outperformed baselines when tested on entirely different domains (e.g., encyclopedia pages), showing it learned the concept of extraction rather than just specific site layouts.
Limitations and Future Work
While highly effective, SCRIBES has a few limitations. Error analysis shows that performance declines as webpages become more structurally complex (e.g., deeply nested tables or multi-column layouts). Furthermore, the model performs best on horizontal tables and attribute-value pairs but struggles more with "free-form" semi-structured data.
Looking forward, the authors suggest that SCRIBES could be used to "clean" massive pretraining corpora (like FineWeb or C4), which currently filter out semi-structured data because it's too messy for standard language modeling. By converting this data into clean triples at scale, we could significantly improve the factual knowledge of future LLMs.
Summary updated