Abstract
Data preprocessing remains a labor-intensive bottleneck in data science, traditionally requiring specialized tools and manual rule engineering. This paper evaluates the potential of Large Language Models (LLMs) to serve as general-purpose data cleaners. By leveraging advanced prompting techniques such as Chain-of-Thought (CoT) reasoning and batching, the authors demonstrate that LLMs like GPT-4 can achieve state-of-the-art performance across error detection, data imputation, and entity matching tasks, often outperforming specialized baselines. The study highlights that the inherent reasoning capabilities of LLMs, combined with efficient batching strategies, make them a viable alternative to traditional, task-specific pipelines.
Introduction
The "grunt work" of cleaning, fixing, and matching tabular data is a notorious hurdle in the data science pipeline. Historically, this has necessitated a fragmented ecosystem of human-engineered rules and specialized machine learning models (e.g., HoloClean for error detection, Magellan for entity matching). These tools are often domain-limited, difficult to configure, and require significant manual effort to adapt to new datasets. This research investigates whether the inherent world knowledge and reasoning capabilities of general-purpose LLMs can replace these specialized systems while maintaining efficiency and accuracy.
Methodology
The proposed framework treats tabular data as text sequences and applies several state-of-the-art prompting strategies to optimize performance:
- Contextualization: Tabular records are serialized into readable string formats (e.g.,
[attribute: value]) to better align with the natural language training of LLMs. - Zero-shot with Chain-of-Thought (CoT): Models are instructed to "reason" before providing an answer. For example, in data imputation, the model might explain why a specific area code implies a certain city before filling in the missing value.
- Few-shot Prompting: Providing a small number of labeled examples helps the model understand task-specific criteria, such as the nuances of what constitutes a "match" in entity resolution.
- Batch Prompting: To address the high cost and latency of LLM APIs, multiple data instances are grouped into a single prompt. This reduces the total token count and the number of required API calls.
- Feature Selection: Manual selection of relevant columns reduces noise and minimizes token consumption, focusing the model's attention on the most informative data.
Experimental Evaluation
The framework was evaluated across 12 public datasets covering four core data cleaning tasks:
- Error Detection (ED): Identifying inaccuracies in datasets like Adult and Hospital.
- Data Imputation (DI): Filling missing values in the Buy and Restaurant datasets.
- Schema Matching (SM): Aligning attributes in the Synthea dataset.
- Entity Matching (EM): Identifying duplicate records across seven benchmarks, including Amazon-Google and iTunes-Amazon.
Results and Key Insights
Performance Comparison
GPT-4 emerged as the superior model, achieving 100% accuracy or F1 scores on 4 of the 12 datasets. As shown in the performance comparison below, LLMs frequently outperformed specialized baselines like Magellan and Ditto in Entity Matching tasks. Notably, GPT-4 significantly outperformed the specialized SMAT baseline in schema matching, reaching a 66.7% F1 score compared to 38.5%.
The Role of Reasoning and Batching
A key finding was that "Zero-shot Reasoning" significantly boosted performance, particularly in complex tasks like error detection and schema matching. Furthermore, the study found that batching is highly effective. Increasing the batch size not only reduced costs and processing time but, in some instances, improved the F1 score by allowing the model to observe patterns across multiple records simultaneously.
On the Adult dataset for error detection, increasing the batch size from 1 to 15 reduced the cost from $8.14 to $2.99 and slashed processing time from 4.76 hours to 1.60 hours, while actually improving the F1 score from 44.0% to 46.3%.
Discussion and Conclusion
While LLMs show immense promise as generalist data preprocessors, several challenges remain. Models may struggle in highly specialized or proprietary domains (e.g., advanced medical or legal data) where training data is sparse. Additionally, the risk of hallucinations—generating plausible but incorrect data—remains a concern. While batching improves efficiency, LLMs are still currently more expensive and slower than local scripts for massive, billion-row datasets. Future work will focus on domain-specific tuning and extending these techniques to more complex tasks like data fusion and automated data wrangling.
Summary updated