Reasoning Graph Enhanced Exemplars Retrieval for In-Context Learning
Yukang Lin, Bingchen Zhong, Shuoran Jiang, Joanna Siebert, Qingcai Chen
TL;DR
This work addresses how exemplar selection for in-context learning can benefit from both semantic similarity and the structural logic of problem-solving. It introduces Reasoning Graph Enhanced Exemplar Retrieval (RGER), which builds reasoning graphs from intermediate steps and uses graph kernels to measure structural similarity for re-ranking candidate exemplars before prompting an LLM. By combining a learned retriever with graph-based re-ranking and two graph-construction pipelines, RGER achieves superior performance on math and logic reasoning benchmarks across multiple backends and demonstrates robustness to different model capabilities. The approach advances ICL by explicitly aligning problem-solving trajectories between exemplars and queries, enabling more reliable and explainable in-context reasoning with practical impact for complex tasks.
Abstract
Large language models (LLMs) have exhibited remarkable few-shot learning capabilities and unified the paradigm of NLP tasks through the in-context learning (ICL) technique. Despite the success of ICL, the quality of the exemplar demonstrations can significantly influence the LLM's performance. Existing exemplar selection methods mainly focus on the semantic similarity between queries and candidate exemplars. On the other hand, the logical connections between reasoning steps can be beneficial to depict the problem-solving process as well. In this paper, we proposes a novel method named Reasoning Graph-enhanced Exemplar Retrieval (RGER). RGER first quires LLM to generate an initial response, then expresses intermediate problem-solving steps to a graph structure. After that, it employs graph kernel to select exemplars with semantic and structural similarity. Extensive experiments demonstrate the structural relationship is helpful to the alignment of queries and candidate exemplars. The efficacy of RGER on math and logit reasoning tasks showcases its superiority over state-of-the-art retrieval-based approaches. Our code is released at https://github.com/Yukang-Lin/RGER.
