Abstract
Large Language Model (LLM) training often relies on massive, internet-scale datasets where quality varies significantly. This paper investigates the impact of document length on code generation performance. We demonstrate that pruning the longest files from a training set—a simple, computationally inexpensive heuristic—can lead to a 2x increase in training efficiency or a 3.5% performance boost on benchmarks like HumanEval. Our analysis reveals that extremely long code files are frequently composed of repetitive data arrays or "spaghetti code" that provide more noise than signal for model learning.
Introduction
Data curation is a critical yet often opaque component of LLM development. While sophisticated embedding-based or classifier-based pruning methods exist, they are computationally intensive. This research explores a simpler alternative for code datasets: length-based pruning. Contrary to natural language domains where length often correlates with quality (e.g., Wikipedia), we hypothesize that in source code, excessive length often indicates low-quality or non-representative data.
Methodology
We fine-tuned a Llama 2 7B model on the Python subset of "The Stack" (approx. 20.4B tokens). Three pruning strategies were compared:
- No Pruning: Baseline using the full dataset.
- Embedding-based Pruning (SCIP): Clustering data and removing outliers furthest from centroids.
- Length-based Pruning: Removing the longest files by token count (testing 10%, 20%, and 50% token removal).
Evaluation was conducted on HumanEval and MBPP benchmarks using a bootstrapping framework to ensure statistical robustness.
The "2% Rule" and Data Quality
The distribution of file lengths in code repositories is highly skewed. A tiny fraction of files accounts for a disproportionate number of total tokens.
Qualitative inspection of these long files reveals they are rarely complex logic. Instead, they often contain massive data arrays, unrolled loops, or repetitive boilerplate. By removing these "spaghetti code" files, we reduce computational waste without losing high-quality algorithmic patterns.
Embedding Bias in Pruning
A key finding is that state-of-the-art embedding-based pruning methods, such as SCIP, are often unintentional proxies for length pruning.
As shown in Figure 4, shorter files are tightly clustered, while longer files are spread out as outliers. This suggests that the "sophistication" of embedding-based methods may be redundant for code datasets where length is the primary driver of outlier status.
Results and Discussion
Our experiments yielded several key insights:
- Efficiency: Models trained on 50% of the data (post-length pruning) matched the performance of full-dataset models after one epoch, effectively doubling training efficiency.
- Benchmark Performance: In compute-controlled settings, aggressive length pruning resulted in a 3.5% absolute improvement on HumanEval.
- Trade-offs: While short-form generation (functions) improved, perplexity on very long files increased. This indicates that while pruning optimizes for standard benchmarks, it may reduce a model's ability to process massive, multi-thousand-line files.
Conclusion
Pruning long files is a highly effective, low-cost strategy for improving code generation models. Future work should focus on distinguishing between "junk" long files and high-quality long-context code, perhaps by synthesizing long-form data from related repository files rather than relying on single, massive source files.
Summary updated