UniRPG: Unified Discrete Reasoning over Table and Text as Program Generation

Yongwei Zhou, Junwei Bao, Chaoqun Duan, Youzheng Wu, Xiaodong He, Tiejun Zhao

TL;DR

UniRPG unifies discrete reasoning over heterogeneous data—combining both tables and text—by framing question answering as a program generation task. By pairing a neural programmer with a symbolic executor and introducing a clever distant supervision strategy, it eliminates the need for expensive human-annotated step-by-step math derivations while significantly outperforming prior state-of-the-art models.

What Problem Does This Paper Address?

Answering complex questions about real-world data often requires discrete reasoning: performing arithmetic, sorting, counting, or comparing values. In domains like finance or sports news, this data is rarely homogeneous; it is scattered across structured tables and unstructured text paragraphs.

Current approaches generally fall into two camps:

  1. Mixture-of-Experts (MoE): These models route questions to specialized sub-predictors (e.g., an addition expert, a sorting expert). While functional, they act as black boxes and struggle to scale to complex, multi-step reasoning.
  2. Semantic Parsing (SP): These models translate questions into executable code (like SQL or Python). They are highly interpretable and scalable but have historically been restricted to either only text or only tables. Furthermore, training them typically requires gold-standard "derivations"—the exact mathematical formulas used to get an answer—which are notoriously expensive and tedious for humans to annotate.

UniRPG bridges this gap by creating a unified semantic parsing framework for hybrid table-text data that can be trained effectively even when human-annotated formulas are completely missing.

Methods

UniRPG splits the problem into two main components: a Neural Programmer that writes a program based on the input, and a Symbolic Program Executor that runs the program to compute the final answer.

Question + Table + Text ──> [ Neural Programmer ] ──> Program ──> [ Symbolic Executor ] ──> Final Answer

1. The Neural Programmer

Built on top of the BART architecture, the programmer consists of two specialized pieces:

  • Structure-Aware Knowledge Reader: Tables are inherently 2D, but standard language models expect flat text. UniRPG flattens the table but injects structural awareness directly into the transformer's self-attention layers. In lower layers, cells only attend to their own rows and the text; in upper layers, column information is integrated.
  • Programmer Generator: The decoder generates a sequence of pre-defined operations (e.g., SUM, DIFF, COUNT, ARGMAX) and uses a pointer/copy mechanism to pluck arguments (specific numbers or text spans) directly from the table and text. To prevent the model from generating invalid code, the authors implement Constraint Decoding, using a dynamic mask to block syntactically illegal choices at each step.
Figure 2: The architecture of neural programmer. It consists of a structure-aware knowledge reader and a program generator. M is a decoding constraint mask to ensure program legality.

2. Distant Supervision (Training Without Derivations)

To bypass manual program annotation, the authors built a template library to automatically search for valid "pseudo-programs." If a generated program executes and yields the correct ground-truth answer, it is kept as a training label. Because multiple formulas can accidentally lead to the correct answer (introducing noise), a re-weighting strategy downweights redundant or overly common pseudo-programs to keep training stable.

Datasets

The model was evaluated on two major benchmarks:

  • TAT-QA: A hybrid dataset containing financial tables and corresponding text paragraphs. It includes human-annotated derivations, allowing the authors to test UniRPG in both fully supervised and distantly supervised (w/o derivation) settings.
  • DROP: A large-scale, text-only dataset requiring discrete reasoning, used to test the model's generality. DROP does not contain derivation annotations.

Key Insights and Ideas

  • Distant Supervision is Viable for Complex QA: Remarkably, training UniRPG using automatically generated pseudo-programs resulted in only a tiny performance drop (~1.0 EM) compared to training with perfect, human-annotated math formulas. This opens the door to leveraging massive unannotated datasets.
  • Syntax Constraints are Crucial: Implementing index, type, and compositional constraints during decoding significantly boosts accuracy by filtering out illegal program states before they can fail at execution time.
  • Cross-Attention Reveals Reasoning: By visualizing the decoder's cross-attention scores, the authors demonstrated that the model explicitly aligns question keywords (like "change") with mathematical operations (DIFF) and correctly maps them to the relevant table cells.
Figure 3: The visualization of the attention score in the last encode layer. The horizontal axis represents the token sequence of the question and table. The vertical axis represents decoded program units at different time steps. Darker color means a higher attention score.

Key Results

UniRPG achieved massive performance gains on the TAT-QA dataset, completely dominating the previous state-of-the-art MoE model, TAGOP:

  • Fully Supervised (w/ derivation): UniRPG (BART-large) achieved 67.1 Exact Match (EM) and 76.0 F1 on the test set, outperforming TAGOP by 17.0 EM and 18.0 F1.
  • Weakly Supervised (w/o derivation): Even without using human math annotations, UniRPG hit 66.1 EM and 74.6 F1, beating out fully supervised baselines.

On the text-only DROP dataset, UniRPG achieved a highly competitive 77.08 EM and 80.42 F1, proving that its unified framework functions exceptionally well even when structured tables are absent.

Limitations and Future Work

Despite its success, the authors note a few areas for improvement:

  • Template Dependency: The distant supervision framework relies on a manually designed template library to find pseudo-programs. Adapting the model to entirely new domains might require expanding these templates.
  • The "Counting" Problem: The model underperformed on questions requiring counting. The authors attribute this to data imbalance, as counting questions make up only 2% of the TAT-QA dataset.
  • Index Errors: An error analysis revealed that 62% of the model's failures were due to "index errors"—extracting the wrong text span or number from long documents containing hundreds of tokens. Refining the pointer mechanism remains a key challenge for future work.

Summary updated

Abstract

Question answering requiring discrete reasoning, e.g., arithmetic computing, comparison, and counting, over knowledge is a challenging task. In this paper, we propose UniRPG, a semantic-parsing-based approach advanced in interpretability and scalability, to perform unified discrete reasoning over heterogeneous knowledge resources, i.e., table and text, as program generation. Concretely, UniRPG consists of a neural programmer and a symbolic program executor, where a program is the composition of a set of pre-defined general atomic and higher-order operations and arguments extracted from table and text. First, the programmer parses a question into a program by generating operations and copying arguments, and then the executor derives answers from table and text based on the program. To alleviate the costly program annotation issue, we design a distant supervision approach for programmer learning, where pseudo programs are automatically constructed without annotated derivations. Extensive experiments on the TAT-QA dataset show that UniRPG achieves tremendous improvements and enhances interpretability and scalability compared with state-of-the-art methods, even without derivation annotation. Moreover, it achieves promising performance on the textual dataset DROP without derivations.
BibTeX
@inproceedings{zhou2022unirpg,
  author = {Yongwei Zhou and Junwei Bao and Chaoqun Duan and Youzheng Wu and Xiaodong He and Tiejun Zhao},
  title = {{UniRPG: Unified Discrete Reasoning over Table and Text as Program Generation}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  url = {https://openreview.net/forum?id=oCh5ZM6Yu9x},
}
Figure