HackerPapers

arXiv:2405.15071cs.CL

Grokked Transformers are Implicit Reasoners: A Mechanistic Journey to the Edge of Generalization

Boshi Wang, Xiang Yue, Yu Su, Huan Sun

Abstract

We study whether transformers can learn to implicitly reason over parametric knowledge, a skill that even the most capable language models struggle with. Focusing on two representative reasoning types, composition and comparison, we consistently find that transformers can learn implicit reasoning, but only through grokking, i.e., extended training far beyond overfitting. The levels of generalization also vary across reasoning types: when faced with out-of-distribution examples, transformers fail to systematically generalize for composition but succeed for comparison. We delve into the model's internals throughout training, conducting analytical experiments that reveal: 1) the mechanism behind grokking, such as the formation of the generalizing circuit and its relation to the relative efficiency of generalizing and memorizing circuits, and 2) the connection between systematicity and the configuration of the generalizing circuit. Our findings guide data and training setup to better induce implicit reasoning and suggest potential improvements to the transformer architecture, such as encouraging cross-layer knowledge sharing. Furthermore, we demonstrate that for a challenging reasoning task with a large search space, GPT-4-Turbo and Gemini-1.5-Pro based on non-parametric memory fail badly regardless of prompting styles or retrieval augmentation, while a fully grokked transformer can achieve near-perfect accuracy, showcasing the power of parametric memory for complex reasoning.

arXiv comments
NeurIPS 2024. Code and data: https://github.com/OSU-NLP-Group/GrokkedTransformer
Journal reference
DOI
Subjects
cs.CLComputation and Language

On Hacker News

Linked by 6 identifiable commenters in 6 comments across 4 threads, from May 2024 to Jun 2024. Found in 2 HN submissions from May 2024 to May 2024. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments4 threads

    • While I agree with the sentiment in general, I've came to the conclusion that what I really want is the flexibility of the natural language interface that LLM's provide, and the return of the correct document. No 'reasoning', no summarizing, just better search [0]. The issue…

      RansomStarkView on HNParent context

    • > The practice of solving problems that you describe is to ingrain/memorize those steps so you don't forget how to apply the procedure correctly Simply memorizing sequences of steps is not how mathematics learning works, otherwise we would not see so much variation in outcomes.…

      VetchView on HNParent context

    • Looks like grokking could give better reasoning and generalization to LLMs, but I'm not sure how practical it would be to overfit a larger LLM See: https://arxiv.org/abs/2405.15071

      barfbagginusView on HNParent context

    • According to https://arxiv.org/abs/2405.15071 their grokked model outperformed GPT4 and Gemini1.5 on the reasoning task. We can then argue if the task makes sense and the conclusion stands for other use cases but i think grokking can be useful

      d3m0t3pView on HNParent context

    • > grokking doesn't and will not have practical uses, imo I'm not so sure. Reasoning is the next big hurdle, and grokking and parametric memory seem very effective here. [1] https://arxiv.org/abs/2405.15071

      naaskingView on HNParent context

  1. Reproducing GPT-2 in llm.c 1 comment

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.