Skip to main content
QUICK REVIEW

[Paper Review] DataFrame QA: A Universal LLM Framework on DataFrame Question Answering Without Data Exposure

Junyi Ye, Mengnan Du|arXiv (Cornell University)|Jan 27, 2024
Topic ModelingComputer Science3 citations
TL;DR

This paper introduces DataFrame QA, a novel zero-shot framework that enables large language models (LLMs) to generate valid Pandas queries for data analysis using only column names and data types—excluding actual table values—thereby ensuring data privacy and reducing context window size. GPT-4 achieves 97% pass@1 accuracy on the new UCI-DataFrameQA benchmark, demonstrating high effectiveness in secure, efficient, and scalable data analysis without data exposure.

ABSTRACT

This paper introduces DataFrame question answering (QA), a novel task that utilizes large language models (LLMs) to generate Pandas queries for information retrieval and data analysis on dataframes, emphasizing safe and non-revealing data handling. Our method, which solely relies on dataframe column names, not only ensures data privacy but also significantly reduces the context window in the prompt, streamlining information processing and addressing major challenges in LLM-based data analysis. We propose DataFrame QA as a comprehensive framework that includes safe Pandas query generation and code execution. Various LLMs, notably GPT-4, are evaluated using the pass@1 metric on the renowned WikiSQL and our newly developed 'UCI-DataFrameQA', tailored for complex data analysis queries. Our findings indicate that GPT-4 achieves pass@1 rates of 86% on WikiSQL and 97% on UCI-DataFrameQA, underscoring its capability in securely retrieving and aggregating dataframe values and conducting sophisticated data analyses. This approach, deployable in a zero-shot manner without prior training or adjustments, proves to be highly adaptable and secure for diverse applications.

Motivation & Objective

  • To address the challenges of data privacy, context window bloat, and computational cost in LLM-based table question answering by eliminating the need to expose raw table values in prompts.
  • To develop a universal, zero-shot framework for DataFrame question answering that relies solely on column headers, data types, and natural language questions.
  • To improve efficiency and scalability in LLM-driven data analysis by minimizing prompt length and reducing reliance on full table content.
  • To evaluate the performance of diverse LLMs—including GPT-4, CodeLlama, and Llama2—on a new benchmark tailored for complex data analysis tasks.
  • To identify and analyze error patterns in LLM-generated queries, particularly those stemming from model limitations and dataframe-specific complexities.

Proposed method

  • The framework takes as input a tuple (S, H, C, Q), where S is supplementary context, H is column headers, C is column metadata (types, descriptions), and Q is the natural language question.
  • The model generates a Pandas query P′ via a zero-shot prompt that excludes all table values, relying only on structural and semantic information from H and C.
  • The generated query P′ is executed on the actual dataframe to produce the answer A′, which is compared to the ground truth answer A derived from the correct query P.
  • The system uses the pass@1 metric to evaluate success, measuring whether the top-ranked generated query produces the correct result.
  • The framework supports dynamic prompt augmentation with dataset descriptions and format constraints to improve interpretability and accuracy.
  • The approach is evaluated on WikiSQL and a newly created benchmark, UCI-DataFrameQA, designed for complex, real-world data analysis queries.
Figure 1: An example where a LLM can generate a correct Pandas query to answer user question using only the table header and column data types, without accessing the table values. Typically, the total number of tokens for DataFrame QA tasks, including both the prompt and the model output, stays belo
Figure 1: An example where a LLM can generate a correct Pandas query to answer user question using only the table header and column data types, without accessing the table values. Typically, the total number of tokens for DataFrame QA tasks, including both the prompt and the model output, stays belo

Experimental results

Research questions

  • RQ1Can LLMs generate semantically correct and executable Pandas queries for data analysis using only column names and data types, without accessing table values?
  • RQ2How does the performance of state-of-the-art LLMs vary in generating accurate queries under zero-shot settings with minimal context?
  • RQ3What are the primary error sources in LLM-based DataFrame QA, and how do they relate to model capabilities versus dataframe-specific structural challenges?
  • RQ4To what extent can prompt engineering with metadata (e.g., data types, descriptions) improve query accuracy and model generalization?
  • RQ5How does the proposed framework compare to traditional Text-to-SQL or table QA approaches in terms of privacy, efficiency, and scalability?

Key findings

  • GPT-4 achieves a pass@1 accuracy of 86% on the WikiSQL benchmark, demonstrating strong performance on standard table QA tasks.
  • On the newly introduced UCI-DataFrameQA benchmark, GPT-4 achieves a pass@1 accuracy of 97%, indicating high effectiveness for complex, real-world data analysis queries.
  • The framework significantly reduces prompt length—keeping total tokens below 250—by excluding table values, thus mitigating context window limitations.
  • The method effectively prevents data leakage, as no actual data values are exposed during inference, enhancing data privacy in sensitive applications.
  • Error analysis reveals that model-inherent limitations, such as mathematical reasoning failures and difficulty with value formatting, are major contributors to incorrect query generation.
  • The framework is deployable in a zero-shot manner across diverse LLMs without fine-tuning, showing strong adaptability and scalability.
Figure 2: Framework of DataFrame QA.
Figure 2: Framework of DataFrame QA.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.