Manuscript Offprint

arXiv:2608.12129

SAG: SQL-Retrieval Augmented Generation with Query-Time Dynamic Hyperedges

Yuchao Wu, Junqin Li, XingCheng Liang, Yongjie Chen, Yinghao Liang, Linyuan Mo, Guanxian Li

ABSTRACT

While retrieval-augmented generation (RAG) has proven effective at giving LLMs access to external knowledge, mainstream dense-retrieval implementations remain inherently limited in handling structured constraints and multi-hop reasoning. Graph-based methods address this by constructing knowledge graphs offline, but they often fragment semantics, incur high maintenance, and complicate incremental updates. We propose SAG (SQL-Retrieval Augmented Generation), a structured retrieval architecture that organizes documents into an event-entity index without building a global knowledge graph. SAG represents each chunk as a semantically complete event paired with its entities, forming a latent hyperedge that preserves n-ary relations without decomposing them into triples. At query time, SAG treats shared entities as join keys to connect related chunks. This dynamically yields a query-scoped neighborhood of events, and yet every piece of evidence remains the original chunk throughout. Experiments on HotpotQA, 2WikiMultiHopQA, and MuSiQue show that SAG achieves the best retrieval and end-to-end QA performance on every benchmark, with gains that widen as reasoning-chain complexity increases. On MuSiQue, where multi-hop evidence chaining is most demanding, SAG reaches 80.36% Recall@5, outperforming the strongest baseline by 11.52 points. This work paves the way for knowledge infrastructure that enables LLM agents to retrieve and reason over continually growing organizational knowledge. 1^{1}

1 INTRODUCTION

What an agent can do is bounded by what it can retrieve. Organizational knowledge is distributed across documents, messages, customer systems, and code; much of it is unstructured, relational, and continuously accumulating. Making this knowledge available to agents is therefore an infrastructure problem as well as a modeling problem. Multi-hop question answering makes this gap concrete. Answers often require evidence from multiple documents, whereas conventional RAG pipelines (Lewis et al., 2020; Karpukhin et al., 2020) rank passages independently by their similarity to the query. This approach works well when a single passage contains the answer, but it does not explicitly represent associations across passages. In multi-hop retrieval, failing to recover one intermediate passage can break the entire evidence chain (Yang et al., 2018; Trivedi et al., 2022; Mavi et al., 2024). The challenge is therefore not only to improve single-shot recall, but also to organize evidence so that cross-document associations can be recovered reliably.

Structure-augmented methods address this problem by constructing knowledge graphs or hierarchical representations offline (Edge et al., 2024; Gutiérrez et al., 2025). When n-ary events are decomposed into independently indexed triples, however, their shared event boundary may be lost. Hypergraph-based methods (Luo et al., 2025) preserve higher-order relations but still encode them in a persistent corpus-level structure. These structures support graph traversal and ranking, but the connections available during retrieval are determined before the query arrives, while ingestion and maintenance remain separate from query execution. This raises a different question: can the structure needed

∗^{*}Correspondence to: jomy@zleap.com.

1^{1}Benchmark and evaluation code: https://github.com/Zleap-AI/SAG-Benchmark by a query be activated from an append-only index during retrieval, without constructing a global knowledge graph?

Our central claim is that multi-hop retrieval need not rely exclusively on either dense similarity or a globally constructed graph (Figure 1). The required associative structure is latent in the events described by passages and the entities shared across them. SAG exposes this structure through an event-entity index. Each chunk is independently represented as one semantically complete event linked to a set of indexing entities. Because an event binds all its entities within one retrieval unit, it defines a latent hyperedge that retains the event's n-ary relation rather than decomposing it into independent triples. At query time, SQL joins over shared entities activate a local neighborhood of related events. This structural path is combined with dense retrieval, after which an LLM selects evidence from the compressed candidate set. SAG constructs no global corpus graph, and selected events are mapped back to their original chunks before answer generation. Under unified evaluation settings, SAG achieves the best retrieval and end-to-end QA performance on HotpotQA, 2WikiMultiHopQA, and MuSiQue. Its largest retrieval gain occurs on MuSiQue, where SAG reaches 80.36% Recall@5 and exceeds the strongest baseline by 11.52 points.

