Abstract
Large Language Models (LLMs) are typically trained using simple random sampling, which often fails to capture the "long-tail" distribution of topics in massive datasets. This paper introduces ClusterClip Sampling, a novel method that leverages semantic clustering to ensure models learn from rare and common data equally. By employing a "repetition clip" mechanism, ClusterClip prevents overfitting on niche data clusters, leading to improved generalization and performance across diverse benchmarks.
Introduction
The training data for LLMs is inherently unbalanced. While common web crawl data is abundant, high-quality specialized topics and rare concepts are often underrepresented. Traditional sampling strategies are typically coarse-grained, relying on broad domain buckets (e.g., 5% math, 67% web) and sampling randomly within them. This approach leads to two significant challenges: the underfitting of rare but critical data and the potential for overfitting if rare data is naively up-sampled (uniform sampling), causing the model to memorize rather than generalize.
Methodology: ClusterClip Sampling
To address these issues, we propose ClusterClip, a two-stage sampling strategy designed to balance data exposure without sacrificing model stability.
1. Semantic Clustering
Unlike metadata-based grouping, ClusterClip categorizes data based on semantic meaning. Every document is converted into a vector using an off-the-shelf embedding model (e.g., Jina Embeddings 2). K-Means clustering is then applied to group these vectors, revealing the true distribution of topics. This process identifies both massive clusters of common topics and tiny clusters representing rare concepts.
2. Balanced Sampling and the Clip Operation
At the start of training, ClusterClip employs uniform sampling across all clusters, ensuring the model encounters a diverse range of topics immediately. To prevent the memorization of rare data, a "repetition clip" mechanism tracks how many times each cluster has been sampled. Once a cluster reaches a predefined threshold (e.g., 5 repetitions), it is "knocked out" of the sampling pool.
Experimental Setup
The effectiveness of ClusterClip was validated in both Supervised Fine-Tuning (SFT) and Pre-training scenarios using the following datasets:
- Open-Orca: A 1-billion token dataset for SFT containing diverse NLP tasks.
- Proof-Pile-2: A 10B token sample from a 55B token dataset focused on mathematical reasoning.
Models were evaluated on benchmarks including SuperGLUE (general language), GSM8K/MATH (reasoning), MMLU (knowledge), and MT-Bench (chat quality).
Key Results
ClusterClip consistently outperformed standard random and naive uniform sampling across all major benchmarks.
Mathematical Reasoning and Knowledge
On the MATH benchmark, a Llama2-7B model trained with ClusterClip achieved a score of 7.90, a significant improvement over the 6.52 achieved via random sampling. Similarly, on the MMLU benchmark, ClusterClip reached an average score of 51.05, surpassing random sampling (48.84) and standard uniform sampling without clipping (49.98).
Stability Across Domains
One of the most notable strengths of ClusterClip is its stability. Unlike other advanced methods like General-to-Specific (G2S), ClusterClip showed consistent improvements across all MMLU categories, including STEM, humanities, and social sciences.
Discussion and Insights
The research highlights that grouping data by semantic meaning is far more effective than relying on source metadata. Furthermore, the study identifies a "Goldilocks zone" for data repetition; while repeating rare data is beneficial, exceeding a threshold of approximately 5 repetitions begins to degrade general knowledge performance (MMLU scores) due to overfitting.
Importantly, the computational overhead for ClusterClip is minimal. For a 7B parameter model, the clustering process required only 6 GPU hours, representing a negligible fraction of the 1,216 GPU hours used for training.
Conclusion
ClusterClip offers a scalable and efficient solution to the data imbalance problem in LLM training. By combining semantic clustering with a controlled repetition mechanism, it enables models to learn effectively from the entire data distribution, resulting in superior reasoning and knowledge capabilities. Future work will explore applying these techniques to multi-modal data and refining sampling at the token level.
Summary updated