Large Language Models (LLMs) achieve strong logical reasoning performance in few-shot settings when prompted with symbolic representations that abstractly describe step-by-step reasoning and graph traversal procedures. However, it remains unclear how LLMs internally carry out these reasoning steps and the overall procedure learned from only a few demonstrations. This work localizes the attention heads that are causally involved in individual reasoning steps under a family of symbolic-aided prompts and characterizes the information transferred among them. We first observe that the model is least confident at the tokens that steer the reasoning process. These tokens correspond to three decisions in each inference step: which premise to select, whether to stop selecting premises, and which rule to apply. For each decision, a small set of attention heads acting at the decision position (approximately 3\% of all heads) restores most of the model's clean behavior when patched into a corrupted run and largely removes it when corrupted in a clean run. In contrast, the heads that read the relevant facts and rules from the context reside in earlier layers and contribute in a more distributed manner. We also identify heads that are sensitive to the order of reasoning steps in the demonstrations, which reflects the global reasoning strategy (e.g., graph traversal algorithm), although this effect is weaker and less consistent across models and prompt templates. Our code is available at https://github.com/phuongnm94/circuits_for_lr_traces.git
翻译:暂无翻译