To summarize, our contributions are fourfold. (1) We introduce SAG, a retrieval architecture that activates query-specific latent hyperedges over an event-entity index through SQL joins, without constructing a global knowledge graph. (2) We formalize the event-entity representation, characterize the neighborhoods recovered through incidence joins, and compare its corpus-level connectivity with four structure-augmented baselines. (3) We evaluate SAG on three multi-hop benchmarks under a unified configuration and isolate the effects of representation, expansion, final selection, and candidate budget. (4) We evaluate robustness to embedding replacement and continual corpus growth, and show how bounded candidate activation limits the downstream SQL and LLM workloads. Beyond the benchmark study, we provide an engineering implementation inspired by SAG's core mechanisms. 2^{2} Together, these properties make SAG a step toward knowledge infrastructure for agents operating over continually growing corpora.

NaiveRAG

Figure

Limitations: Reliant on similarity, Shallow retrieval

GraphRAG

Figure

Limitations: Slow, High cost, Difficult incremental updates

SAG

Figure

Figure 1: Three RAG paradigms. NaiveRAG retrieves top-k chunks by dense similarity, while GraphRAG organizes evidence in an offline knowledge graph. SAG stores event-entity relations in an append-only index and activates query-specific latent hyperedges through SQL joins.

2^{2}Engineering project: https://github.com/Zleap-AI/SAG

2 RELATED WORK

Retrieval-Augmented Generation. RAG combines a parametric generator with a dense passage index to incorporate external knowledge (Lewis et al., 2020). Later work adapts when and how retrieval is performed. Self-RAG uses reflection tokens to decide when to retrieve and to evaluate retrieved evidence (Asai et al., 2024), while FLARE retrieves from predicted upcoming sentences when generation contains low-confidence tokens (Jiang et al., 2023b). Adaptive-RAG routes queries among no-retrieval, single-step, and iterative strategies according to predicted complexity (Jeong et al., 2024). IRCoT instead alternates retrieval with chain-of-thought generation, using each reasoning step to guide the next retrieval (Trivedi et al., 2023). These methods modify retrieval control or query formulation, whereas SAG changes how corpus knowledge is represented and connected.

Structure-Augmented Retrieval. GraphRAG constructs an entity graph and community summaries for answering global corpus-level questions (Edge et al., 2024). HippoRAG builds a knowledge graph from extracted relations and propagates relevance with personalized PageRank, while HippoRAG 2 integrates passages more directly and strengthens the online use of an LLM (Gutiérrez et al., 2024; 2025). LightRAG combines incremental graph updates with low- and high-level retrieval over entities and relations (Guo et al., 2025). SiReRAG constructs similarity and relatedness trees and flattens their nodes into a unified retrieval pool (Zhang et al., 2025), whereas StructRAG selects and constructs a task-appropriate structure at inference time (Li et al., 2025). These methods either maintain corpus-level structures or reconstruct structured views for individual queries. SAG instead stores event-entity incidence records and activates query-specific associations through SQL joins without materializing a global graph. ChatDB and StructGPT query existing databases or structured sources, but do not organize unstructured corpora for retrieval (Hu et al., 2023; Jiang et al., 2023a).

Hyperedge and Higher-Order Representations. Hypergraphs and n-ary knowledge-base models represent relations among multiple entities without reducing each relation to independent binary triples (Zhou et al., 2006; Feng et al., 2019; Fatemi et al., 2020; Galkin et al., 2020; Liu et al., 2020; 2021). HyperGraphRAG extracts n-ary facts and stores a corpus-level hypergraph with vector indexes for entities and hyperedges (Luo et al., 2025). Hyper-RAG retrieves both entities and correlations from a hypergraph repository and expands them through structural diffusion (Feng et al., 2026). HGRAG treats entities as nodes and passages as hyperedges, combining entity- and passage-level similarity through hypergraph diffusion (Wang et al., 2026). Graph-R1 constructs a lightweight knowledge hypergraph and learns multi-turn retrieval through reinforcement learning (Luo et al., 2026). These methods materialize a corpus-level hypergraph. SAG instead stores each event and its entities as relational incidence rows. SQL joins over shared entities activate only the latent hyperedges required by the query, after which the original chunks are returned to the reader.

References (61)