Programmatic Reasoning with Structural Schema: A Unified Framework for Multi-Table Inference

Jialin Chen, Brandon A. Mayer, Mikhail Galkin, Sami Abu-El-Haija, Rex Ying, Bryan PerozziNeurIPS 2026

TL;DR

Trying to make an LLM reason across multiple database tables by pasting all the rows into the prompt is like trying to navigate a city by reading every phonebook entry on every street—it quickly blows up your context window and confuses the model. StrucTab-R1 solves this by hiding the raw data and giving the LLM a compact "map" of the database schema instead. Armed with this structural map, the model writes step-by-step executable plans to fetch and join only what it needs, outperforming massive frontier models while slashing token usage by up to 90%.

What Problem Does This Paper Address?

Large Language Models (LLMs) are surprisingly good at answering questions about a single, small spreadsheet. Typically, you just serialize the table into text, paste it into the prompt, and let the model’s attention mechanism figure it out.

However, real-world enterprise data rarely lives in one neat table; it lives in relational databases with dozens of interlinked tables connected by primary and foreign keys. When you try the "paste-it-all" approach here, two things break:

  1. Context Overflow: Serializing thousands of rows across multiple tables eats up tokens at an alarming rate, leading to out-of-context crashes or "lost-in-the-middle" amnesia.
  2. Structural Blindness: Without an explicit grasp of how tables connect, LLMs hallucinate columns or invent nonsensical join paths. Even standard Text-to-SQL approaches struggle here—writing a monolithic SQL query in one shot makes it hard to tell whether a failure came from picking the wrong tables, botching a join, or messing up an aggregation.

Methods

The authors introduce StrucTab-R1 (built on Gemma3-4B and 12B backbones), which decouples planning over the database structure from looking at raw cell values.

Figure 1: Overview of StrucTab-R1. Instead of serializing raw table rows, StrucTab-R1 encodes the database as a schema graph and builds a Chain-of-Execution prompt. The model identifies a relevant schema subgraph and executable tool calls, which are trained by SFT and further refined with structure-aware RL rewards for correctness, execution validity, and schema grounding.

Here is how the pipeline works:

  • Heterogeneous Schema Graph & Token Compression (Novel): Instead of reading rows, the database is turned into a graph where nodes are tables and columns, and edges represent relationships (like has_column or fk_link). A Heterogeneous Graph Attention Network processes this structure, and a cross-attention pooling layer squashes the entire database skeleton into $K$ compact, learned "schema tokens" fed directly to the LLM alongside empty mock-table headers.
  • Chain-of-Execution / CoE (Novel): Rather than spitting out an answer or a single giant SQL query, the LLM emits a <GRAPH> block (identifying the minimal subgraph of tables/columns needed) followed by a <TOOL> block. Here, it calls composable Python-like functions (join, filter, groupby, aggregate) executed by an external engine, receiving compact intermediate observations along the way.
  • Two-Stage Training (Standard + Novel Twist): First, the LLM and graph encoder are jointly warmed up via Supervised Fine-Tuning (SFT) on valid traces generated by Gemini-2.5. Second, the model undergoes Reinforcement Learning using Group Relative Policy Optimization (GRPO). What is new is the structure-aware reward: conditioned on getting the final answer right, the model gets bonus points for schema F1-precision (picking the exact right tables/columns) and execution validity (zero runtime errors), plus an asymmetric length penalty that punishes skipping necessary steps more harshly than taking an extra one.

Datasets

  • Single-Table Benchmarks: Evaluated on TableBench and WikiTableQuestions (WikiTQ) to ensure the structured machinery doesn't overcomplicate simple lookups.
  • Multi-Table Benchmark: Evaluated on TQA-Bench, which tests relational reasoning across foreign-key dependencies at scaling context sizes (8K, 16K, 32K, and 64K tokens).
  • Custom Factual-Conflict Subset: The authors constructed a specialized 8K subset from TQA-Bench where answers could be guessed via world knowledge, then shuffled the answer column ("Disrupted Table") to test whether models genuinely read the database or lazily rely on memorized facts.

