TLDR: This research introduces a three-stage framework that uses large language models (LLMs) to automatically assess the quality of tabular data. It combines statistical outlier detection with LLM-driven generation of data quality rules and executable Python code for validation, significantly outperforming traditional methods by incorporating semantic understanding and domain-specific knowledge.
Ensuring high-quality data is paramount for effective business decisions and reliable analysis, especially with the ever-growing volume of tabular datasets. Traditional methods for validating data often fall short, struggling with efficiency, requiring significant human input, and incurring high computational costs. A new framework from IBM Research addresses these challenges by integrating large language models (LLMs) and automated code generation to provide a robust and scalable solution for assessing tabular data quality.
The core of this innovative approach lies in a three-stage pipeline designed to identify and validate data quality issues. It begins by filtering out potentially erroneous data, then intelligently generates rules to define quality, and finally synthesizes executable code to apply these rules.
Stage 1: Identifying the “Clean” Data
The process starts with an essential preprocessing step: identifying inliers and outliers within the tabular dataset. This involves using advanced statistical analysis and clustering techniques, like the Sparx algorithm, to pinpoint rows that are likely free from errors. By focusing subsequent stages only on this “clean” subset of data, the system ensures that the rules generated are based on reliable patterns, significantly reducing the chance of creating false-positive quality rules.
Stage 2: Generating and Refining Data Quality Rules with LLMs
Once the reliable data is identified, the framework leverages the power of large language models, specifically Gemma-3-12B, to generate data quality rules. These rules are not just simple checks; they are semantically valid and tailored to the specific dataset. The system employs an iterative prompting strategy, where the LLM first drafts a rule description and then enriches it with detailed specifications and pseudocode that precisely capture the validation logic. To make these rules highly effective, the LLMs are aided by retrieval-augmented generation (RAG), drawing upon external knowledge sources and domain-specific examples. This ensures that the generated rules are context-aware and align with the dataset’s domain. Each rule is encapsulated in a structured “Rule Card,” making it transparent and easy to understand.
Before these rules move to the next stage, they pass through a multi-layer “guardrail” system. This critical step eliminates redundant, logically inconsistent, or low-value constraints. It includes a conflict-resolution filter to identify and remove contradictory rules and a rubric-based evaluation that assesses each rule’s significance, priority, and accuracy. Only high-value, correct, or fixable rules proceed, ensuring the final set of rules is robust and reliable.
Also Read:
- ReFine: A New Approach for Generating Tabular Data in Low-Data Scenarios
- Navigating LLM Sensitivity: A New Approach to Testing Response Differences
Stage 3: Automating Validation with Code Generation
The final stage translates these refined data quality rules into executable Python code. For this, the framework utilizes Qwen-2.5-Coder, an LLM specialized in code generation. The system provides the code-generating LLM with comprehensive context, including the table schema, column summaries, the enriched rule card with pseudocode, and representative data samples. It also incorporates few-shot examples of domain- and rule-type-specific code snippets to guide accurate code synthesis. The generated code snippets, typically in the form of a check(df) function, are then run on the dataset to produce a Boolean error mask, highlighting invalid cells. If the code encounters an error during a test run, the exception is fed back to the model for repair, ensuring functional and accurate validators.
The entire workflow culminates in a comprehensive Quality Assessment Report. This report details every flagged cell, identifies the triggering rule, and provides the exact Python snippet responsible for its detection, offering invaluable insights for data stewards to inspect and remediate issues. This approach scales efficiently by avoiding per-row LLM inference calls, making it suitable for large tabular datasets.
Extensive evaluations on various benchmark datasets, including those with synthetically injected errors and standard data corruption suites like REIN, ED2, and RAHA, confirm the effectiveness of this framework. It consistently outperforms existing error detection methods, often by significant margins, particularly on challenging datasets. The research also highlights the crucial role of the inlier detection module and the benefits of incorporating domain-specific few-shot examples, which notably improve performance across different domains. For more details, you can refer to the full research paper here.
In conclusion, this framework represents a significant advancement in automated data quality assessment. By combining statistical analysis with the semantic understanding and code generation capabilities of large language models, it offers a powerful, transparent, and scalable solution for maintaining high data quality in today’s complex data environments.


