Answers are grounded in this paper and cite their sources.
Few-shot learning (FSL) in large language models (LLMs) is highly sensitive to the selection of suitable in-context examples, yet existing approaches commonly guide selection through predefined retrieval or local criteria. In this work, we propose GAFS, a genetic algorithm-based method that formulates FSL example selection as a global combinatorial optimization problem. GAFS searches for fixed-size subsets of demonstrations that jointly maximize downstream task performance by evaluating complete demonstration sets rather than ranking examples independently. We evaluate GAFS on four Spanish hate speech detection datasets, namely HatEval, EXIST, DETESTS and HOMO-MEX, using ten open-weight LLMs from different families and parameter scales, and compare it against ZSL, random FSL and retrieval-based FSL baselines. The best GAFS configurations achieve macro-averaged F1-scores of 68.6 on HatEval, 73.1 on EXIST, 67.6 on DETESTS and 63.7 on HOMO-MEX. Across datasets, GAFS achieves higher macro-F1 than random FSL in 37 of 40 model-dataset configurations and higher macro-F1 than retrieval-based FSL in 37 of 40 configurations. An aggregate McNemar analysis against retrieval-based FSL yields 2,269 additional correct predictions among the discordant cases ( \(p<0.001\) ). A complementary multi-seed analysis shows that this performance pattern is largely preserved across independent evolutionary runs. To isolate the effect of model-specific optimization, we additionally compare GAFS with matched-budget model-aware random search (MA-RS). Neither search strategy shows a systematic advantage over the other across the evaluated configurations, indicating that model-aware, performance-driven evaluation of complete demonstration subsets is an important component of the gains over standard FSL baselines. The analysis of selected demonstrations further shows that higher diversity, coverage or class balance is not systematically associated with better downstream performance. These findings support global, model-aware optimization of demonstration subsets as an effective strategy for FSL while motivating further investigation of the relative advantages of different search mechanisms.
No takes yet. Share an insight, caveat, or question.
Bernal-Beltrán et al. (2026) studied this question.
Synapse has enriched 10 related papers. Consider them for comparative context: