Introduction
The performance of foundation models is heavily dictated by the quality of their pretraining data. However, the process of cleaning and preparing these datasets is often fragmented, manual, and opaque. Researchers frequently build bespoke pipelines for different data sources, leading to repetitive effort and a lack of standardized quality metrics. This paper introduces a unified, flexible framework designed to automate and streamline this "messy" process through an iterative loop of data processing and analysis.
The Integrated Framework
The proposed framework consists of two symbiotic modules that allow for a systematic, reproducible engineering process.
Processing Module
The "engine room" of the framework standardizes and cleans data through four key components:
- Reformatter: Converts diverse sources into a unified
jsonlinesformat. - Filter: Discards low-quality text using heuristic rules and model-based metrics like perplexity.
- Cleaner: Strips noise such as HTML tags and advertisements using regex and exact matching.
- Deduplicator: Employs MinHash LSH to remove near-duplicate documents, preventing overfitting and the "double descent" phenomenon.
Analyzing Module
The "control tower" enables researchers to inspect data quality iteratively:
- Evaluator: Visualizes distributions of text length, language, and perplexity.
- Retriever: Uses ElasticSearch and BM25 to verify the presence of specific entities or niche knowledge.
- Debugger: Fine-tunes cleaning parameters by showing which documents are captured by specific filters.
Experimental Evaluation
The framework was validated using subsets of The Pile (OpenWebText2, Wikipedia, HackerNews) and a version of CommonCrawl for end-to-end pretraining of a 110M parameter GPT-2 model.
Training Efficiency and Performance
The impact of data refinement is most evident in training efficiency. A model trained on refined data (GPT-2-ref) achieved the same validation loss in just 0.25M steps that the baseline model (trained on raw data) required 2M steps to reach—representing an 8x improvement in compute efficiency.
Beyond efficiency, the refined model demonstrated superior performance across multiple downstream benchmarks. For instance, on the LAMBADA dataset, perplexity dropped from 134.04 to 122.43. Automated evaluations using ChatGPT also confirmed that processed data was consistently preferred over raw data across all tested domains, particularly in noisier datasets like HackerNews.
Conclusion
By shifting data curation from an "art" to a systematic engineering process, this framework significantly reduces the manual effort and compute cost associated with training foundation models. While aggressive cleaning improves quality, it also reduces token volume; future work will focus on balancing these factors and scaling the framework to handle multi-terabyte datasets.
Summary updated