I co-authored SPIRE with Mike Rainey and Umut Acar. The paper asks a practical retrieval question: how can a system return a small piece of evidence without removing the document structure that explains it? Our approach preserves source locations while controlling how much context accompanies each result.
The problem
HTML distributes meaning across headings, lists, tables, and nearby text. A relevant table cell may need its row label; a sentence may need the section heading or the previous sentence to make sense. Flattening a page into fixed-size chunks forces retrieval and presentation to use the same boundaries.
Small chunks can match a query precisely but omit essential context. Larger chunks preserve more context while spending the available token budget on unrelated material. SPIRE separates those decisions: match fine-grained evidence, retain its structural address, then construct the view needed to interpret it.
Architecture and retrieval pipeline
The core representation is an HTML tree whose nodes are addressed by paths of child indices. A retrieval candidate is a source document plus a set of selected paths. This lets several non-contiguous regions remain one addressable object. Contextualization and pruning turn that selection into a well-formed excerpt when text is needed by a model or reader.
The pipeline combines four operations:
- Index sentence seeds. NLTK sentence segmentation supplies fine-grained units while boundaries remain represented in the document tree. Each seed receives global structural context before its rendered view is embedded.
- Retrieve and aggregate. Similarity search ranks candidates. Hits from the same document are combined by merging their path sets, so shared headings and titles are included once when calculating the rendered token cost.
- Expand locally. Nearby complete sentences and structural containers provide context for interpreting a candidate. This expansion changes its view while preserving the original selection's identity.
- Select evidence. A generative filter examines labeled units and returns their identifiers. Those identifiers map back to source paths, keeping the final citations connected to the document.
Global context supplies structural information such as titles, active headings, and table labels. Local context supplies neighboring content. Sections 2 and 3 formalize these separate operations and their composition.
Engineering decisions
Keeping source identity separate from rendered text is central to the design. The system can merge or expand an excerpt without recovering its location through string matching afterward. The generative model selects labels rather than reproducing citation text, making provenance a property of the representation.
Document-aware aggregation also makes the token budget more useful. Two hits from one section should not pay twice for the same heading. The retrieval stage measures the combined, contextualized view and can admit more ranked candidates when deduplication frees space. Global context comes from document structure; the generative stage is reserved for query-conditioned evidence selection.
Evaluation and results
The paper uses HtmlRAG's released HotpotQA and ASQA evaluation suites: 400 sampled queries per benchmark, each accompanied by HTML pages gathered through Bing search. The BGE baseline and SPIRE's sentence retriever both use BGE-Large-EN. This controls the embedding model while comparing how the retrieval algorithms handle HTML.
The evaluation applies a 1,000-token rendered-citation budget per query. Qwen3 235B Instruct judges each query–citation pair as helpful or unhelpful; the paper reports manual inspection of a random sample of judgments. Qwen3 32B performs the full pipeline's contextual filtering. These models have different roles.
The following values reproduce Table 1. Counts are aggregated across each benchmark; parentheses contain the helpful-citation ratio.
| System | HotpotQA: helpful / total | ASQA: helpful / total |
|---|---|---|
| BGE block baseline | 336 / 1,514 (0.222) | 998 / 1,658 (0.602) |
| Sentence retrieval | 479 / 2,225 (0.215) | 1,236 / 2,010 (0.615) |
| Sentence retrieval without global context | 836 / 6,077 (0.138) | 767 / 1,872 (0.410) |
| SPIRE with contextual filtering | 538 / 822 (0.655) | 1,673 / 2,058 (0.813) |
Sentence retrieval fits more citations into the same budget while maintaining comparable helpfulness ratios. Filtering increases the ratios to 0.655 and 0.813. These measure judged citation usefulness, rather than final-answer accuracy. Different citation granularities also affect the counts, so a larger count alone does not establish better evidence.
Limitations and next steps
The evidence covers two HTML QA suites and an LLM judging protocol. It does not establish performance for every document type or language. Local expansion and generative filtering introduce additional work; the reported citation results do not quantify a production latency or cost advantage.
Document paths provide a useful abstraction, but deep trees require attention to representation overhead. Extending contextualization to definitions, cross-references, and figure captions is a further engineering direction. The transferable idea is to preserve evidence identity first, then make contextualization an explicit policy.