← Latest papers
💬 NLP

Reasoning by Commented Code for Table Question Answering

This paper proposes a commented step-by-step code-generation framework that decomposes Table Question Answering into executable programs with natural language reasoning, achieving state-of-the-art accuracy of 84.3% on the WikiTableQuestions benchmark by enhancing numerical precision and interpretability.

Original authors: Seho Pyo, Jiheon Seok, Jaejin Lee

Published 2026-02-03
📖 5 min read🧠 Deep dive

Original authors: Seho Pyo, Jiheon Seok, Jaejin Lee

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Problem: The "Linear" Brain vs. The "Grid" World

Imagine a Large Language Model (LLM) as a very smart reader who only reads books one word at a time, from left to right. This works great for stories or essays.

However, tables (like spreadsheets or financial reports) are like grids. They have rows and columns, and the relationship between data points is two-dimensional. If you force a book-reader to read a grid, they often get confused. They might miss the connection between a number in the top row and a category in the bottom column.

Existing methods try to solve this in two ways, but both have flaws:

  1. The "Magic Guess" (End-to-End): The model just looks at the table and guesses the answer. It's fast, but it's bad at math. It's like asking a human to do complex division in their head without a calculator; they might get the right idea but mess up the numbers.
  2. The "One-Line Command" (Old Code Methods): The model writes a single line of code to solve the problem. While this uses a calculator (which is good for math), it's like a black box. You see the input and the output, but you can't see how the machine got there. If it makes a mistake, you have no idea why.

The Solution: The "Cookbook" Approach

The authors of this paper propose a new way to teach the AI: Write a recipe with notes.

Instead of just guessing the answer or writing a cryptic one-line command, the AI is asked to write a step-by-step Python program (a set of instructions for a computer) where every single step has a comment explaining what it's doing.

Think of it like a cooking recipe:

  • Old Way: "Make the soup." (You don't know if they added salt or sugar).
  • New Way (Commented Code):
    • # PLAN: We need to find the oldest year in the list.
    • # FILTER: First, let's throw out all the rows that aren't about "USL A-League".
    • # AGGREGATE: Now, look at the remaining years and pick the biggest number.
    • # ANSWER: The result is 2004.

By forcing the AI to write the "comments" (the reasoning) right next to the "code" (the action), the model is forced to think logically before it acts. It's like making a student show their work on a math test. If they make a mistake in the logic, the comment reveals it, and the code execution catches the error.

How They Trained the AI

The researchers didn't just tell the AI to do this; they built a special training system:

  1. The Teacher: They used a very smart AI to generate these "commented recipes" for thousands of table questions.
  2. The Safety Net: If the AI wrote a recipe that didn't work (the code crashed or gave the wrong answer), the system didn't just throw it away. It showed the AI the mistake and asked it to try again, fixing the specific step that failed.
  3. The "Answer Selector": They realized that sometimes the "Recipe" method is great at math but bad at understanding tricky language, while the "Magic Guess" method is good at language but bad at math. So, they built a tiny "referee" AI. When a question comes in, the referee looks at the answer from the Recipe method and the answer from the Magic Guess method, and picks the one it thinks is correct.

The Results

They tested this on WikiTableQuestions, a popular benchmark where the AI has to answer questions based on messy, real-world tables (like sports stats or financial logs).

  • Solo Performance: Their "Commented Code" method, using a relatively small AI model, achieved 70.9% accuracy. This beat the previous best "code-only" method (which got 67.6%).
  • Team Performance: When they combined their method with the best "Magic Guess" model (Table-R1) using their "referee" selector, the accuracy jumped to 84.3%.

Why This Matters (According to the Paper)

The paper claims that this approach bridges the gap between "thinking" and "doing."

  • Reliability: Because the math is done by a computer engine (Pandas) rather than the AI guessing, the numbers are exact.
  • Transparency: Because of the comments, humans can read the code and understand exactly why the AI chose that answer.
  • Robustness: It handles messy data (like numbers written as "1,234" or dates in weird formats) much better than previous methods because the code explicitly tells the computer how to clean that data before calculating.

In short, the paper shows that if you force an AI to write a step-by-step plan with explanations before it solves a math problem on a table, it becomes much smarter, more accurate, and easier to trust.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →