Revisiting In-context Learning Inference Circuit in Large Language Models

Hakaze Cho, Mariko Kato, Yoshihiro Sakai, Naoya Inoue
2/12/2026

No official code found. Best implementation: mlbio-epfl/joint-inference (22 stars, MIT, last commit 2025-06-06). 1 more below.

Abstract

In-context Learning (ICL) is an emerging few-shot learning paradigm on Language Models (LMs) with inner mechanisms un-explored. There are already existing works describing the inner processing of ICL, while they struggle to capture all the inference phenomena in large language models. Therefore, this paper proposes a comprehensive circuit to model the inference dynamics and try to explain the observed phenomena of ICL. In detail, we divide ICL inference into 3 major operations: (1) Input Text Encode: LMs encode every input text (in the demonstrations and queries) into linear representation in the hidden states with sufficient information to solve ICL tasks. (2) Semantics Merge: LMs merge the encoded representations of demonstrations with their corresponding label tokens to produce joint representations of labels and demonstrations. (3) Feature Retrieval and Copy: LMs search the joint representations of demonstrations similar to the query representation on a task subspace, and copy the searched representations into the query. Then, language model heads capture these copied label representations to a certain extent and decode them into predicted labels. Through careful measurements, the proposed inference circuit successfully captures and unifies many fragmented phenomena observed during the ICL process, making it a comprehensive and practical explanation of the ICL inference process. Moreover, ablation analysis by disabling the proposed steps seriously damages the ICL performance, suggesting the proposed inference circuit is a dominating mechanism. Additionally, we confirm and list some bypass mechanisms that solve ICL tasks in parallel with the proposed circuit.

View on arXivView PDF

Code Implementations(2)

MIT

[ICLR 2025] Large (Vision) Language Models are Unsupervised In-Context Learners

226PythonFeb 4, 20251 years agoMIT
deep-learningfoundation-modelsiclriclr2025in-context-learning+3 more
hc495/ICL_CircuitCommunity100%
MIT

[ICLR 2025] Official code implementation of paper: "Revisiting In-context Learning Inference Circuit in Large Language Models"

40Python, Jupyter NotebookJan 22, 20251 years agoMIT
iclr2025in-context-learninginterpretabilitylanguage-model

Similar Papers

Cite this paper

@article{cho2026revisiting,
  title  = {Revisiting In-context Learning Inference Circuit in Large Language Models},
  author = {Hakaze Cho and Mariko Kato and Yoshihiro Sakai and Naoya Inoue},
  year   = {2026},
  eprint = {2410.04468},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2410.04468},
  journal = {ICLR 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.04468.svg)](https://codeofpaper.com/paper/2410.04468)

Discussion