OptiSeq: Ordering Examples On-The-Fly for In-Context Learning

Rahul Atul Bhope, Praveen Venkateswaran, K. R. Jayaram, Vatche Isahagian, Vinod Muthusamy, Nalini Venkatasubramanian


Abstract
Developers using LLMs and LLM-based agents in their applications have provided plenty of anecdotal evidencethat in-context-learning (ICL) is fragile. In this paper, we show that in addition to the quantity and quality of examples, the order in which the in-context examples are listed in the prompt affects the output of the LLM and, consequently, their performance. While prior work has explored improving ICL through dataset-dependent techniques, we introduce , a purely inference-time, dataset-free optimization method that efficiently determines the best example order. OptiSeq leverages log probabilities of LLM-generated outputs to systematically prune the search space of possible orderings and recommend the best order(s) by distinguishing orderings that yield high levels of accuracy and those that underperform. Extensive empirical evaluation on multiple LLMs, datasets, and prompts demonstrates that OptiSeq improves accuracy by 5.5 - 10.5 percentage points across multiple tasks.
Anthology ID:
2025.findings-emnlp.1353
Volume:
Findings of the Association for Computational Linguistics: EMNLP 2025
Month:
November
Year:
2025
Address:
Suzhou, China
Editors:
Christos Christodoulopoulos, Tanmoy Chakraborty, Carolyn Rose, Violet Peng
Venue:
Findings
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
24864–24887
Language:
URL:
https://aclanthology.org/2025.findings-emnlp.1353/
DOI:
Bibkey:
Cite (ACL):
Rahul Atul Bhope, Praveen Venkateswaran, K. R. Jayaram, Vatche Isahagian, Vinod Muthusamy, and Nalini Venkatasubramanian. 2025. OptiSeq: Ordering Examples On-The-Fly for In-Context Learning. In Findings of the Association for Computational Linguistics: EMNLP 2025, pages 24864–24887, Suzhou, China. Association for Computational Linguistics.
Cite (Informal):
OptiSeq: Ordering Examples On-The-Fly for In-Context Learning (Bhope et al., Findings 2025)
Copy Citation:
PDF:
https://aclanthology.org/2025.findings-emnlp.1353.pdf
Checklist:
 2025.findings-emnlp.1353.checklist.pdf