TBDFiltering: Sample-Efficient Tree-Based Data Filtering
Robert Istvan Busa-Fekete, Julian Zimmert, Anne Xiangyi Zheng, Claudio Gentile, Andras Gyorgy
TL;DR
TBDFiltering tackles the scalability challenge of quality-filtering training data for large language models by combining text embeddings with hierarchical clustering to guide adaptive LLM prompting. The core method greedily traverses a clustering tree, querying only a small, strategically chosen subset of leaves to determine keep/discard decisions, with theoretical guarantees that the required samples scale with the final tree cut complexity $K$ rather than the dataset size. Empirically, TBDFiltering yields consistent downstream improvements (1–5% relative) across ThePile, C4, and FineWeb datasets and model sizes from 270M to 4B, often outperforming baseline and classifier-based filtering approaches. The approach promises scalable, modality-agnostic data curation for high-quality foundation models and invites future work on multi-modal and diversity-aware extensions.
Abstract
The quality of machine learning models depends heavily on their training data. Selecting high-quality, diverse training sets for large language models (LLMs) is a difficult task, due to the lack of cheap and reliable quality metrics. While querying existing LLMs for document quality is common, this is not scalable to the large number (billions) of documents used in training. Instead, practitioners often use classifiers trained on sparse quality signals. In this paper, we propose a text-embedding-based hierarchical clustering approach that adaptively selects the documents to be evaluated by the LLM to estimate cluster quality. We prove that our method is query efficient: under the assumption that the hierarchical clustering contains a subtree such that each leaf cluster in the tree is pure enough (i.e., it mostly contains either only good or only bad documents), with high probability, the method can correctly predict the quality of each document after querying a small number of documents. The number of such documents is proportional to the size of the smallest subtree with (almost) pure leaves, without the algorithm knowing this subtree in advance. Furthermore, in a comprehensive experimental study, we demonstrate the benefits of our algorithm compared to other classifier-based filtering methods.
