Solving Data-centric Tasks using Large Language Models

Shraddha Barke, Christian Pölitz, Carina Negreanu, Benjamin Zorn, José Cambronero, Andrew D. Gordon, Vu Le, Elnaz Nouri, Nadia Polikarpova, Advait Sarkar, Brian Slininger, Neil Toronto, Jack Williams

Abstract

Large Language Models (LLMs) are increasingly utilized for data-centric tasks such as spreadsheet manipulation and data wrangling. However, real-world tables often exceed context windows or cause performance degradation due to information overload. This paper introduces a novel "cluster-then-select" prompting technique that intelligently samples syntactically diverse rows to represent large datasets. Using SOFSET, a new benchmark of real-world tasks, we demonstrate that providing a small, representative sample of data yields significantly more robust and reliable code generation than random sampling or providing the entire dataset.

Introduction

End-users frequently leverage LLMs to automate repetitive data tasks, such as extracting specific fields from messy strings. To generate code that generalizes to an entire table, an LLM must understand the underlying data structure—including edge cases like hyphenated names or varying date formats. However, passing massive tables into a prompt is computationally expensive and often leads to decreased model performance. This research addresses the critical challenge of conveying the structure of large input tables to an LLM efficiently.

Methodology: Cluster-then-Select Prompting

To optimize the information density of LLM prompts, the authors propose a cluster-then-select technique. This method ensures that the LLM observes the full syntactic variety of the data without needing to process every row.

The cluster-then-select workflow: from raw input table to LLM-generated code.

The pipeline consists of three primary stages:

  1. Regex Synthesis & Clustering: The system synthesizes regular expressions for input columns and clusters rows based on these syntactic patterns (e.g., distinguishing between "First Last" and "First Middle Last").
  2. Greedy Selection: Row selection is framed as a weighted maximal coverage problem. A greedy algorithm selects a small budget of rows that cover the maximum number of distinct syntactic clusters.
  3. Code Generation: These representative rows are formatted into a Pandas dataframe and included in the prompt. The LLM then generates Python code, which is executed in a WebAssembly sandbox (Pyodide) for verification.

The SOFSET Benchmark

The study introduces SOFSET, a dataset of 201 real-world tasks mined from StackOverflow. Tasks are categorized into three classes:

  • Data-independent (IND): Solvable via the query alone.
  • Data-dependent (DEP): Requires data visibility for column names or formats.
  • External-dependent (EXT): Requires external knowledge (e.g., holiday calendars).

To test scalability, the authors created the Kaggle-augmented SOFSET, expanding DEP tasks to 1,000 rows using domain-matched open-source data.

Results and Discussion

Experimental results indicate that the quality of data in the prompt is more important than the quantity. Providing even a single representative row significantly boosts performance compared to providing no data at all.

Performance comparison (pass@K) between no-data, random-sampling, and representative-sampling strategies.

Key findings include:

  • Superiority of Representation: On the 1,000-row dataset, the cluster-then-select method consistently outperformed random selection. Selecting 10 representative rows (represent-10) achieved a pass@5 of 0.32, a 6% improvement over 10 random rows.
  • The "More is Less" Paradox: Counterintuitively, passing the entire 1,000-row table to long-context models sometimes performed worse than passing a single representative row. This suggests that LLMs can suffer from information overload when presented with redundant data.
  • Positional Bias: The order of rows in the prompt matters. Simply shuffling the same 1,000 rows caused pass@1 accuracy to fluctuate between 0.20 and 0.32, highlighting a significant sensitivity in current LLM architectures.

Conclusion

This work demonstrates that intelligent data sampling is a powerful alternative to long-context prompting for data-centric tasks. By focusing on syntactic diversity through clustering, users can generate more robust code while reducing computational costs. Future work will explore expanding this technique to multi-table SQL joins and hierarchical data structures.

Summary updated

BibTeX
@inproceedings{barke2024solving,
  author = {Shraddha Barke and Christian Pölitz and Carina Negreanu and Benjamin Zorn and José Cambronero and Andrew D. Gordon and Vu Le and Elnaz Nouri and Nadia Polikarpova and Advait Sarkar and Brian Slininger and Neil Toronto and Jack Williams},
  title = {{Solving Data-centric Tasks using Large Language Models}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-naacl.41},
}
Figure