Papers
Topics
Authors
Recent
Search
2000 character limit reached

Grounded XPath Resolution (GXR)

Updated 9 February 2026
  • The paper introduces GXR as a post-processing method that guarantees all fields extracted by neural models are accurately traced to their corresponding DOM nodes.
  • The algorithm computes a composite score based on token overlap and fuzzy similarity to match extracted strings with their exact DOM locations.
  • Empirical results demonstrate that GXR enhances traceability, significantly improving page-level F1 scores and reducing extraction errors.

Grounded XPath Resolution (GXR) is a formal post-processing mechanism developed to guarantee that every field extracted from HTML by a LLM or neural extractor is physically traceable to a unique node in the original DOM tree. By providing both the resolved value and its absolute XPath coordinate, GXR ensures 100% traceability and verifiability, correcting common failure modes where neural models hallucinate plausible outputs that do not actually appear on the page. GXR is a core component of the AXE pipeline for low-cost, cross-domain web structured information extraction, operating after model generation to attach each output to its precise DOM origin (Mansour et al., 2 Feb 2026).

1. Motivation and Conceptual Problem

Extracting structured data from heterogeneous, template-varying web pages presents the issue of "hallucinated" outputs, wherein model-generated strings may look plausible but are not present in the source HTML. This undermines downstream schema integrity, traceability, and auditability. GXR addresses this by enforcing that each extracted field in the output (e.g., in JSON or database records) is grounded—namely, matched precisely back to a node in the original DOM. Grounding is defined as the process of identifying, for each predicted string, the single DOM node whose text content most closely matches the prediction. The final output includes both the predicted value and the absolute XPath identifying its exact structural location in the document. This mechanism allows for field-level auditing and prevents non-verifiable "floating" answers (Mansour et al., 2 Feb 2026).

2. Formal Definitions

Let the DOM be modeled as a rooted, ordered tree

T=(V,E,r),T = (V, E, r),

where VV is the finite set of nodes, EV×VE \subseteq V\times V are parent-child edges, and rVr\in V is the root.

  • Text labels: Each node vVv\in V carries a label Text(v)\mathrm{Text}(v), which concatenates its visible text and that of all its descendants.
  • XPath expressions: Let X\mathcal{X} be the set of all absolute XPaths; each xXx\in\mathcal{X} is a path from rr to some vVv\in V. There is a mapping g:XVg: \mathcal{X} \to V that evaluates xx and returns the unique target node (or undefined).
  • Grounding predicate: For an LLM prediction ss (a string), a scoring function σ(v,s)\sigma(v,s) is computed for every vVv\in V; the best match is

v=argmaxvVσ(v,s).v^* = \arg\max_{v\in V} \sigma(v,s).

The field ss is grounded if σ(v,s)τ\sigma(v^*, s) \ge \tau for some fixed threshold τ[0,1]\tau\in[0,1], that is,

Ground(s)=true    vV:σ(v,s)τ.\mathrm{Ground}(s) = \text{true} \iff \exists v\in V: \sigma(v,s) \ge \tau.

The final grounded output for each field is the tuple (s,x)(s, x^*) where x=XPath(v)x^* = \mathrm{XPath}(v^*).

3. GXR Algorithmic Workflow

GXR operates as a deterministic, post-hoc procedure over the full, unpruned DOM. The full pipeline is as follows:

  1. Inputs
    • The complete DOM T=(V,E,r)T=(V,E,r), with no pruning to preserve all potential candidates.
    • The set of extracted strings {s1,,sm}\{s_1,\dots,s_m\} predicted by the LLM.
    • A matching threshold τ\tau.
  2. Processing
    • Parse all text-bearing nodes VtextVV_\mathrm{text}\subset V.
    • For each sis_i, score each vVtextv\in V_\mathrm{text} as follows:
      • α=LexOverlap(si,Text(v))\alpha = \mathrm{LexOverlap}(s_i, \mathrm{Text}(v))
      • β=FuzzySim(si,Text(v))\beta = \mathrm{FuzzySim}(s_i, \mathrm{Text}(v))
      • score=λα+(1λ)β\mathrm{score} = \lambda\cdot \alpha + (1-\lambda)\cdot \beta
    • Select the vv with maximum score; if scoreτ\mathrm{score}\ge \tau, return (si,XPath(v),score)(s_i, \mathrm{XPath}(v), \mathrm{score}). Otherwise, flag as "ungrounded."
  3. Outputs
    • For each prediction: (s^i,xi,σi)(\widehat{s}_i, x_i, \sigma_i), or "ungrounded."

