In-Context Learning (ICL) has revolutionized how Large Language Models (LLMs) tackle new tasks by providing a few demonstration examples in the prompt. However, the effectiveness of ICL is highly sensitive to example selection. Traditional retrievers, such as those based on BERT or BM25, rely on semantic similarity—finding examples that "sound" like the query. This often leads to "shallow semantic bias," where the model is misled by surface-level vocabulary rather than the underlying logic required to solve the problem.
The Problem: Shallow Semantic Bias
When a math problem mentions "miles" and "hours," a text-based retriever might fetch examples about "hiking" or "running" simply because they share keywords. However, the logical steps needed to solve a "remaining distance" problem are fundamentally different from a "total time" problem. As shown in the figure below, this bias can cause the LLM to follow an incorrect reasoning path, leading to failure even when the retrieved examples are semantically related.
Methods: The GraphIC Framework
To overcome these limitations, the authors propose GraphIC, a training-free retrieval model that represents reasoning processes as directed, node-attributed graphs rather than flat text.
1. Thought Graph Construction
Instead of treating a reasoning chain as a string of text, GraphIC converts it into a Formalized Reasoning Representation (FRR). This representation strips away linguistic "fluff" and focuses on core logical transitions. Each node represents a specific reasoning step (e.g., a mathematical operation), and edges represent dependencies between these steps. This allows the retriever to match the structure of the thought process.
2. Asymmetric Similarity Metric
Standard similarity metrics are symmetric, but reasoning is often directional: a complex example might help solve a simpler one, but the reverse is rarely true. GraphIC introduces a novel asymmetric metric that learns a "reasoning pattern" matrix for each candidate. It uses an iterative aggregation process to account for multiple prior steps and potential backtracking, ensuring that the retrieved examples are truly helpful for the specific logical structure of the query.
Key Results and Insights
GraphIC was evaluated across diverse benchmarks, including GSM8K, AQUA (math), MBPP (coding), and ProofWriter (logic). It consistently outperformed both training-free and training-based baselines.
- Superior Accuracy: On the AQUA dataset, GraphIC improved performance by 7.64% over the best training-free baseline when using Llama-3.1-8B.
- Consistency: The model's performance improves steadily as the number of retrieved examples ($k$) increases, unlike many traditional methods that see diminishing returns.
- Zero Training Required: GraphIC achieves these results without expensive fine-tuning, making it highly adaptable to new domains and different LLMs (tested on both Llama-3 and GPT-4o-mini).
Conclusion
By prioritizing logical structure over surface-level text, GraphIC provides a more robust way to select in-context examples for multi-step reasoning. While it introduces some inference latency due to the graph construction step, its ability to filter out semantic noise and capture logical dependencies represents a significant step forward for reliable LLM prompting.
Summary updated