Learning to Search Effective Example Sequences for In-Context Learning

Xiang Gao, Ankita Sinha, Kamalika Das


Abstract
Large language models (LLMs) demonstrate impressive few-shot learning capabilities, but their performance varies widely based on the sequence of in-context examples. Key factors influencing this include the sequence’s length, composition, and arrangement, as well as its relation to the specific query. Existing methods often tackle these factors in isolation, overlooking their interdependencies. Moreover, the extensive search space for selecting optimal sequences complicates the development of a holistic approach. In this work, we introduce Beam Search-based Example Sequence Constructor (BESC), a novel method for learning to construct optimal example sequences. addresses all key factors involved in sequence selection by considering them jointly during inference, while incrementally building the sequence. This design enables the use of beam search to significantly reduce the complexity of the search space. Experiments across various datasets and language models show notable improvements in performance.
Anthology ID:
2025.findings-naacl.342
Volume:
Findings of the Association for Computational Linguistics: NAACL 2025
Month:
April
Year:
2025
Address:
Albuquerque, New Mexico
Editors:
Luis Chiruzzo, Alan Ritter, Lu Wang
Venue:
Findings
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
6137–6146
Language:
URL:
https://preview.aclanthology.org/fix-sig-urls/2025.findings-naacl.342/
DOI:
Bibkey:
Cite (ACL):
Xiang Gao, Ankita Sinha, and Kamalika Das. 2025. Learning to Search Effective Example Sequences for In-Context Learning. In Findings of the Association for Computational Linguistics: NAACL 2025, pages 6137–6146, Albuquerque, New Mexico. Association for Computational Linguistics.
Cite (Informal):
Learning to Search Effective Example Sequences for In-Context Learning (Gao et al., Findings 2025)
Copy Citation:
PDF:
https://preview.aclanthology.org/fix-sig-urls/2025.findings-naacl.342.pdf