Notably, GXR does not prune the DOM—structural reductions are applied in earlier stages (specifically, by AXE’s pruner), but GXR itself performs the grounding step on the unaltered tree (Mansour et al., 2 Feb 2026).

4. Scoring Functions and Constraints

The core of GXR's matching is its composite scoring function:

σ(v,s)=λTokens(s)Tokens(Text(v))Tokens(s)+(1λ)FuzzySim(s,Text(v))\sigma(v,s) = \lambda\,\frac{|\mathrm{Tokens}(s)\cap \mathrm{Tokens}(\mathrm{Text}(v))|}{|\mathrm{Tokens}(s)|} + (1-\lambda)\,\mathrm{FuzzySim}(s, \mathrm{Text}(v))

where:

  • λ[0,1]\lambda\in[0,1] weights token-level lexical overlap vs. character-level fuzzy similarity (e.g., Ratcliff–Obershelp or Levenshtein).
  • Only nodes with σ(v,s)τ\sigma(v,s)\ge\tau are considered grounded.

A grounding constraint ensures that only predictions with a sufficiently strong match in the DOM are output as structured fields:

Ground(s)    maxvVσ(v,s)τ.\mathrm{Ground}(s) \iff \max_{v\in V} \sigma(v,s) \ge \tau.

Minimal pruning (outside GXR, but relevant for context) finds the smallest node subset PVP\subset V so that for all queries, the answer labels are retained in the text of nodes in PP—but for GXR, the entire VV is preserved as candidate space.

5. Implementation and Example

Data Structures and Efficiency

  • Text nodes VtextV_\mathrm{text} are indexed in a flat array, with each storing the DOM node pointer, normalized text, and precomputed token set.
  • Per-prediction runtime is O(Vtext×L)O(|V_\mathrm{text}| \times L), LL being average string length. Typically, Vtext|V_\mathrm{text}| is on the order of hundreds. Fuzzy comparisons leverage optimized native libraries (e.g., Python’s SequenceMatcher).

Illustrative Example

Given the DOM fragment:

1
2
3
4
5
<div id="prod">
  <span class="title">UltraWidget 3000</span>
  <p class="price">$42.99</p>
  <p>Free shipping</p>
</div>
Suppose the LLM predicts s1=s_1= "UltraWidget 3000" and s2=s_2= "$42.99". The text nodes are$v_1:"UltraWidget3000","UltraWidget 3000",v_2:""42.99", and v3:v_3: "Free shipping". For each sis_i:

  • GXR finds v1v_1 and v2v_2 as the respective best matches, both with exact string and fuzzy similarity, so outputs:
    • ("UltraWidget 3000", "/div[1]/span[1]", 1.0)(\text{"UltraWidget 3000"},\ \text{"/div[1]/span[1]"},\ 1.0)
    • $(\text{"\$42.99"},\ \text{"/div[1]/p[1]"},\ 1.0)$</li> </ul></li> </ul> <p>No match is assigned to &quot;Free shipping&quot; as that was not an extracted field.</p> <h2 class='paper-heading' id='empirical-performance-and-impact'>6. Empirical Performance and Impact</h2> <p>Ablation results on the SWDE dataset underscore GXR&#39;s importance in practical systems. Removing GXR from the AXE pipeline leads to a 4.42-point drop in page-level F1 (from 88.37% to 83.95%), constituting the single largest drop after earlier pruning. This empirically demonstrates that simple text-only generation, without field grounding, results in plausible outputs that cannot guarantee structural correctness.</p> <p>Internal evaluation on traceability metrics reports:</p> <ul> <li><strong>Grounding precision</strong> (node is correct when field appears): $\geq$98%
    • Recall (fraction of predictions finding valid node with $\sigma\ge\tau):): \approx$96%
    • Overall traceability accuracy (precision and recall): $\approx$97%

    This indicates that GXR reliably maps nearly all model extractions to their genuine DOM origins and appropriately flags missing or mismatched fields (Mansour et al., 2 Feb 2026).

    7. Significance for Cross-Domain Information Extraction

    Grounded XPath Resolution transforms the field extraction task from one of unconstrained generation to verifiable retrieval, aligning model outputs directly with document structure. By enforcing that every output field is paired with an exact DOM coordinate, GXR creates audit trails for structured extraction and establishes domain-agnostic guarantees vital for large-scale, cross-domain web mining. Its lightweight, efficient scoring over the unpruned DOM, robust to minor string variations, is positioned as essential for high-precision, cost-efficient structured data acquisition from the web (Mansour et al., 2 Feb 2026).

    Definition Search Book Streamline Icon: https://streamlinehq.com
    References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Grounded XPath Resolution (GXR).