Introduction
Supervised Fine-Tuning (SFT) is a critical phase in transforming base large language models (LLMs) into capable assistants. While the volume of available instruction data has exploded, recent research suggests that data quality and diversity are more important than sheer quantity. Current data selection strategies typically prioritize either high-quality examples (often using teacher models or perplexity) or diverse coverage (using clustering or topic modeling). However, quality-focused methods can lead to redundancy and poor generalization, while diversity-focused methods may inadvertently include low-quality "noise."
This paper introduces GRAPHFILTER, a novel data selection framework that treats SFT data selection as a set cover problem on a bipartite graph. By simultaneously optimizing for linguistic diversity and data quality, GRAPHFILTER identifies a training subset that is both high-performing and broadly representative.
Methodology: Data Selection as a Set Cover Problem
The core of GRAPHFILTER is the representation of a dataset as a bipartite graph $G = (U \cup V, E)$, where $U$ represents the set of sentences and $V$ represents the set of unique n-grams (unigrams, bigrams, and trigrams) found across the dataset. An edge $(u, v) \in E$ exists if sentence $u$ contains n-gram $v$. The authors found that trigrams ($n=3$) provide the optimal balance between linguistic granularity and computational complexity.
The Priority Function
To select the most informative and diverse sentences, GRAPHFILTER employs a multiplicative priority score: $$\phi(u) = \text{QUALITY}(u) \times \text{DIVERSITY}(u)$$
- Quality: The authors utilize SUPERFILTER, a metric that measures the information gain of a response conditioned on its instruction.
- Diversity: This is calculated as the sum of TF-IDF scores for the n-grams in a sentence that have not yet been "covered" by previously selected sentences.
Iterative Selection Process
The algorithm proceeds iteratively, selecting the sentence with the highest priority score at each step. Once a sentence is added to the training subset, the n-grams it contains are marked as "covered" in the graph, which dynamically updates the diversity scores for the remaining sentences. This mechanism naturally favors sentences with novel linguistic patterns.
The use of a max-heap data structure ensures the process is highly efficient, with a complexity of $O(\log N)$ per iteration, making it feasible to process large-scale datasets on standard CPU hardware.
Experimental Setup
The researchers evaluated GRAPHFILTER using the Magpie dataset (300K instances generated by Llama-3-70B-Instruct). They fine-tuned three model backbones: Gemma-2-2B, Mistral-7B-v0.3, and Llama-3-8B. Performance was measured across a suite of standardized benchmarks (MMLU, ARC, HellaSwag, GSM8K) and LLM-as-a-judge evaluations (AlpacaEval-2.0, MT-Bench).
Results and Analysis
GRAPHFILTER consistently outperformed nine competitive baselines, including AlpaGasus, DEITA, and KMeans-based selection. On the Llama-3-8B model, GRAPHFILTER achieved an average score of 47.97, surpassing the random baseline (45.51) and the previous state-of-the-art quality-based method, SuperFilter (46.70).
Quality-Diversity Synergy
A key finding is the "power of multiplication." By multiplying quality and diversity scores, the algorithm ensures that selected data must excel in both dimensions. This prevents the inclusion of high-quality but redundant data or unique but low-quality data.
As shown in the t-SNE visualizations, GRAPHFILTER (red) provides more uniform coverage of the data manifold compared to quality-only methods like ArmorRM, which tend to cluster in specific regions. Furthermore, GRAPHFILTER is remarkably lightweight, selecting 10K instances in approximately 0.53 hours on a CPU—a $60\times$ speedup over neural-based methods like AlpaGasus.
Discussion and Conclusion
The study reveals that the optimal selection strategy is budget-dependent: quality is paramount for very small data budgets, while diversity becomes increasingly important as the budget grows. GRAPHFILTER effectively navigates this transition automatically. Additionally, the authors found that applying diversity filtering to instructions is more beneficial than applying it to responses, highlighting the importance of task variety for generalization.
While GRAPHFILTER currently relies on n-grams, its bipartite graph framework is flexible and could be extended to use semantic embeddings in future work. Overall, GRAPHFILTER provides a robust, efficient, and effective solution for curating high-quality, diverse SFT datasets.
Summary updated