Programming Every Example: Lifting Pre-training Data Quality Like Experts at Scale

Fan Zhou, Zengzhi Wang, Qian Liu, Junlong Li, Pengfei Liu

TL;DR

PROX (Programming Every Example) is a framework that transforms pre-training data refinement from a set of rigid, human-written rules into a flexible programming task. By training tiny language models (as small as 0.3B parameters) to generate and execute Python-style snippets for every document, researchers achieved a 20x reduction in training compute for math tasks and consistent performance boosts across all major open-source web corpora.

What Problem Does This Paper Address?

The "Garbage In, Garbage Out" mantra dominates LLM pre-training. Currently, researchers clean massive web crawls using two main methods:

  1. Heuristic Rules: Rigid "if-then" statements (e.g., "if the word count is < 50, drop it"). These are blunt instruments that often delete good data or keep "noisy" text like navigation bars and footers.
  2. Model-based Synthesis: Using giant LLMs to rewrite or generate data. This is prohibitively expensive at the trillion-token scale and risks introducing "model collapse" or hallucinations.

There is a missing middle: a way to perform fine-grained, document-specific cleaning that is more flexible than a rule but more grounded and efficient than full-scale text synthesis.

Methods

The authors introduce PROX, which treats data cleaning as a programming task. Instead of a model outputting a "clean" version of a document, it outputs a small program (using a Pythonic grammar) that describes how to fix the document.

Overview of the ProX framework

The workflow follows three steps:

  1. Adaptation: A powerful "teacher" model (Llama-3-70B) annotates a small seed dataset, showing how to clean documents using specific functions like remove_lines() or normalize(). A tiny "refining model" (0.3B to 1.7B parameters) is then fine-tuned on this seed data.
  2. Generation: This tiny model processes the entire corpus, generating a specific program for every document. This happens in two stages: Doc-level (deciding to keep or drop the whole thing) and Chunk-level (performing surgical edits on sections of text).
  3. Execution: A standard Python executor runs these programs on the raw text to produce the final, high-quality corpus.

By using code execution, the system ensures that the "refinement" is deterministic and avoids the hallucination issues common in pure text-to-text rewriting.

Datasets

The authors tested PROX across the most prominent "heavyweight" pre-training corpora:

  • General Domain: RedPajama-V2, C4, FineWeb, FineWeb-Edu, and DCLM.
  • Math Domain: OpenWebMath.
  • Evaluation: Performance was measured across 10 standard benchmarks (including ARC, MMLU, and HellaSwag) and 9 mathematical reasoning tasks (like GSM8K and MATH).

Key Insights and Results

  • Small Models are Sufficient Refiners: One of the most surprising findings is that a 0.3B parameter model—tiny by modern standards—is capable of identifying complex noise patterns and writing effective cleaning programs.
  • The "Surgical" Advantage: Unlike traditional filters that delete entire documents if they contain a single navigation bar, PROX can simply call remove_lines(0, 5) to strip the header while keeping the valuable content. This leads to much higher data efficiency.
Performance gains using ProX on FineWeb and OpenWebMath
  • Domain-Specific Multiplier: In the math domain, PROX-refined data allowed a 7B model to match the performance of models trained on 20x more data (10B tokens vs. 200B tokens). This suggests that for technical domains, data quality isn't just a marginal gain—it's a massive compute multiplier.
  • Scaling Refinement FLOPs: The authors show that spending extra compute on refining data (inference) significantly reduces the compute needed for training. For a 1.7B model, they achieved baseline performance using only 58% of the original training FLOPs.
  • Consistent Gains: Models trained on PROX-refined data outperformed those trained on raw data by an average of 2.5% across 10 benchmarks, beating state-of-the-art heuristic pipelines (like the FineWeb and Gopher rules) by over 1.0% on average.
  • High Reliability: The generated programs had an extremely low failure rate (<0.4%), proving that small models can be highly reliable when the output space is constrained to simple function calls.

Limitations and Future Work

  • Inference Overhead: While the refining models are small, running inference on trillions of tokens still requires a significant GPU budget. The authors argue this is offset by training savings, but it remains a high entry barrier.
  • Seed Data Dependency: The system relies on a high-quality "teacher" model to create the initial SFT (Supervised Fine-Tuning) data. If the teacher is biased or misses certain types of noise, the refiner will too.
  • Token Retention: PROX is quite "picky," retaining only about 23-28% of the original tokens. While this increases quality, it might limit the total "knowledge" a model can acquire if the starting corpus isn't large enough.
  • Future Directions: The authors suggest exploring even more complex "programming" operations and applying PROX to multi-modal data (images/video) where heuristic cleaning is even more difficult.

Summary updated

BibTeX
@inproceedings{zhou2025programming,
  author = {Fan Zhou and Zengzhi Wang and Qian Liu and Junlong Li and Pengfei Liu},
  title = {{Programming Every Example: Lifting Pre-training Data Quality Like Experts at Scale}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=ak0vlKTkpx},
}
Figure