Introduction
Large Language Models (LLMs) have revolutionized natural language processing through In-Context Learning (ICL), where models perform tasks based on a few demonstration examples provided in the prompt. However, the effectiveness of ICL is highly dependent on the quality of these examples. In practical scenarios, developers often face a massive pool of unlabeled data but possess a limited budget for human annotation. Selecting the most representative and diverse samples to annotate is thus a critical challenge.
Existing "selective annotation" methods, such as Vote-k or IDEAL, aim to identify optimal examples but suffer from significant computational overhead. For instance, on a standard dataset like DBpedia, these methods can take over eight hours to select a mere 18 instances. This bottleneck hinders the rapid development and scaling of LLM-based applications. To address this, we introduce FastGAS (Fast Graph-based Annotation Selection), a novel algorithm that reduces selection time from hours to seconds while maintaining or improving model performance.
The FastGAS Methodology
FastGAS treats the unlabeled dataset as a graph and employs a three-step "divide-and-conquer" strategy to optimize for both diversity and representativeness:
- Graph Construction: Every unlabeled text instance is converted into a vector embedding (e.g., using Sentence-BERT). A similarity graph is then constructed where each instance is a node connected to its $k$-nearest neighbors.
- Graph Partitioning: To ensure diversity, FastGAS uses a multi-level graph bisection technique to split the large graph into $K$ distinct clusters. This prevents the selection of redundant examples that are too similar in topic or style.
- Greedy Node Selection: To ensure representativeness, the algorithm identifies central nodes within each cluster. By selecting nodes with the highest "degree" (most connections), FastGAS picks the best "ambassadors" for each specific data region.
By partitioning the graph first, FastGAS avoids the iterative global searches required by previous methods, resulting in linear computational complexity relative to the number of nodes and edges.
Experimental Evaluation
FastGAS was evaluated across seven diverse datasets covering classification (MRPC, SST-5, DBpedia, MNLI, RTE), commonsense reasoning (HellaSwag), and abstractive summarization (XSUM). The performance was validated across various LLMs, including Llama-2-7B and GPT-3.5-Turbo.
Key Results: Efficiency and Accuracy
The most striking advantage of FastGAS is its efficiency. As shown in the comparison below, FastGAS achieves orders-of-magnitude speedups over state-of-the-art baselines.
- Massive Speedup: On the DBpedia dataset, while the baseline Vote-k required over 30,000 seconds (approximately 8.3 hours), FastGAS completed the selection in roughly 10 seconds.
- Superior Performance: Beyond speed, FastGAS outperformed baselines in 13 out of 14 tested scenarios. Notably, on the MNLI dataset using GPT-3.5-Turbo, FastGAS-selected examples boosted accuracy from ~50% to over 70%.
- Model Agnostic: The gains were consistent across different model architectures and scales, proving that the graph-based selection captures fundamental data characteristics useful for any LLM.
Discussion and Future Work
FastGAS demonstrates that the perceived tradeoff between selection quality and computational efficiency is a myth; a well-structured graph approach can achieve both. However, some challenges remain. The algorithm's performance is sensitive to hyperparameters like the number of partitions ($K$) and neighbors ($k$), which currently require manual tuning.
Future research will focus on automating hyperparameter selection and exploring inter-cluster relationships to further refine the representativeness of the selected samples. Additionally, the authors plan to validate FastGAS on even larger "frontier" models and more complex reasoning tasks to ensure its continued relevance as datasets scale toward the web-level.
Summary updated