Key Insights and Ideas

  • Decoupling schema from data flattens token scaling: Because raw rows stay outside the prompt until queried by tools, input token usage stays nearly flat even as database size explodes.
Figure 2: Input (left) and Output (right) token efficiency across prompting methods.
  • The "Goldilocks" Schema Bottleneck: Compressing a massive database graph into $K$ tokens has a sweet spot (peaking around $K=16$ to $32$). Too few tokens starve the model of join paths; too many reintroduce distracting noise.
  • High accuracy doesn't mean faithful reading: When table values were shuffled to contradict common sense, many frontier models suffered steep accuracy drops while stubbornly clinging to their pre-trained memories. Because StrucTab-R1 must execute programmatic tools to see any data at all, it treats the database as the true source of evidence rather than optional context.
  • Outcome rewards aren't enough: Ablations show that rewarding final answers alone leaves intermediate reasoning shaky; explicitly rewarding schema subgraph selection and error-free tool execution is what locks in reliability.

Key Results

  • Beating Giants on Multi-Table Tasks: On TQA-Bench, StrucTab-R1 (12B) hits 76.83% (16K), 73.20% (32K), and 70.56% (64K) execution accuracy—outperforming both GPT-4o (63.41% at 64K) and Gemini-2.5-Pro (67.25% at 64K), while smaller open-weights and table-specialized models (like TableLLM-7B) completely crash with Out-Of-Context errors.
  • Single-Table Strength: It achieves 76.88% on WikiTQ, edging out GPT-4o (75.40%).
  • Structural Gains: Adding learned schema tokens boosts multi-hop reasoning accuracy by 13% and cross-table joins by 12% compared to running without them.
  • Robustness Under Conflict: On the disrupted commonsense test, StrucTab-R1 (12B) achieves the highest Table-Reliance Rate (78.6%) and smallest accuracy drop (-5.4%), beating DeepSeek-R1 (-8.1%) and GPT-4o (-6.7%).

Limitations and Future Work

Not discussed in the paper. (Note: The provided text concludes at Section 5 without a dedicated Limitations or Future Work section, though the experiments note that on simpler single-table tasks like TableBench, CoE is competitive with—rather than strictly superior to—simpler prompting methods like Textual CoT).

Summary updated

Abstract

Large language models (LLMs) have shown strong performance in single-table reasoning but struggle to generalize to multi-table scenarios due to schema heterogeneity, long input contexts, and the lack of structural awareness. We introduce StrucTab-R1, a schema-centric reasoning framework that decouples relational reasoning from raw data exposure. Our approach encodes relational databases as heterogeneous schema graphs, where tables, columns, and foreign-key constraints form distinct node and edge types, and employs a heterogeneous graph encoder with question-conditioned cross-attention pooling to distill compact, semantically grounded schema tokens. Rather than serializing table rows into the context, the LLM plans over the schema representation and emits a Chain-of-Execution: an executable reasoning trace that first identifies the relevant schema subgraph and then performs a sequence of composable tool-function calls (e.g., filter, join, aggregate). These calls are executed externally, with compact observations returned to support subsequent reasoning steps. This design confines the model's attention to relevant subgraphs, mitigating hallucinations in multi-hop join reasoning. To further improve reliability, we train the model with supervised traces followed by structure-aware reinforcement learning, where the reward jointly optimizes answer correctness, schema-region precision, and execution consistency. Experiments on single-table and multi-table benchmarks show that StrucTab-R1 improves execution accuracy over strong general-purpose and table-specialized LLMs and remains effective on large-schema settings where raw-context baselines fail.
BibTeX
@inproceedings{chen2026programmatic,
  author = {Jialin Chen and Brandon A. Mayer and Mikhail Galkin and Sami Abu-El-Haija and Rex Ying and Bryan Perozzi},
  title = {{Programmatic Reasoning with Structural Schema: A Unified Framework for Multi-Table Inference}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=lqGHZL1TSK},
}
Figure