Towards Zero-Shot and Few-Shot Table Question Answering using GPT-3

Pragya Srivastava, Tanuja Ganu, Saikat GuhaarXiv 2022

Abstract

We present very early results on using GPT-3 to perform question answering on tabular data. We find that stock pre-trained GPT-3 is able to zero-shot learn the table structure from a serialized JSON array-of-arrays representation, and able to answer lookup queries and simple comparison questions in natural language without any fine-tuning. We further find that simple prompt engineering to include few-shot static Q&A examples significantly improves accuracy. Lastly, we find that intermixing passage text improves accuracy even further on heterogeneous data. We apply our approach on a novel dataset of simple tables in newspaper infographics with promising results. Overall, we find much cause for optimism in this basic approach.

Introduction

While Large Language Models (LLMs) have demonstrated remarkable proficiency in natural language understanding and code generation, their ability to interpret structured tabular data—particularly the "messy" infographics found in daily newspapers—remains a significant challenge. Traditional Table Question Answering (TableQA) systems often rely on specialized, heavy-duty architectures like TAPAS or HybridQA, which require extensive fine-tuning on large-scale datasets to understand row-column relationships. This research explores whether a general-purpose model like GPT-3 can perform these tasks in zero-shot and few-shot settings using simple serialization and prompt engineering.

Methodology

The researchers developed a multi-stage pipeline to transform visual newspaper infographics into a format suitable for LLM processing. The process begins with extraction using Faster RCNN to segment infographics from digital newspaper pages and Azure Form Recognizer to extract the underlying table structures and associated text.

Representation and Prompting

A key innovation of this approach is the representation of tables. Instead of complex embeddings, tables are serialized into a simple JSON array-of-arrays format. This leverages GPT-3's likely exposure to structured data formats during its training on code. The prompts are constructed using a "sandwich" technique, where the model is provided with passage text followed by the serialized table data, a question, and a prefix for the answer.

Figure 1: Prompt structure for GPT-3 TableQA, showing the integration of passage text, JSON-serialized table data, and few-shot examples.

To further enhance performance, the team utilized a Google T5 model to generate synthetic Q&A pairs from the extracted tables. These pairs serve as "few-shot" examples, priming the model to reason about the specific data structure before it encounters the actual test query.

Experimental Data

The study utilized a novel infographic dataset consisting of 12 tables extracted from digital newspapers, covering diverse domains such as weather, sports, and finance. Additionally, a synthetic dataset of 200 Q&A pairs was generated from 37 infographic tables to facilitate the few-shot learning experiments.

Figure 2: An example of a newspaper infographic table used in the study, showing price variations for different mango varieties.

Results and Discussion

The results indicate a substantial performance advantage for the LLM-based approach on this specific dataset. While a fine-tuned TAPAS model achieved only 18.4% accuracy—likely due to the small size of the training set—GPT-3 demonstrated remarkable robustness:

  • Zero-Shot GPT-3: Achieved 73.6% accuracy, demonstrating a strong baseline understanding of table structures without prior examples.
  • Few-Shot GPT-3: Performance rose to 86.8% accuracy when the model was "warmed up" with synthetic examples.

Qualitative analysis showed that GPT-3 could handle complex lookup queries and comparisons with ease. For instance, it correctly identified minimum temperatures and compared heat levels across different cities based on weather tables. The inclusion of unstructured passage text alongside the table data actually improved accuracy, suggesting that the model can effectively index across heterogeneous data sources.

Conclusion and Future Work

These early results suggest that GPT-3's general-purpose training makes it highly adaptable to unconventional table formats that often stymie specialized models. While the current study is limited by a small sample size, it provides a compelling proof-of-concept for zero-shot and few-shot TableQA. Future work will focus on scaling the infographic dataset, addressing potential hallucinations in numerical reasoning, and exploring applications for the visually impaired and in educational settings to improve data literacy.

Summary updated

BibTeX
@misc{srivastava2022towards,
  author = {Pragya Srivastava and Tanuja Ganu and Saikat Guha},
  title = {{Towards Zero-Shot and Few-Shot Table Question Answering using GPT-3}},
  year = {2022},
  eprint = {2210.17284},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.17284},
}
Figure