Sparse Autoencoders Reveal Temporal Difference Learning in Large Language Models
Can Demircan, Tankred Saanum, Akshay Kumar Jagadish, Marcel Binz, Eric Schulz
Abstract
In-context learning, the ability to adapt based on a few examples in the input prompt, is a ubiquitous feature of large language models (LLMs). However, as LLMs' in-context learning abilities continue to improve, understanding this phenomenon mechanistically becomes increasingly important. In particular, it is not well-understood how LLMs learn to solve specific classes of problems, such as reinforcement learning (RL) problems, in-context. Through three different tasks, we first show that Llama 3 70B can solve simple RL problems in-context. We then analyze the residual stream of Llama using Sparse Autoencoders (SAEs) and find representations that closely match temporal difference (TD) errors. Notably, these representations emerge despite the model only being trained to predict the next token. We verify that these representations are indeed causally involved in the computation of TD errors and Q-values by performing carefully designed interventions on them. Taken together, our work establishes a methodology for studying and manipulating in-context learning with SAEs, paving the way for a more mechanistic understanding.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
11 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Sparse Autoencoders Find Highly Interpretable Features in Language Models cites The Alignment Problem from a Deep Learning Perspective
- The Alignment Problem from a Deep Learning Perspective cites Language Models are Few-Shot Learners
- From Flat to Hierarchical: Extracting Sparse Representations with Matching Pursuit cites Sparse Autoencoders Find Highly Interpretable Features in Language Models
- In-Context Learning Strategies Emerge Rationally cites Language Models are Few-Shot Learners
- In-Context Learning Strategies Emerge Rationally cites Transformers Learn In-Context by Gradient Descent
- In-Context Learning Strategies Emerge Rationally cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- Transformers Learn In-Context by Gradient Descent cites Language Models are Few-Shot Learners
- Transformers Learn In-Context by Gradient Descent cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- What Can Transformers Learn In-Context? A Case Study of Simple Function Classes cites Language Models are Few-Shot Learners
Cited by top-tier papers11
- The Alignment Problem from a Deep Learning PerspectiveRichard Ngo, Lawrence Chan, Sören MindermannICLR 2024 · 296 citations
- From Flat to Hierarchical: Extracting Sparse Representations with Matching PursuitValérie Costa, Thomas Fel, Ekdeep Singh Lubana, Bahareh Tolooshams et al.NeurIPS 2025 · 54 citations
- In-Context Learning Strategies Emerge RationallyDaniel Wurgaft, Ekdeep Singh Lubana, Core Francisco Park, Hidenori Tanaka et al.NeurIPS 2025 · 19 citations
- A Snapshot of Influence: A Local Data Attribution Framework for Online Reinforcement LearningYuzheng Hu, Fan Wu, Haotian Ye, David A. Forsyth et al.NeurIPS 2025 · 13 citations
- Large Language Models Think Too Fast To Explore EffectivelyLan Pan, Hanbo Xie, Robert C. WilsonNeurIPS 2025 · 10 citations
Builds on10
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- Reflexion: language agents with verbal reinforcement learningNoah Shinn, Federico Cassano, Ashwin Gopinath, Karthik Narasimhan et al.NeurIPS 2023 · 5,828 citations
- Sparse Autoencoders Find Highly Interpretable Features in Language ModelsRobert Huben, Hoagy Cunningham, Logan Riggs Smith, Aidan Ewart et al.ICLR 2024 · 1,072 citations
- What Can Transformers Learn In-Context? A Case Study of Simple Function ClassesShivam Garg, Dimitris Tsipras, Percy Liang, Gregory ValiantNeurIPS 2022 · 883 citations
- Transformers Learn In-Context by Gradient DescentJohannes von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento et al.ICML 2023 · 729 citations
Related papers
- Scaling Sparse Feature Circuits For Studying In-Context LearningDmitrii Kharlapenko, Stepan Shabalin, Arthur Conmy, Neel NandaICML 2025
- On the Versatility of Sparse Autoencoders for In-Context LearningIkhyun Cho, Gaeul Kwon, Julia HockenmaierEMNLP Findings 2025
- Sparse Latents Steer Retrieval-Augmented GenerationChunlei Xin, Shuheng Zhou, Huijia Zhu, Weiqiang Wang et al.ACL 2025 · 2 citations
- Emergence and Effectiveness of Task Vectors in In-Context Learning: An Encoder Decoder PerspectiveSeungwook Han, Jinyeop Song, Jeff Gore, Pulkit AgrawalICML 2025
- Step-Level Sparse Autoencoder for Reasoning Process InterpretationXuan Yang, Jiayu Liu, Yuhang Lai, Hao Xu et al.ICML 2026 · 2 citations
