Revisiting In-context Learning Inference Circuit in Large Language Models

## Abstract

Abstract I n- c ontext L earning (ICL) is an emerging few-shot learning paradigm on L anguage M odels (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) Summarize : LMs encode every input text (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 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. The proposed inference circuit successfully captured many 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.

## 1 Introduction

In-Context Learning (ICL) (Radford et al., ; Dong et al., ) is an emerging few-shot learning paradigm: given the demonstrations $\{(x_{i},y_{i})\}_{i=1}^{k}$ consisting of [input text]-[label token] pairs and a *query* $x_{q}$, Language Models (LMs) take the sequence $[x_{1}][s_{1}][y_{1}]\dots[x_{k}][s_{k}][y_{k}][x_{q}][s_{q}]$(^1^11In this paper, we denote tokenization as $[\cdot]$.) as input and then predicts the label for $x_{q}$ by causal language modeling operation. Typically, the label tokens $y_{i}$ are preceded by and also predicted by forerunner tokens $s_{i}$ (e.g., the colon in “Label: ”). ICL has aroused widespread interest, but its underlying mechanism is still unclear.

There have been theoretical or empirical trials to characterize and explain the inference process of ICL (Xie et al., ; Dai et al., ; Wang et al., ; Han et al., ; Jeon et al., ; Zheng et al., ). However, to capture all the operating dynamics and the observed interesting phenomenon of ICL in Large Language Models(^2^22Large refers to scaled LMs trained by natural language data, such as Llama 3 (AI@Meta, ), contrast to simplified work that uses simple models trained and test on well-embedded input in toy models.)(LLMs), a more comprehensive characterization is still necessary. Therefore, this paper proposes a unified inference circuit and measures various properties in LLMs for a conformation to the observed ICL phenomenon.

As shown in Fig. 1, we decompose ICL dynamics into 3 atomic operations on Transformer layers. Step 1: Summarize: LMs encode each input text $x_{i}$ into linear representations in the hidden state of its corresponding forerunner token $s_{i}$. Step 2: Semantics Merge: For demonstrations, LMs merge the encoded representations of $s_{i}$ with the hidden state of its corresponding label tokens $y_{i}$. Step 3: Feature Retrieval and Copy: LMs retrieve merged label representations $y_{1:k}$ from Step 2 similar to the query representation $s_{q}$ in a task-relevant subspace and then merge them with the query representation. Finally, LM heads predict the label for $x_{q}$ using the label-attached query representation $s_{q}$.
Steps 2 and 3 form a typical induction circuit, which is a key mechanism of ICL but only examined in synthetic scenarios (Elhage et al., ; Singh et al., ; Reddy, ).

Figure: Figure 1: The 3-phase inference diagram of ICL. Step 1: LMs encode every input text into representations, Step 2: LMs merge the encoded text representations of demonstrations with their corresponding label semantics, Step 3: LMs retrieve merged label-text representations similar to the encoded query, and copy the retrieved representations into the query representation.
Refer to caption: extracted/5905049/Figure/Fig1.png

We empirically find evidence for the existence of each proposed step in LLMs, and conduct more fine-grained measurements to gain insights into some phenomena observed in ICL scenarios, such as (1) position bias: the prediction is more influenced by the latter demonstration (Zhao et al., ), (2) noise robustness: the prediction is not easy to be affected by demonstrations with noisy labels (Min et al., ), while larger models are less robust to noise (Wei et al., ), and (3) demonstration saturation: the improvements plateau when sufficient demonstrations are given (Agarwal et al., ; Bertsch et al., ), etc. (discussed in §5.3). Moreover, we find multiple bypass mechanisms for ICL with the help of residual connections, while the 3-phase dynamics remains dominant.

Our contributions can be summarized as: (1) We propose a comprehensive 3-step inference circuit to characterize the inference process of ICL, and find empirical evidence of their existence in LLMs. (2) We conduct careful measurements for each inference step and successfully capture a large number of interesting phenomena observed in ICL, which enhances the practicality of the proposed circuit. (3) Our ablation analysis suggests that the proposed circuit dominates, but some bypass mechanisms exist in parallel to perform ICL. We introduce some of these bypasses along with their empirical evidence.

## 2 Preparation

### 2.1 Background & Related Works

In-context Learning. Discovered by Radford et al. (), ICL is an emerging few-shot learning paradigm with only feed-forward calculation in LMs. Given demonstrations $\{(x_{i},y_{i})\}_{i=1}^{k}$ composed of structured input-label pairs and a query $x_{q}$, typical ICL creates a prompt $[x_{1}][s_{1}][y_{1}]\dots[x_{k}][s_{k}][y_{k}][x_{q}][s_{q}]$, with some structural connectors (e.g. “Label: ”) including forerunner token $s_{i}$ (e.g. “: ”), as shown in Fig. 1. LMs receive such prompts and return the next token distribution, where the label token with the highest likelihood is chosen as the prediction. Explaining the principle of ICL is an unresolved research topic, although there have been some efforts on the relationship between ICL capacity and pre-training data (Li & Qiu, ; Singh et al., ; ; Gu et al., ; Han et al., ; Chan et al., ), the feature attribution of input prompt (Min et al., ; Yoo et al., ; Pan, ; Kossen et al., ), and reduction to simpler algorithms (Zhang et al., ; Dai et al., ; Xie et al., ; Han et al., ). However, a comprehensive explanation of real-world LMs is needed to capture the operating dynamics of ICL.

Induction Circuit. Introduced by Elhage et al. (), an induction circuit is a pair of two cooperating attention heads from two transformer layers, where the “previous token head” writes information about the previous token to each token, and the “induction head” uses this information to identify a token that should follow each token.
Such a function is implemented by two atomic operations: (1) copy the representation of the previous token $[\mathrm{A}]$ to the next token $[\mathrm{B}]$, and (2) retrieve and copy similar representations on $[\mathrm{A}]$ to the current token $[\mathrm{A}^{\prime}]$.
Concisely, it performs inference in the form of $[\mathrm{A}][\mathrm{B}]\dots[\mathrm{A}^{\prime}]\Rightarrow[\mathrm{B}]$, which is similar to ICL-styled data. Therefore, this circuit has been widely used to explain the inference dynamics of ICL (Wang et al., ) and the emergence of ICL during pre-training (Olsson et al., ; Reddy, ; Singh et al., ). Despite their valuable insights, their experiments rely on a synthetic setting: using simplified models and well-embedded (linearly separable) inputs, which differs from the practical ICL scenario using real-world LMs with many layers and complicated inputs. We bridge the gap between the synthetic and real-world settings, providing more detailed explanations for the inference dynamics of ICL based on real-world LLMs.

### 2.2 Experiment Settings

Models. We mainly conduct experiments on 4 modern LMs: Llama 3 (8B, 70B) (AI@Meta, ), and Falcon (7B, 40B) (Almazrouei et al., ). Unless specified, we report the results on Llama 3 70B, since its deep and narrow structure (80 layers, 64 heads) makes it easier to show hierarchical inference dynamics (discussed in §5.2). The results of other models can be found in Appendix F.2.

Datasets. We build ICL-formed test inputs from 6 sentence classification datasets: SST-2 (Socher et al., ), MR (Pang & Lee, ), Financial Phrasebank (Malo et al., ), SST-5 (Socher et al., ), TREC (Li & Roth, ; Hovy et al., ), AGNews (Zhang et al., )specified, we report the average results on these datasets.

Others. Unless specified, we use $k=4$ demonstrations in ICL inputs. For each dataset, we randomly sample $n=512$ test data and assign one order-fixed demonstration sequence for each test sample. About the prompt templates, etc., please refer to Appendix A.1.

## 3 Step 1, Summarize: Linear Representations in Hidden States

This section mainly confirms that LMs construct task-relevant and linearly separable semantic representations for every input text (demonstrations and queries) in the hidden states. Such linear representations are an important foundation for explaining the dynamics of ICL based on induction head, since attention-based feature retrieval, a key mechanism of induction head, can be easily done on linear representations. Current successful studies on simplified models and inputs (Chan et al., ; Reddy, ; Singh et al., ) also assume the existence of such linear representations. Moreover, we confirm some interesting properties of the input text representations: (1) It is based on the capacity in the model weights and can be enhanced by demonstrations in context (Fig. 2 (Middle, Right)). (2) The similarity of representations is biased towards the encoding target’s position.

### 3.1 LLMs Summarize Input Text on Forerunner Tokens in Hidden States

We first study the existence of input text encoding in hidden states and then explain their linear separability and task relevance in §3.2. For each text-label pair $(x_{t},y_{t})$ (encoding target) sampled from the datasets, we prepend them with $k$ demonstrations, resulting in ICL-style inputs $[x_{1}][s_{1}][y_{1}]\dots[x_{k}][s_{k}][y_{k}][x_{t}][s_{t}][y_{t}]$. These inputs are then fed into an LM to extract the hidden states of a specific token in $[x_{t}][s_{t}][y_{t}]$ from each layer, serving as the ICL inner representations. To assess the quality of these representations as sentence representations, we use the sentence embedding of $x_{t}$ encoded by BGE M3 (Chen et al., ), a SotA encoder-only Transformer, as a “reference” representation and then calculate the mutual nearest-neighbor kernel alignment(^3^33Intuitively, kernel alignment measures similarity between two representations toward the same datasets, and according to Huh et al. (), a higher cross-model kernel alignment usually means a better representation.) (Huh et al., ) between these representations. See Appendix A.1 and A.2 for details.

Forerunner Tokens Encode Input Text Representations. We plot the kernel alignment using 3 types of tokens in Fig. 2 (Left). The forerunner token, while often overlooked in previous work, produces the best input text-encoding, emerging in the early phase (layers 0-28) of the inference process, and keeping a high level to the end of inference. Interestingly, hidden states of label words are not satisfactory input text representations even with a high background value (the result at layer 0, refer to Appendix A.2.1 for details), which is a critical supplement to previous work which suggests the label tokens are pivots for collecting the information of demontrations (Wang et al., ).

Input Text Encoding is Enhanced by Demonstrations. We investigate the influence of contextual in on input text encoding by repeating the experiments with different $k$. As shown in Fig. 2 (Middle), when the demonstrations increase, feature alignment is enhanced, which is counterintuitive since longer preceding texts are more likely to confuse encoding targets. Such findings indicate that LMs (1) utilize contextual information to enhance the input text encoding and (2) correctly segment different demonstrations (detailed operation discussed in Appendix C).

Perplexed Texts are Encoded Worse. We investigate the correlation between kernel alignment and the perplexity of encoding targets with different $k$. Fig. 2 (Right, upper) shows a negative correlation for $k=0$,
that is, LMs generate poorer encodings for more complex input text when no demonstrations are given, which can be identified as an In-weight Learning (IWL) property of the inner text encoding.
While, when demonstrations are given in context (Fig. 2 (Right, lower)), the negative correlation disappears, which suggests that LMs effectively encode more complex samples with the help of demonstrations in context. More discussion about the relationship of classification performance and perplexity is in Appendix E.

The above findings suggest that the inner text encoding is a hybrid process of ICL and IWL: Basic encoding capability presents from LMs weights, and is enhanced by demonstrations in context, which can be a clue to how demonstrations help ICL. Moreover, we are about to illustrate that these encodings are sufficiently informative for ICL tasks and linearly separable, which meets the presumption of simplified models on the linear and well-embedded input features.

### 3.2 Text Summarization is Linear and Task-Relevant but Position-biased

Figure: (a)
Refer to caption: x1.png

Figure: Figure 3: Test results of centroid classifier trained on ICL hidden states. Solid: Centroid classification accuracy, Dotted: Kernel alignment.
Refer to caption: x4.png

Input Text Encoding is Linear Separable and Task-relevant. We train a centroid classifier on hold-out 256 input samples (Cho et al., ), using the hidden states of a specific token in $[x_{t}][s_{t}]$(^6^66We skip the experiments on label tokens because of the leakage of ground-truth label information.) from each layer and then predict the label $y_{t}$ (see Appendix A.3 for details).
The results are shown in Fig. 3. The considerably high classification accuracy of the forerunner token suggests the high linear separabilities of the hidden states in the task-semantic-relevant subspaces since the centroid classifier is linear.
In addition, a similar emerging trend in accuracy and kernel alignment confirms the reliability of the kernel alignment measurement.

Input Text Encoding is Biased towards Position. Ideally, the inner representations of similar queries should be highly similar regardless of their position in ICL inputs to support attention-based operations for classification. To verify this, for each encoding target, we extract the hidden states of forerunner tokens with various numbers of preceding demonstrations. We then calculate the cosine similarity between all possible pairs of the hidden states for the same target or different targets. As shown in Fig. 4, although the overall similarities on the same target are higher than on the different targets, they are both especially higher when their positions are close to each other.
As to be discussed in §5.3, such positional similarity bias may lead to one flaw: demonstrations closer to the query have stronger impacts on ICL (Zhao et al., ; Lu et al., ; Chang & Jia, ; Guo et al., ). The principle of such bias is discussed in Appendix C.

## 4 Induction Circuits in Natural Language Models

Figure: Figure 4: The similarities of ICL hidden states in different positions on layer 24 between the same queries (Left) or two different queries (Right) (on SST-2).
Refer to caption: x5.png

This section mainly shows how LMs utilize the summarized linear text representations in induction circuits with a typical 2-step form (Singh et al., ): Forerunner Token Heads merge the demonstration text representations in the forerunner token into their corresponding label tokens with a selectivity regarding the compatibility of demonstrations and label semantics. Induction Heads copy the information in the label representations similar to the query representations back to the query. Such operations are done on task-specific subspaces, enabling LMs to solve multiple tasks by multiplexing hidden spaces.

### 4.1 Step 2, Forerunner Token Head: Copy from Text Feature to Label Token

This subsection mainly examines and measures the forerunner token heads, which copy the information in the forerunner into label tokens. We investigate the interaction between the forerunner tokens and label tokens, and focus on how the representations are merged, especially when the semantics of labels and text are disjoint, towards an explanation of why ICL are robust to wrong labels.

Text Representations are Copied to Label Tokens. To confirm the existence of the representation copy process, we start by calculating the kernel alignment between the hidden state of forerunner token $s_{t}$ at layer $l$ (the copy source) and that of label token $y_{t}$ at layer $(l+1)$ (the copy target). To suppress the high background values caused by the semantics of labels, we use abstract label tokens $\{\mathrm{``A",``B",``C",}\dots\}$ instead of the original label tokens. The results are shown in Fig. 5 (Left), where the kernel alignment between the hidden states of the label token and the forerunner token gradually increases and then bumps up after the encoding in the forerunner token (described in §3) finished improving. It indicates that the hidden states of the input text representation encoded in the forerunner tokens are merged into their label tokens, suggesting the existence of copy processing from the forerunner token to the label token.

Text Representations are Copied without Selectivity. For each attention head, we extract the attention score $\alpha_{y_{t}\rightarrow s_{t}}$ from a label token $y_{t}$ (as attention query) to the corresponding forerunner token $s_{t}$ (as attention keys). We then mark the head with $\alpha_{y_{t}\rightarrow s_{t}}\geqslant 5/n_{t}$ ($n_{t}$: the length of tokens before $y_{t}$) as a Forerunner Token Head and count them in each layer.
The results are shown in Fig. 5 (Middle, “Correct Label”), where the peak matches the copy period in Fig. 5 (Left). Moreover, to investigate the influence of the correctness of label tokens, we replace $y_{t}$ with a wrong label token(^7^77For example, for a label space of “positive” and “negative”, if $y_{t}$ is “positive”, then replace it to “negative”.), where the results in Fig. 5 (Middle, “Wrong Label”) are almost identical to the correct-label setting, suggesting that the forerunner token heads don’t show selectivity toward the semantic consistency between input text and labels simply merge the input text representations into the label tokens.

Hidden States of Label Tokens are Joint Representations of Text Encodings and Label Semantics. Given the findings above, we probe the content of hidden states of label tokens $[y_{t}]$, i.e., how the text representation interacts with the original label semantics. We first train two centroid classifiers to predict the corresponding label $y_{t}$: (1) $\mathcal{C}_{f}$ trained on the hidden states of forerunner tokens $[s_{t}]$ and (2) $\mathcal{C}_{l}$ trained on the hidden states of label tokens $[y_{t}]$. To check whether the label tokens include the information of forerunner tokens, we use $\mathcal{C}_{f}$ to predict the label on the hidden state of label token $[y_{t}]$ in Fig. 5 (Right, solid). It shows that, during the copy processing, high classification accuracies can be achieved both on the correct label tokens and wrong label tokens, suggesting that the text features in the forerunner tokens can be partly and linearly detected in the label tokens. Moreover, results using $\mathcal{C}_{l}$ (dotted line) shows extreme results, suggesting the label information remains in the label token. So, we can conclude that: hidden states of label tokens are joint representations of label semantics and text representations.

Label Denoising is Conducted on the Overlap of Label Semantics and Text Representations. Notice that in Fig. 5 (Right, solid), compared to the typical results predicted on the forerunner tokens, accuracies are improved on the correct label and suppressed on the wrong label, which suggests that information consistent with the label semantics is easier to be enhanced by the label tokens and vice versa, showing a feature selectivity on the consistency between the text representations and the label semantics. Given the observation that the information on label semantics and text features can be extracted separately and linearly, we can confirm that these two kinds of information are located in different sub-spaces of the hidden states, and linearly merged by the attention operation of forerunner heads. Moreover, given the fact that there is no selectivity is observed in the copy behavior of the forerunner token head (Fig. 5 (Middle)), it is intuitive that the feature selectivity shown in Fig. 5 (Right) comes from the arithmetical interaction of feature vectors on the overlap of sub-spaces between the label semantics and text features, making ICL stable against label noise (Min et al., ). Moreover, as mentioned by Wei et al. (), large models show poorer stability against label noise. We infer that the larger hidden dimensions in larger models lower the overlap between the sub-spaces of label semantics and text representations to reduce the interaction.

Figure: (a)
Refer to caption: x7.png

### 4.2 Step 3, Induction Head: Feature Retrieval on Task Subspace

This subsection examines the existence of the aforementioned induction heads, which retrieve similar label token features as the queries’ forerunner feature, and copy the retrieved features back to the query. We claim the necessity of multi-head attention in this process: correct feature retrieval can only be conducted on the subspace of the hidden space, which is captured by some attention heads.

Induction is Correct in Minority Subspaces. Similar to Fig. 5 (Middle), we mark (1) the attention heads with the sum of attention scores from the query’s forerunner token $s_{q}$ (as attention query) to all the label tokens $[y_{1}],\dots,[y_{k}]$ (as attention keys) in the demonstration more than $5k/n_{t}$ as induction heads, and (2) attention heads with the sum of scores to all the correct label tokens more than $5k/|\mathbb{Y}|n_{t}$ as correct induction heads ($\mathbb{Y}$ is a label space). We show the number of both kinds of induction heads in Fig. 6 (Left, detailed head statistics in Appendix F.1), where a unimodal pattern is observed later than the copy processing of Step 2. Moreover, more than half of the induction heads are not correct ones, suggesting that task-specific feature similarity can only be caught on some induction subspaces (defined by low-rank transition matrix $W_{Q}^{h\top}W_{K}^{h}$ of correct induction head $h$). We enhance this claim in Fig. 6 (Middle) (details in Appendix A.4), where both vanilla attention (without transformation and head split) and attention scores averaged among heads show low assignment on correct label tokens, while some heads show considerable correctness. Considering the average value,
the majority of attention heads almost randomly copy label token information to the query, causing the prediction biased to the frequency of labels in the prompt (Zhao et al., ). As the reason, we infer that the hidden states are sufficient (Fig. 3) but not minimum for ICL, where redundant information interferes with the similarity calculation of attention.

Figure: (a)
Refer to caption: x10.png

Figure: Figure 7: Label representations of $k$ demonstrations visualized on (Left 4) correct and (Right 4) wrong induction head, on one sample of SST-2 (see Appendix F.3). $\circ$: “positive” label, $\times$: “negative” label, $\blacktriangle$: zero vector. Color: attention assigned to query, negative to positive (cartography: Appendix A.5).
Refer to caption: x13.png

Some Induction Subspaces are Task-specific. We check if different tasks share the same induction subspaces based on the overlap of the correct induction heads across different datasets. Given $n_{\mathcal{D}}(h)$, the number of times $h$ is marked as correct induction head on dataset $\mathcal{D}$, the overlap rate $S$ is defined as:

$$ $S(\mathcal{D}_{1},\mathcal{D}_{2})=\frac{2\sum_{\forall h}\mathrm{min}[n_{ \mathcal{D}_{1}}(h),n_{\mathcal{D}_{2}}(h)]}{\sum_{\forall h}n_{\mathcal{D}_{1 }}(h)+n_{\mathcal{D}_{2}}(h)}.$ (1) $$

The results are shown in Fig. 6 (Right), where: (1) A significant overlap of induction heads indicates that a part of correct induction heads is inherent in the model, built by the pre-training process (Reddy, ; Singh et al., ). (2) Such overlap is not fully observed, suggesting that some induction subspaces are task-specific: input texts evoke task-specific attention in induction heads, enabling the anisotropy multiplex of different sub-spaces in the hidden spaces to transmit relevant information for various tasks.
Therefore, we can restore ICL to implicit end-to-end multi-task learning methods with hidden state multiplexing since they also use various task heads on common bottom network layers and informative hidden state (Zhang & Yang, ).

Demonstration Saturates on Induction Subspace. We visualize the demonstrations’ label token representations mapped on the induction subspaces by the transition matrix $W_{Q}^{h\top}W_{K}^{h}$ and principal component analysis in Fig. 7, indicating: (1) Compared to a correct induction head, a wrong induction head is easier to map label representations linearly inseparably. (2) In the early stage of demonstration ($k=1\rightarrow 2$), when a new demonstration is given, the morphology of attention assignment towards query changes significantly (shown as background color in Fig. 7; see §A.5 for details), while in the late stage ($k=15\rightarrow 16$), attention assignment morphology is stable. This can explain the demonstration saturation (Agarwal et al., ; Bertsch et al., ): the performance is submodular against the demonstrations. Intuitively, since demonstrations follow a prior distribution, representation of a new demonstration is likely to be located within the closure of existing demonstrations, making it less contributable to the attention assignment in the induction subspace.

## 5 Putting Things Together

So far, we have revealed the existence of the circuit with 3 steps, organized by the sequential inference process among Transformer layers. In this section, we find that the circuit is dominant in the ICL inference, while some bypass mechanisms activated by residual connection assist ICL inference. Moreover, a series of phenomena observed in ICL is successfully explained by the circuit.

### 5.1 Ablation Analysis

**Table 1: Accuracy variation (%) with each inference step ablated on Llama 3 8B. Small numbers are controlled results of randomly ablating equivalent amounts of connections. Ablations are applied from the bottom to the top layers, and results with various ablated layers are reported.**
| # | Attention Disconnected<br>Key $\rightarrow$ Query | Affected Layers Ratio (from layer 1) |  |  |  |
| --- | --- | --- | --- | --- | --- |
| 25% | 50% | 75% | 100% |  |  |
| 1 | None (4-shot baseline) | $\pm 0$ (Acc. $68.55$) |  |  |  |
| – Step1: Summarize – |  |  |  |  |  |
| 2 | Demo. Texts $x_{i}$ $\rightarrow$ Forerunner $s_{i}$ | $-4.98$<br>$-0.85$ | $-15.82$<br>$-1.33$ | $-23.43$<br>$-4.65$ | $-30.60$<br>$-1.50$ |
| 3 | Query Texts $x_{q}$ $\rightarrow$ Forerunner $s_{q}$ | $-13.87$<br>$-0.13$ | $-21.10$<br>$-0.10$ | $-24.74$<br>$-0.68$ | $-28.38$<br>$-0.62$ |
| – Step2: Semantics Merge – |  |  |  |  |  |
| 4 | Demo. Forerunner $s_{i}$ $\rightarrow$ Label $y_{i}$ | $-2.24$<br>$+0.07$ | $-3.45$<br>$-0.20$ | $-3.39$<br>$+0.10$ | $-3.42$<br>$-0.26$ |
| – Step3: Feature Retrieval & Copy – |  |  |  |  |  |
| 5 | Label $y_{i}$ $\rightarrow$ Query Forerunner $s_{q}$ | $-5.14$<br>$+0.07$ | $-10.03$<br>$-0.07$ | $-11.36$<br>$-0.03$ | $-10.22$<br>$-0.03$ |
| Reference Value |  |  |  |  |  |
| 6 | Zero-shot | $-17.90$ (Acc. $50.65$) |  |  |  |
| 7 | Random Prediction | $-36.05$ (Acc. $32.50$) |  |  |  |

To demonstrate that our 3-phase circuit dominates or at least participates in ICL process, we disconnect the related attention connection of each step in the proposed circuit, and test the accuracies without such connections as shown in Table 1. The results show that when the non-trivial connections designated by the proposed circuit are ablated, accuracies of ICL significantly decrease, supporting the existence of our circuit. However, the result doesn’t fully match expectations, for example, the result without induction (line 5) should be consistent with zero-shot (line 6), since all the expected communication from demonstration to query is intercepted, but that’s not the case; and the contribution of Step 1 in later layers are unexpectedly high, indicating the existence of some bypass mechanisms parallelly contributing to ICL accuracies.

### 5.2 Bypass Mechanism

Motivated by the ablation results, we believe that several mechanisms including our circuit run parallelly for ICL, since the residual connection supports complex paths among layers and attention heads. We list some possible bypasses and plan a complete enumeration as future work.

Figure: Figure 8: Dynamics and deserialization of magnitudes of proposed 3 inference steps (cartography details: Appendix A.6).
Refer to caption: x15.png

Parallel Circuits. Multiple 3-step circuits can execute in parallel, that is, one layer can assign multiple inference functions to different heads, causing dispersion and deserialization as shown in Fig. 8, where a narrow (fewer heads) and deep (more layers) model is more likely to generate localized inference, and vice versa.

Direct Decoding. Residual connection to output embedding allows intermediate hidden states to be decoded directly. Intuitively, a shortcut from Step 1 encodings to the LM head enables ICL with zero-shot capacities, since we have confirmed that encoded representations are informative for ICL tasks, while the decoding methods should be selected carefully (Cho et al., ) (e.g. with essential calibration). On the other hand, shortcuts from insufficiently encoded features may lead to meaningless information decoded by language model heads, causing prediction bias, i.e., even if no query is given, ICL still returns unbalanced results (Zhao et al., ) decoded from tokens of prompt template (see Appendix D).

**Table 2: Accuracy drop with shortcut ablated.**
| Attention Disconnected | 25% | 50% | 75% | 100% |
| --- | --- | --- | --- | --- |
| Forerunner $s_{1:i}$ $\rightarrow$ Forerunner $s_{i:q}$ | $-1.30$<br>$-0.00$ | $-0.75$<br>$-0.16$ | $-0.78$<br>$-0.16$ | $-1.56$<br>$-0.71$ |

Shortcut Induction. Note that a $k$-shot ICL input sequence always contains a $(k-1)$-shot sequence, where the $k$-th forerunner (once served as the query) is previously processed. So every forerunner can directly retrieve previously processed forerunners of demonstrations to copy their induction results directly. The non-trivial result (Table 2) with all forerunners disconnected from each other confirms such infer.

### 5.3 Explaination towards Observed ICL Phenomena

Difficulty-based Demonstration Selection. In §3.1, we find that in the zero-shot scenario, perplexed texts are harder to be encoded, which explains the observation of PPL-ICL (Gonen et al., ) selecting demonstrations with lower perplexity. Moreover, while the demonstrations increase, LMs can encode more complex inputs with diverse information to update the attention assignment shown in Fig. 7, making it beneficial to input harder demonstrations later, which explains the ICCL (Liu et al., ), which build demonstrations sequence from easy to hard.

Prediction Bias. (1) Contextual Bias: As shown in §5.2 and Appendix D, direct decoding insufficiently encoded information adds meanless logits into LM’s output, causing a background prediction value even if no queries are given (named bias). (2) Position Bias: As shown in §3.2, closer input texts are encoded more similarly, so label tokens near the query have more similar information to the query, causing more attention assignment in the induction processing, so that more influences on the prediction. (3) Frequency Bias: As shown in §4.2, in the induction, some attention heads are without selectivity towards labels, causing an averaged induction from label tokens to the query, triggering a prediction bias towards the label frequency in the demonstration, even if their contribution (absolute value of attention score on label tokens) is small. All three biases are observed by Zhao et al. (), and can be removed by ICL calibration methods.

The Roles and Saturates of Demonstrations. It is well known that demonstrations improve the performance of ICL. We decompose such performance improvement into 2 parts: (1) demonstrations help early layers encode better (§3.1), and (2) more demonstrations provide larger label token closure, enabling more accurate attention assignment (§4.2), while the volume of such closure is submodular to demonstrations, causing the saturates of ICL performance towards demonstrations.

The Effect of Wrong Label. It is well-known that the label noise is less harmful in ICL (Min et al., ) than in gradient-based learning (Zhang et al., ). We have explained in §4.1 that ICL implies labels denoise to stabilize ICL against label noise, while weakened by dimensionality.

## 6 Conclusion and Discussion

Conclusion. In summary, this paper restores ICL inference into 3 basic operations and confirms their existence. Careful measurements are conducted to capture and explain various phenomena successfully. Moreover, ablation studies show the proposed inference circuit dominates and reveals the existence of bypass mechanisms. We hope this paper can bring new insight into ICL practice.

**Table 3: Performance of full and layer-pruned ICL inference.**
| Inference | Acc. | Para.# | Speed |
| --- | --- | --- | --- |
| Full + LM Head | 66.19% | 70.6B | 1$\times$ |
| Full + Cent. | 83.24% | 69.5B | 1.00$\times$ |
| Layer34 + LM Head | 49.29% | 32.7B | 2.16$\times$ |
| Layer34 + Cent. | 84.27% | 31.2B | 2.38$\times$ |

The Role of Early and Later Layers. Our framework and Fig. 3 show: encoding result of Step 1 can be directly used for classification with reliable decoding, and later transformer layers are not contributing to centroid classification accuracies, leading to a taxonomy of Encoding for Step 1 and Output Preparation for Step 2 and 3. LMs complete multi-task classification implicitly in early layers, and verbalize it by merging task-specific label semantics in later layers. Therefore, we suggest removing some top layers and using a centroid classifier (Cho et al., ) to accelerate ICL inference as shown in Table 3 and Appendix D.

Pre-training Possibility from Natural Language Data. A large gap can be considered between such a precise circuit and gradient descent pre-training on the wild data. However, we believe the wild training target contains the ICL circuit functionally. Based on the previous works finding trainability of ICL on linear representation-label pairs (Chan et al., ; Reddy, ; Singh et al., ), we speculate that in early training step, Transformers learn to extract linear representations shown in §3 from wild data (Appendix B), serving as the training input of later layers to evoke the emergence of induction heads with the same mechanism shown in aforementioned previous works. Moreover, our conclusion of Step 3 highlights the input data requirements for the later layers: These data should activate the multiplex of hidden space, i.e., it should implicate multi-task classification with a wide distribution, which is consistent with the aforementioned previous works.

Limitations. (1) These 3 basic operations are not functionally indivisible. Ideally, one can reduce every operation in ICL inference to the interconnection of special attention heads to ulteriorly examine how the operating subspaces interact between steps. (2) Even though we have some insights into how pre-training promotes ICL in natural language models, its detailed dynamics are still unknown. One can start by decomposing pre-training targets into implicit tasks, and examine how these tasks can evoke the occurrence of the 3-step inference operations. (3) We only focus on classification tasks, while we believe that our findings can be applied to non-classification tasks, efforts are still needed to fill the gap.

## Appendix A Experiment Details and Settings

### A.1 Detailed Overall Experimental Settings

Prompt Template. We conduct experiments on a specific prompt template for each dataset as shown in Table 4. Moreover, similar to typical ICL practices, we reduce the label into one token to simplify the prediction decoding. The reduced label tokens are also shown in Table 4.

Quantization. In our experiments, we use BitsAndBytes(^8^88[https://huggingface.co/docs/bitsandbytes/main/en/index](https://huggingface.co/docs/bitsandbytes/main/en/index)) to quantize Llama 3 70B and Falcon 40B to INT4. For the other models, full-precision inference is conducted.

**Table 4: Prompt templates used in this paper.**
| Dataset | Prompt Template (Unit) | Label Tokens |
| --- | --- | --- |
| SST-2 | sentence: <input sentence> sentiment: <label token> $\backslash$n | negative, positive |
| MR | review: <input sentence> sentiment: <label token> $\backslash$n | negative, positive |
| FP | sentence: <input sentence> sentiment: <label token> $\backslash$n | negative, neutral, positive |
| SST-5 | sentence: <input sentence> sentiment: <label token> $\backslash$n | poor, bad, neutral, good, great |
| TREC | question: <input sentence> target: <label token> $\backslash$n | short, entity, description, person, location, number |
| AGNews | news: <input sentence> topic: <label token> $\backslash$n | world, sports, business, science |

Other. All the experiment materials (models and datasets) are loaded from huggingface. For the BGE M3, we use its pooler_output as the output feature.

### A.2 Calculation of Mutual Nearest-neighbor Kernel Alignment

In this paper, we need to measure the similarity between features from two different models or model layers. There are many approaches (Klabunde et al., ), and we use mutual nearest-neighbor kernel alignment (Huh et al., ), which is relatively efficient and accurate, calculated as follows to measure the similarity of representation from the same object set $\mathcal{X}=\left\{x_{i}\right\}_{i=1}^{n}$ in different feature spaces.

Given a representation mapping $\delta:\mathcal{X}\rightarrow\mathbb{H}^{d}$ from the objects to a space where similarity measurement $\left\langle\cdot,\cdot\right\rangle:\mathbb{H}^{d}\times\mathbb{H}^{d}
\rightarrow\mathbb{R}$ is defined, we can calculate the similarity map from dataset $\mathcal{X}$ as $\mathcal{S}_{\delta}\in\mathbb{R}^{n\times n}$, where the elements are $\mathcal{S}_{\delta|i,j}=\langle\delta\left(x_{i}\right),\delta\left(x_{j}
\right)\rangle$, especially, we axiomatic define $\left\langle x,x\right\rangle=1$, so we set the diagonal element $\mathcal{S}_{\delta|i,i}\fallingdotseq 0$ since they are trivial values.

Given two encoding $\delta_{1}$ and $\delta_{2}$, two similarity map can be calculated as $\mathcal{S}_{\delta_{1}}$ and $\mathcal{S}_{\delta_{2}}$ on the same object set $\mathcal{X}$. For each line vector index $i=1,2,\dots,n$ in $\mathcal{S}_{\delta_{1}}$, we select the index of top-$k$ elements from greater to lower as $\mathrm{top}_{k}\left(\mathcal{S}_{\delta_{1}|i}\right)$. Similarly, we get $\mathrm{top}_{k}\left(\mathcal{S}_{\delta_{2}|i}\right)$ from $\mathcal{S}_{\delta_{2}}$.

Then, we calculate the kernel alignment for sample $i$ as:

$$ $\mathrm{KA}_{\mathcal{X}}(\delta_{1},\delta_{2})_{i}=\frac{\left|\mathrm{top}_ {k}\left(\mathcal{S}_{\delta_{1}|i}\right)\cap\mathrm{top}_{k}\left(\mathcal{S }_{\delta_{2}|i}\right)\right|}{k}.$ (2) $$

The kernel alignment for dataset $\mathcal{X}$ is the average on each $\mathrm{KA}_{\mathcal{X}}(\delta_{1},\delta_{2})_{i}$.

Implementation. In our experiments, we choose cosine similarity as the $\langle\cdot,\cdot\rangle$, and $k\fallingdotseq 64$. According to experiment settings in §2.2, $n\fallingdotseq 512$ is defined, and a randomlized matrix $\mathcal{S}$ have $\mathrm{KA}=64/512=0.125$ as the random baseline.

Figure: Figure 9: Distributions (clusters) of representations generated by: Left: encoder model (BGE), clustering w.r.t. the label; Middle: ICL on the forerunner token, where representations gather into one point when no Transformer operation is conducted; Right: ICL on the label token, where representations gather into points w.r.t. label (using a 2-way example) when no Transformer operation is conducted, causing a high background value.
Refer to caption: extracted/5905049/Figure/backgroundvalue.png

#### A.2.1 Background Values of Kernel Alignment: Label Token - Text Encoding.

Given two specific tokens $x_{i}$ and $x_{j}$ where kernel alignment is calculated from different ICL-styled input sequences $p_{i}$ and $p_{j}$, in a specific layer of a decoder Transformer, the representations can be written as $\delta(x)=e(x)+\epsilon(p)$, where $e(x)$ are the embedding vector of the token $x$, and $\epsilon(p)$ are the residual side-flow w.r.t the context $p$.

Intuition. As shown in Fig. 9, in the hidden states of ICL, the hidden state on the label token has a prior clustering, making it naturally similar to the representation generated by the encoder model, even if the ICL process does not encode it sufficiently. So, at layer 0, since the model is not able to perform any encoding in this layer, the kernel alignment on the forerunner is on a random baseline value of 0.125, but the value on the label token will be greater. In the case where (1) BGE generates fully linearly separable clusters with sufficient inter-cluster distance, and (2) the number of samples for each label is not less than 64, this upper bias can be expected to be $0.125(|\mathbb{Y}|-1)$ (proof omitted). Intuitively, such bias can propagate along the residual network to every layer, making the results of any layer unfaithful.

Similarity on Forerunner Tokens. The cosine similarity between $\delta(x_{i})$ and $\delta(x_{j})$, where the $x_{i}$ and $x_{j}$ are forerunner tokens of the input sequence can be written as:

$$ $\displaystyle\left\langle\delta(x_{i}),\delta(x_{j})\right\rangle$ $\displaystyle=\left\langle e(x_{i})+\epsilon(p_{i}),e(x_{j})+\epsilon(p_{j})\right\rangle$ (3) $\displaystyle=\frac{\left\langle e(x_{i}),e(x_{j})\right\rangle+\left\langle e (x_{i}),\epsilon(p_{j})\right\rangle+\left\langle e(x_{j}),\epsilon(p_{i}) \right\rangle+\left\langle\epsilon(p_{i}),\epsilon(p_{j})\right\rangle}{\left \|e(x_{i})+\epsilon(p_{i})\right\|_{2}\left\|e(x_{j})+\epsilon(p_{j})\right\|_ {2}}.$ (4) $$

Denote $B_{i,j}=\left\langle e(x_{i}),\epsilon(p_{j})\right\rangle+\left\langle e(x_{j
}),\epsilon(p_{i})\right\rangle$, $C_{i,j}=\left\|e(x_{i})+\epsilon(p_{i})\right\|_{2}\left\|e(x_{j})+\epsilon(p_
{j})\right\|_{2}$, and notice that $x_{i}=x_{j}$ since they are forerunner tokens which is kept consistent in experiments, we have:

$$ $\left\langle\delta(x_{i}),\delta(x_{j})\right\rangle=\frac{1+B_{i,j}+\left \langle\epsilon(p_{i}),\epsilon(p_{j})\right\rangle}{C_{i,j}}.$ (5) $$

Similarity on Label Tokens. Similarly, the cosine similarity between $\delta(y_{i})$ and $\delta(y_{j})$ on label tokens can be written as:

$$ $\left\langle\delta(y_{i}),\delta(y_{j})\right\rangle=\frac{\left\langle e(y_{i }),e(y_{j})\right\rangle+B_{i,j}+\left\langle\epsilon(p_{i}),\epsilon(p_{j}) \right\rangle}{C_{i,j}}.$ (6) $$

Encoding on Label Tokens Enhances the Similarity with Same Labels. Given $k=1$ for simplicity, the probability $\mathrm{top}_{1}\left(\mathcal{S}_{\delta|i}\right)$ selects a sample with the similar label with $i$-th sample on the forerunner token can be written as:

$$ $\displaystyle\mathrm{P}_{F}\left[y_{i}=y_{\mathrm{top}_{1}\left(\mathcal{S}_{ \delta|i}\right)}\right]$ $\displaystyle=r_{y_{i}}\frac{\mathbb{E}_{j|y_{i}=y_{j}}\left[\left\langle \delta(x_{i}),\delta(x_{j})\right\rangle\right]}{\mathbb{E}_{j}\left[\left \langle\delta(x_{i}),\delta(x_{j})\right\rangle\right]}$ (7) $\displaystyle\approx r_{y_{i}}\frac{1+\mathbb{E}_{j|y_{i}=y_{j}}\left[B_{i,j} \right]+\mathbb{E}_{j|y_{i}=y_{j}}\left[\left\langle\epsilon(p_{i}),\epsilon(p _{j})\right\rangle\right]}{1+\mathbb{E}_{j}\left[B_{i,j}\right]+\mathbb{E}_{j} \left[\left\langle\epsilon(p_{i}),\epsilon(p_{j})\right\rangle\right]},$ (8) $$

where the $r_{y_{i}}$ is the label ratio of $y_{i}$. Similarly, the probability on the label token can be written as:

$$ $\displaystyle\mathrm{P}_{L}\left[y_{i}=y_{\mathrm{top}_{1}\left(\mathcal{S}_{ \delta|i}\right)}\right]$ $\displaystyle\approx\frac{r_{y_{i}}(1+\mathbb{E}_{j|y_{i}=y_{j}}\left[B_{i,j} \right]+\mathbb{E}_{j|y_{i}=y_{j}}\left[\left\langle\epsilon(p_{i}),\epsilon(p _{j})\right\rangle\right])}{\begin{multlined}r_{y_{i}}\left(1+\mathbb{E}_{j|y_ {i}=y_{j}}\left[B_{i,j}\right]+\mathbb{E}_{j|y_{i}=y_{j}}\left[\left\langle \epsilon(p_{i}),\epsilon(p_{j})\right\rangle\right]\right)\\ +\left(1-r_{y_{i}}\right)\left(\left\langle e(y_{i}),e(y_{j})\right\rangle+ \mathbb{E}_{j}\left[B_{i,j}\right]+\mathbb{E}_{j}\left[\left\langle\epsilon(p_ {i}),\epsilon(p_{j})\right\rangle\right]\right)\end{multlined}r_{y_{i}}\left(1 +\mathbb{E}_{j|y_{i}=y_{j}}\left[B_{i,j}\right]+\mathbb{E}_{j|y_{i}=y_{j}} \left[\left\langle\epsilon(p_{i}),\epsilon(p_{j})\right\rangle\right]\right)\\ +\left(1-r_{y_{i}}\right)\left(\left\langle e(y_{i}),e(y_{j})\right\rangle+ \mathbb{E}_{j}\left[B_{i,j}\right]+\mathbb{E}_{j}\left[\left\langle\epsilon(p_ {i}),\epsilon(p_{j})\right\rangle\right]\right)}$ (11) $\displaystyle\geqslant\mathrm{P}_{F}\left[y_{i}=y_{\mathrm{top}_{1}\left( \mathcal{S}_{\delta|i}\right)}\right].$ (12) $$

That is, the inputs with the same labels with $x_{i}$ are easier to be selected into the $\mathrm{top}_{1}\left(\mathcal{S}_{\delta|i}\right)$. Notice that we make approximations here: (1) we consider the $\mathbb{E}_{j|y_{i}=y_{j}}\left[C_{i,j}\right]\approx\mathbb{E}_{j}\left[C_{i,
j}\right]$, i.e., the 2-norm of two encoding vectors are considered equal granted by normalization used in Transformer. (2) We consider the context term $c$ in the label token scenario the same as the forerunner scenario since the difference is only a label token, which usually occupies quite a small part of the input sequence.

Background Values of Kernel Alignment. According to the explanation above, it is intuitive to conclude that $\mathrm{top}_{k}\left(\mathcal{S}_{\delta|i}\right)$ from label tokens is easier to cluster samples with the same label as $y_{i}$. Moreover, a well-pre-trained encoder can catch the prior distribution determined by these labels, and also cluster samples with the same label, causing a high similarity of similarity map, so that a high but unfaithful kernel alignment as the background value from the similarity on $e(y)$ but not $\epsilon(p)$. An intuitive verification of such background value is shown in the Fig. 2 (Left), where the “Label Token” curve has a high value in layer 0 with $\epsilon(p)=0$. However, the background value also indicates that the representation generated by BGE correctly clusters the samples, confirming its reliability.

### A.3 Training and Inference of Centroid Classifier

In this paper, we follow Cho et al. () to train centroid classifiers as a probe toward hidden states of LMs. In detail, given the LM’s hidden states set $\left\{h_{i}^{l}\right\}_{i=1}^{m}$ of the selected tokens (according to the experimental setting, the last label token or forerunner token) in layer $l$ from an [input prompt]-[query label] set $\mathcal{Z}=\left\{\left(p_{i},y_{i}\right)\right\}_{i=1}^{m}$, where the labels are limited in label space $\mathbb{Y}$, in the training phase, we calculate the centroid of the hidden state $\bar{h}^{l}_{y}$ for each label respectively:

$$ $\bar{h}^{l}_{y}=\mathbb{E}_{i|y_{i}=y}\left[h_{i}^{l}\right].$ (13) $$

In the inference phase, we extract the equitant(^9^99Equitant refers to hidden states from the same layer and token type. While, in experiments shown in Fig. 5 (Right), we don’t keep the token type consistent.) hidden state $h_{t}^{l}$ as the training phase from the test input, and calculate the similarity between $h_{t}^{l}$ and the centroids calculated above. Then, we choose the label of the most similar centroids as the prediction:

$$ $\mathcal{C}(h_{t}^{l})=\mathop{\mathrm{argmax}}\limits_{y}\left\langle h_{t}^{ l},\bar{h}^{l}_{y}\right\rangle.$ (14) $$

Implementation. In our experiments, we set training sample number $m\fallingdotseq 256$, similarity function $\left\langle a,b\right\rangle=-\|a-b\|_{2}$.

### A.4 Cartography Details of Fig. 6 (Middle)

In Fig. 6 (Middle), we define a Correct Label Assignment, here we introduce how this measurement is calculated. Suppose we have an attention score $\mathcal{A}_{W,f}(K,Q)$ calculated as:

$$ $\mathcal{A}_{W,f}\left(K,Q\right)=f\left(Q^{\top}WK\right),$ (15) $$

with hidden dimensionality of $d$, give a certain layer, $K\in\mathbb{R}^{d\times n_{t}}$ is the hidden state matrix of full context, $Q\in\mathbb{R}^{d\times 1}$ is the hidden state of query’s forerunner token ($Q^{\top}=K^{\top}_{n_{t}}$), $f:\mathbb{R}^{n_{t}}\rightarrow\Omega^{n_{t}}$ is a normalization mapping from $n_{t}$-dimensional real vector to $n_{t}$-dimensional probability vector (usually $\mathrm{softmax}$ function), the $W$ is a linear kernel, usually $W_{Q}^{h\top}W_{K}^{h}$ for multi-head attention or $\mathrm{I}=\mathrm{diag\left(\mathbbold{1}^{n_{t}}\right)}$ for vanilla attention.

For one input sample, given the token-index set of label tokens as $\mathcal{L}$, the token-index set of label tokens which is the same as the query’s ground truth label as $\mathcal{L}^{+}$, we define the Correct Label Assignment (CLA) of one sample as:

$$ $\mathrm{CLA}_{W,f}(K,Q,\mathcal{L},\mathcal{L}^{+})=\frac{\sum_{i\in\mathcal{L }^{+}}\mathcal{A}_{W,f}\left(K,Q\right)_{i}}{\sum_{i\in\mathcal{L}}\mathcal{A} _{W,f}\left(K,Q\right)_{i}}.$ (16) $$

Intuitively, CLA reflects the accuracy of attention computation $\mathcal{A}_{W,f}$ towards label tokens on one input. For an input set built from a dataset, we calculate the averaged $\mathrm{CLA}$ on these inputs, and repeat in every layer to plot a curve of Averaged CLA against layer numbers. Specifically:

(1) Vanilla attention. We assign $W\fallingdotseq\mathrm{I}$, $f$ to linear normlization.

(2) Best Induction Head. For each attention head $h$, we assign $W^{h}\fallingdotseq W_{Q}^{h\top}W_{K}^{h}$, $f\fallingdotseq\mathrm{softmax}$. For each input, we calculate $\max\limits_{h}\mathrm{CLA}_{W^{h},f}\left(K,Q,\mathcal{L},\mathcal{L}^{+}\right)$ as the result for single input.

(3) Head Average. For each attention head $h$, we assign $W^{h}\fallingdotseq W_{Q}^{h\top}W_{K}^{h}$, $f\fallingdotseq\mathrm{softmax}$. For each input, we calculate $\sum_{h}\mathrm{CLA}_{W^{h},f}\left(K,Q,\mathcal{L},\mathcal{L}^{+}\right)/|
\mathcal{H}|$, where the $|\mathcal{H}|$ is the amount of heads in current layer, as the result for single input.

Note that we do not consider the absolute value of attention assignment on label tokens in this experiment, and most of the heads have little scores assigned to the label (Fig. 6 (Left)), therefore, although the average assignments tend to be average, this result shown in Fig. 6 (Middle) does not contradict the phenomenon that ICL can achieve high accuracy.

### A.5 Cartography Details of Fig. 7

For Fig. 7, we input one sample from SST-2 into Llama 3 70B, take the output of layer 30 on the label tokens to span a matrix $K_{\mathcal{L}}$, and map them by $W_{Q}^{h\top}W_{K}^{h}$ of head 32 (the best induction heads in this layer) and 9 (the worst induction heads) of layer 31 (the layer with the most correct induction heads), respectively. We visualize the distribution of these mapped $W_{Q}^{h\top}W_{K}^{h}K_{\mathcal{L}}$, we conduct principal component analysis on them, and plot them on the plane of the first two components.

For each point $q\in\mathbb{R}^{2}$ on the principal component plane, we calculate the attention assignment as follows. Give the index set of “positive” label token in $K_{\mathcal{L}}$ as $\mathcal{L}^{+}$, the index set of “negative” label token as $\mathcal{L}^{-}$, we calculate the attention assignment, which can be an estimate of ICL prediction (Wang et al., ), as:

$$ $\mathrm{AttAssign}(q)=\sum_{i\in\mathcal{L}^{+}}q^{\top}W_{Q}^{h\top}W_{K}^{h} K_{\mathcal{L}|i}-\sum_{i\in\mathcal{L}^{-}}q^{\top}W_{Q}^{h\top}W_{K}^{h}K_{ \mathcal{L}|i}.$ (17) $$

We map this value to the degree of blue color of each pixel. The larger the positive value, the bluer it is, and the smaller the negative value, the redder it is.

### A.6 Cartography Details of Fig. 8

For Fig. 8, we calculate the magnitude of Step 1 as the finite differences of kernel alignment in Fig. 2 (Left, Forerunner Token of Label). We directly use the head counting of Fig. 5 (Middle) and Fig. 6 (Left) as the magnitude of Steps 2 and 3. These data are regularized and converted into transparencies.

## Appendix B LM Pre-training Dynamics Measured by ICL Circuit

We extend the discussion of pre-training dynamics in §6 here.

Figure: Figure 10: Operating magnitude (normalized) and ICL accuracy w.r.t. pre-training steps on Pythia 6.9B and SST-2.
Refer to caption: x16.png

One can divide a self-regression model into an early part and a later part, where the early part encodes the input into a hidden representation, and the later part decodes the hidden representation back to the input. So, the training object can also be divided into an encoding loss and a decoding loss. According to the discussion in §6, the summarization operation (Step 1) can be classified as encoding, and the other two steps of the induction circuit can be classified as decoding. Intuitively, since the decoding operations require the encoding results as input, unless the encoding operation converges to a stable output, the decoding can not be trained since the input-output mapping is noised, causing unstable gradients to interfere with the training (Liu et al., ).

We confirm such inference by a measurement in Pythia 6.9B (Biderman et al., ) as shown in Fig 10, where: (1). The magnitude of the 3 operations is emergent in the early phase of pre-training (less than 10k steps), and is monotonically increasing, while the encoding operation has the fastest growth rate. (2). ICL capacity appearance after all three operations reaches a high level (around 50k steps, notice that the random accuracy is 0.5), while the curve morphology of the operating magnitude against the layer number (shown in Fig. 11) is convergence to the last training step and also the main results in this paper. Such results suggest that: LMs start to produce the inner encoding in the very early steps of the pre-training, and can be an important fundamental in building the subsequent induction circuits, as explained in the previous works mentioned in §2.1.

### B.1 Data Distribution Requirement Explained by Hidden State Multiplex

Figure: (a)
Refer to caption: x17.png

Moreover, the hidden space multiplexing in the induction operation observed in this paper can give a prototypical and phenomenological conjecture for the data distribution requirement found in the previous works (Olsson et al., ; Reddy, ; Singh et al., ), where data with a large label space and various tasks can promote ICL and suppress In-weight Learning (IWL), and vice versa. Intuitively, suppose the encoding inputted into the later layers is clustered by their labels (similar to the well-embedded input styles in the works above, confirmed in Fig. 3). In that case, we can say a cluster center is the eigen-subspace of the corresponding label. Since attention only conducts dot-multiplication operations, let us assume that these eigen-subspaces are radially distributed.

Figure: Figure 12: Attention matrix visualized on layer 2, head 53 in Llama 3 70B from an input case.
Refer to caption: extracted/5905049/Figure/appendix_segmentation/segmentation_index1_3.png

During the training, (1) When the label space is small, the trained attention heads only need to extract the projected length of the query on each label eigen-subspace. For each label, such operation has a parameters’ analytical solution with (encoding kernel) $W_{Q}^{\top}W_{K}=I$ and (decoding transformation) $W_{O}W_{V}=o_{y}^{\top}e_{y}$, where $o_{y}$ is the label token’s output embedding, and $e_{y}$ is the label’s eigen-subspace. From such an operation, theoretically, one layer can handle at most $|\mathcal{H}|$ labels, where $|\mathcal{H}|$ is the head amounts. While, considering the sparsity of these eigen-subspaces, such an upper bound can be increased to $d^{\prime}|\mathcal{H}|$ by multiplex one head to decode an orthogonal group of labels with orthogonal eigen-subspaces of $\mathcal{E}=[e_{y_{1}};e_{y_{2}};\dots;e_{y_{d^{\prime}}}]$ and orthogonal output embedding $\mathcal{O}=[o_{y_{1}};o_{y_{2}};\dots;o_{y_{d^{\prime}}}]$, where $d^{\prime}$ is the inner dimension of attention head, with decoding transformation $W_{O}W_{V}=\mathcal{O}^{\top}\mathcal{E}$. (2) When the label space expands(^10^1010Notice that such a situation can also occur when the orthogonality between eigen-subspaces or output embeddings is lost. A common situation is that the variance of the cluster increases, creating confusion within the decoding space of the attention head.), the decoding transformation can not distinguish all the clusters since the $W_{O}W_{V}$ is low-rank. Driven by the training loss, the model can choose to transform the encoding kernel to focus on catching the most similar label tokens with the query, and copy the label tokens’ information back to the query. As a result, one attention head can catch at most $d^{\prime}$ groups of label tokens mapped collinearly by the encoding kernel (note that this set of labels may not appear simultaneously in the context, so confusion can be avoided), and the common space of these label words become the induction subspace shown in §4.2.

Figure: (a)
Refer to caption: extracted/5905049/Figure/appendix_segmentation/segmentation_index1_1.png

Our other conjecture is that the ICL training endpoint is thermodynamically stable (with a lower loss), and in contrast, the IWL training endpoint is kinetically stable (with a more accessible training trajectory). Moreover, the IWL training object can be a precursor of ICL training, since the total number of labels fed into the model gradually increases with the data. So, we can hypothesize that: when the metastable state is disturbed by some condition, such as the appearance of rare or noisy labels, the training can show a phase transition toward a thermodynamically stable state.

Notice that this section is our hypothesis based on the results of this paper, which should be empirically validated in future work. In addition, we still need to find implicit input-label tuples in wild data, which will also be addressed in future work.

## Appendix C Can LMs Segment ICL Prompt?

**Table 5: Accuracy drop with delimiters removed / modified from prompts on SST-2.**
| Template Modification | Acc. (%) |
| --- | --- |
| None (Table 4) | 91.60 |
| - w/o “$\backslash$n” | 93.36 |
| - w/o “:” | 85.74 |
| - w/o “sentence:”, “sentiment:” | 79.10 |
| - w/o all above | 50.98 |
| - “:” $\rightarrow$ “hello” | 78.91 |
| - “:” $\rightarrow$ “@” | 91.41 |
| - “:” $\rightarrow$ “positive” | 71.48 |
| (Random) | 50.00 |

The experiments in §3.1 imply that LMs conduct effective segmentation on ICL-styled inputs, enabling LMs to block the interference of preceding demonstrations in the input text encoding operation. Here, as a prototypical discussion, we confirm the existence of segmentation and then reveal that such segmentation can be done in very early layers from an attention operation focusing on some specific segmentation tokens in the inputs.

As a preliminary observation, we visualize the attention scores with the last forerunner token as the attention queue at layer 21 (a layer with high encoding magnitude, refer to Fig. 2) from an input case, as shown in Fig. 13 (Left), where most of the attention heads are focused on the query text. The visualization suggests that encoding operations are localized into the query.

Although position embedding inserts sufficient positional information to hidden states and enables attention heads to identify nearby tokens, we believe that position embedding is insufficient to accurately segment the various input parts of uncertain lengths. We hypothesize that LM focused on natural delimiters (e.g. “$\backslash$n”, “:”) in the input during the early stages of inference, and visualization in Fig. 13 (Right) supports such hypothesis: in layer 2, most of the attention heads focus on the natural delimiters, and another visualization in Fig. 12 shows that all attention queries (not only the forerunner token) exhibit similar separator-focusing behavior, suggesting that: some attention heads merge all the preceding delimiters’ representation into every token as delimiter-based positional encoding, making the representations of tokens with the same number of preceding delimiters similar, while differentiating the representations of tokens with different numbers of preceding delimiters. In the subsequent inference process, LM can utilize these delimiter-based positional encodings for localization operations. Such observation is also consistent with Fig. 4.

Furthermore, we empirically demonstrate that delimiters have significant saliency towards ICL accuracies in Table 5 (upper), experimented by removing them from prompt templates. Interestingly, the trial to completely remove these delimiters from the prompt yielded almost random results, even though these inputs still conform to the primary form of ICL. A reliable reason can be that: The missing delimiter interferes with the encoding operation (Step 1) on both demonstrations and queries, so that completely disrupts the ICL process.

The scale of such a segmentation operation can surprise one since more than half of the heads focus on the segmenting operation as shown in Fig. 13 (Right). However, as an assumption, we want to argue that dividing the input text into local segmentation is a crucial step in language modeling, so, functionally, LM has sufficient motivation to focus on segmenting during the training process. Moreover, based on the above principles, as long as the delimiter appears periodically at appropriate positions and can be captured by attention heads (only in the structured parts of the prompt template), as shown in Table 5 (lower), the delimiter can be designed to any token. While we still recommend natural delimiters without semantics in the template design.

## Appendix D Measurement on Direct Decoding

Figure: Figure 14: Direct decoding accuracies on various layers.
Refer to caption: x20.png

This section measures the direct decoding bypass, suggesting that: (1) Direct decoding on well-processed hidden states with some later layer skipped can get satisfactory accuracy even better than the full inference process. (2) Direct decoding on insufficient processed hidden states adds bias towards the predicting distribution.

We examine the first claim by applying the language model head on each layer’s hidden state on SST-2, Llama 3 8B, and conduct a standard ICL process on the decoded token prediction distribution. The results are shown in Fig. 14, where direct decoding accuracy emerges from random to near $1$ around layer 18. Refer to Fig. 8 and results in Appendix F.2, we can confirm: accuracy emerges after all three steps are executed. Moreover, the accuracies on the intermediate hidden states are even higher than the last hidden states, which is aligned with the discussion in Table 3. So, we can conclude: direct decoding on well-processed hidden states can classify well.

Figure: Figure 15: Predicting distributions on different forerunner tokens with various direct decoding logits. Inference process used: Upper: Vanilla ICL, Lower: Biased removed inference by Contextual Calibration proposed by Zhao et al. ().
Refer to caption: x21.png

**Table 6: Results of Table 1 on Falcon 7B.**
| # | Attention Disconnected<br>Key $\rightarrow$ Query | Affected Layers Ratio (from layer 1) |  |  |  |
| --- | --- | --- | --- | --- | --- |
| 25% | 50% | 75% | 100% |  |  |
| 1 | None (4-shot baseline) | $\pm 0$ (Acc. $65.27$) |  |  |  |
| – Step1: Summarize – |  |  |  |  |  |
| 2 | Demo. Texts $x_{i}$ $\rightarrow$ Forerunner $s_{i}$ | $-7.65$<br>$-0.42$ | $-15.69$<br>$-0.36$ | $-27.15$<br>$-0.10$ | $-29.10$<br>$-4.68$ |
| 3 | Query Texts $x_{q}$ $\rightarrow$ Forerunner $s_{q}$ | $-8.30$<br>$-0.26$ | $-21.13$<br>$-0.13$ | $-28.84$<br>$+0.19$ | $-31.74$<br>$-0.00$ |
| – Step2: Semantics Merge – |  |  |  |  |  |
| 4 | Demo. Forerunner $s_{i}$ $\rightarrow$ Label $y_{i}$ | $-1.01$<br>$+0.68$ | $-1.92$<br>$-0.03$ | $-1.04$<br>$-0.00$ | $-1.27$<br>$-0.07$ |
| – Step3: Feature Retrieval & Copy – |  |  |  |  |  |
| 5 | Label $y_{i}$ $\rightarrow$ Query Forerunner $s_{q}$ | $+3.32$<br>$+3.71$ | $-3.61$<br>$-0.03$ | $-7.91$<br>$-0.00$ | $-5.92$<br>$+0.16$ |
| Reference Value |  |  |  |  |  |
| 6 | Zero-shot | $-4.28$ (Acc. $60.99$) |  |  |  |
| 7 | Random Prediction | $-32.77$ (Acc. $32.50$) |  |  |  |

Moreover, we infer that direct decoding from lower layers, where hidden states are not sufficiently processed, causes prediction bias. We investigate the influence of the direct decoding result of layer 0, by the relationship between direct decoded distribution and final prediction distribution. In detail, on SST-2 and Llama 3 8B, we use various forerunner tokens with different direct decoding distributions on the label tokens “positive” and “negative”, and calculate their ICL prediction probability distributions respectively, as shown in Fig. 15 (upper), where forerunner tokens with biased direct decoding distribution produce prediction biases with the same tendencies. While, when we apply contextual calibration (Zhao et al., ), which removes the background value without a query from the prediction, such similar tendencies disappear (Fig. 15 (Lower)).

## Appendix E Demonstrations Enhance the Inference of Perplexed Queries

We investigate the correlation between the queries’ perplexities and the classification accuracies with and without demonstrations, as a supplement of results in Fig. 2 (Right). We divide the queries into 10 bins w.r.t. the language modeling loss, and calculate the prediction accuracy in each bin, shown in Fig. 16. In these results, although a unified correlation can not be observed, we can confirm that: compared to the 0-shot results, the 4-shot inference shows better accuracies, especially on queries with high language modeling loss. So, we can conclude that: demonstrations enhance the inference accuracy of perplexed queries, consistent with the results in Fig. 2 (Right).

## Appendix F Augmentated Experiment Results

### F.1 Attention Head Statistics

We count the marked count of each attention head as Forerunner Token Head (Fig. 18, 19, 20, 21) / Correct Induction Head (Fig. 22, 23, 24, 25) by every data sample from each dataset on each model.

Forerunner Token Head Statistics. We plot the distributions of the marked Forerunner Token Heads towards correct and wrong labels, where: there are observable morphological differences in figures across different datasets, while the forerunner token heads marked on the correct and incorrect labels of the same dataset are almost identical. The detailed data confirms our conclusion in §4.1.

Induction Head Statistics. We plot the distributions of the marked Correct Induction Heads, where there are observable morphological differences in figures across different datasets, but also significant overlaps, which confirms our conclusion in §4.2.

Figure: (a)
Refer to caption: x23.png

Figure: Figure 17: Supplemental experiment result on more samples for Fig. 7.
Refer to caption: x35.png

### F.2 Other LMs’ Experiment Results

The results of most experiments in the main text on Llama 3 8B are shown in Fig. 26,  29,  32, and 35; The results of most experiments in the main text on Falcon 40B are shown in Fig. 27,  30,  33, and 36; The results of most experiments in the main text on Falcon 7B are shown in Fig. 28,  31,  34,  37, and Table 6.

From these results, we can conclude consistently with the main text. However, as discussed in §5.2, inference dynamics on these models are delocalized, thus clear serialization of the 3 steps can not be observed in these results.

### F.3 More Results of Fig. 7

To enhance the persuasiveness, we additionally and randomly try 4 input samples as supplements to Fig. 7 on SST-2 and Llama 3 70B as shown in Fig. 17. From these results, we can observe similar phenomena to Fig. 17 and conclude consistently.

#### Reproducibility Statement

We will publicly release our experiment code after the acceptance of this paper.

#### Author Contributions

H.C. conducted the overwhelming majority of work in this paper.

N.I. is their principal investigator, providing important and beneficial guidance, revision, and research support. M.K. and Y.S. participated in our discussion and provided some helpful suggestions and revisions.

#### Acknowledgments

This work was supported by JSPS KAKENHI Grant Number 19K20332, and The Nakajima Foundation Start-Up Support Grant.

Figure: (a) SST-2
Refer to caption: x43.png

Figure: (a) SST-2
Refer to caption: x55.png

Figure: (e) TREC
Refer to caption: x63.png

Figure: (a) SST-2
Refer to caption: x67.png

Figure: (e) TREC
Refer to caption: x75.png

Figure: (a) SST-2
Refer to caption: x79.png

Figure: (d) SST-5
Refer to caption: x85.png

Figure: (a) SST-2
Refer to caption: x91.png

Figure: (a) SST-2
Refer to caption: x97.png

Figure: (a) SST-2
Refer to caption: x103.png

Figure: (a) SST-2
Refer to caption: x109.png

Figure: (a)
Refer to caption: x115.png

Figure: (a)
Refer to caption: x118.png

Figure: (a)
Refer to caption: x121.png

Figure: (a)
Refer to caption: x124.png

Figure: (a)
Refer to caption: x127.png

Figure: (a)
Refer to caption: x130.png

Figure: (a)
Refer to caption: x133.png

Figure: (a)
Refer to caption: x136.png

Figure: (a)
Refer to caption: x139.png

Figure: (a)
Refer to caption: x142.png

Figure: (a)
Refer to caption: x145.png

Figure: (a)
Refer to caption: x148.png

## Peer Reviews

confidence: 3
contribution: 2
initial_rating: 6
presentation: 2
questions: Please refer to the Weaknesses section.
soundness: 3
strengths: - Attempts to explain the inner workings of ICL, based on reasonable assumptions and investigative tools.
- The findings align with previous work, encouraging readers to accept the claims presented in the paper.
- Visualized results help readers quickly grasp the core concepts and findings of the paper.
summary: This paper aims to explain the mechanisms behind in-context learning (ICL) using the inference circuit framework.

According to the authors, the ICL process consists of three internal steps:
1. Summarize: Large language models (LLMs) encode each demonstration within its corresponding forerunner token,  $s_i$ .
2. Semantics Merge: The semantics of each demonstration and its label are combined into the representation of the label  $y_i$ .
3. Feature Retrieval and Copy: LLMs rely on the accumulated labels  $y_{1:k}$  to respond accurately to the query  $s_q$ , yielding the most appropriate answer.

Each step is empirically validated using methods such as kernel alignment and embedding comparisons. The authors also seek to align their findings with those of prior research, reinforcing the credibility of the arguments presented in this work.
weaknesses: - While the proposed framework is logical and reasonable, it remains challenging to argue definitively that the core mechanism of ICL follows the assumptions presented in the paper. As noted in Section 5.2, there are exceptions that do not align well with the proposed framework, raising concerns that the explanations may be superficial and fail to capture the essence of ICL. This is understandable, as fully explaining the inner workings of neural networks is inherently difficult, if not nearly impossible.
- I am somewhat unclear about the core novelty of this paper. As I understand it, the primary contribution seems to be the attempt to apply the existing inference circuit framework to the ICL of specific LLMs, including LLaMA 3. In Section 2.1, I did not find explanations that clarify why the procedure conducted in this paper is particularly innovative, compelling, or novel. More comprehensive comparisons with prior work employing induction or inference circuits to illustrate the inner workings of ICL would be helpful to underscore the merits and uniqueness of this study.
- In Section 3.1, sentence embeddings generated by an external encoder (BGE M3) are compared to hidden representations computed by an LLM. Since these two representations come from different models, without any modification or fine-tuning, there is a risk that their vector spaces are not aligned or compatible. This raises concerns about whether this experiment is sufficiently reasonable.

---

confidence: 3
contribution: 2
initial_rating: 6
presentation: 2
questions: See weaknesses.
soundness: 3
strengths: 1. The authors proposed to use the mutual nearest-neighbor kernel alignment of the intermediate representations of LLMs and sentence embeddings produced by another pre-training model to assess the quality of these representations. This method is novel.

2. Extensive analysis has been performed on all three steps of the proposed framework. Possible explanations have also been provided for many phenomena.

3. The experiments are performed with real-world LLMs and datasets, which makes the insights more likely to be useful in practice.

4. The paper is well-written and easy to follow.
summary: The authors propose a three-step inference circuit to capture the in-context learning (ICL) process in large language models (LLMs):

1. Summarize: Each input (both demonstration and query) is encoded into linear representations in the model's hidden states.

2. Semantics Merge: The encoded representation of each demonstration is merged with its label, creating a joint representation for the label and demonstration.

3. Feature Retrieval and Copy: The model retrieves and copies the label representation most similar to the query's representation, using this merged representation to predict the query's label.

This circuit explains various ICL phenomena, such as position bias, robustness to noisy labels, and demonstration saturation. Ablation studies show that removing steps in this process significantly reduces performance, supporting the dominance of this circuit in ICL. The paper also identifies some bypass mechanisms that operate in parallel, assisting the inference circuit through residual connections.
weaknesses: 1. The majority of the analysis is based on associations without verifying their strength and whether those effects are causal. For example, Figure 2 right does not look significant enough for me. The peaks highlighted in Figure 5 also look pretty noisy to me.

2. The causal evidence that the authors provided in the ablation study only shows the effect of deleting the hypothesized important components in ICL. What if unimportant components are deleted? Would they have a similar effect? Only if the unimportant components have a significantly weaker effect on ICL performance, can we draw a causal conclusion that the proposed three-step process dominates ICL.

---

confidence: 3
contribution: 3
initial_rating: 6
presentation: 4
questions: Please see weaknesses.
soundness: 3
strengths: 1. The findings in this paper are clearly explained. Experimental results and visualizations enhance readability and help the audience follow the study's progression easily.

2. This work is well-connected to existing ICL research, with discussions that compare its findings to prior studies on ICL explainability and demonstration selection.

3. The study uses multiple LLMs, strengthening the generalizability of the findings across different model architectures.

4. The insights provided are thought-provoking and have potential practical implications for ICL applications.
summary: This paper investigates the mechanisms within large language models (LLMs) that enable in-context learning (ICL) tasks, breaking down the process into three distinct stages: summarization, semantic merging, and feature retrieval/copying. The study employs a variety of experiments across multiple LLMs to validate its findings. Overall, this paper presents valuable insights that can contribute to the field of LLM research, particularly within the ICL community.
weaknesses: 1. [Section 3.1] The authors used mutual nearest-neighbor kernel alignment to evaluate LLMs' summarization abilities. However, the term “summarize” lacks clarity. Does it refer to encoding capabilities similar to those in BGE?

2. [Section 3.1] Additionally, the kernel alignment metric may not be sufficiently robust, as alignment scores in Figure 2 range only from 0.25 to 0.35, which is not significant enough. Consequently, the finding on “summarization” may hold only to a limited extent.

3. [Section 4.1 – Copying from Text Feature to Label Token] It is unclear whether the copying mechanism is applied solely to label tokens or if it extends to other tokens within the input. Using results from other tokens as a baseline could provide a more nuanced understanding of the copying process.

4. [Figure 5, Right] After layer 40, the classification accuracy drops significantly. The authors did not investigate potential reasons for this decline. Could it be due to the gradual degradation of copied information?

5. The experimental setup in Section 5.1 is insufficiently detailed. For instance, how many attention heads are disconnected at each layer? Additionally, the experiments lack certain baselines, such as randomly disconnecting some attention heads to observe the impact on model performance.

Despite these questions and weaknesses, I believe this paper still offers meaningful insights.

---

confidence: 3
contribution: 3
initial_rating: 8
presentation: 4
questions: The three-stage framework proposed in the paper is quite interesting. The questions I have raised are mentioned in the weaknesses section. Here, I would like to know what inspired you to propose this framework. Each part of the framework consists of very specific ideas—were they derived from repeated trial and error, or were they inspired by something else? Alternatively, are they improvements on a significant prior work?
soundness: 3
strengths: - **Originality:** To my knowledge, the three-stage circuit proposed by the authors is a novel contribution.
- **Quality:** The hypothesis put forward is reasonable, and the experiments are thorough with a well-crafted methodology.
- **Clarity:** The arguments and evidence presented in the paper are clear, and the experimental descriptions are appropriately detailed.
- **Significance:** Currently, ICL is one of the most important applications in the LLM field, and understanding the mechanisms behind ICL will greatly aid in enhancing its performance.
summary: This paper proposes a three-stage ICL circuit hypothesis and provides thorough empirical examinations of the existence and significance of these stages. Within this circuit framework, many phenomena are explained, such as how Forerunner Tokens encode input text representations and the bias in input text encoding towards position. These findings present intriguing insights.
weaknesses: The three-stage ICL framework appears to have implicit applicability conditions, which I believe should be clarified.

For example, in Fig. 1 on page 2, a few-shot scenario with $ k=2 $ is presented, which indeed fits the three-stage ICL circuit framework. However, in a zero-shot scenario ($ k=0 $), step 1 may still exist, but steps 2 and 3 would not be applicable. In a few-shot scenario with $ k=1 $, steps 1 and 2 might still apply, but step 3 cannot exist.

Therefore, the framework proposed in this paper should be limited to discussions of scenarios where $ k \geq 2 $. A related question arises: if the focus is restricted to this scenario, what potential issues might emerge?

Furthermore, if we condition on $ k \geq C $ (where $ C $ is a fixed value), could this value vary depending on the problem type? For instance, in tasks like SST-2 and SST-5, which have different label set sizes, might the value of $ C $ differ across these scenarios?

Meta-review: **Summary:**
The paper investigates the mechanisms behind In-Context Learning in large language models. The authors introduce a three-step inference circuit comprising (1) input text encoding, (2) semantic merge, and (3) feature retrieval and copying. Through empirical analysis, they demonstrate that this circuit effectively captures observed phenomena like positional bias, noise robustness, and demonstration saturation in ICL. Ablation studies reveal the circuit's dominance in driving ICL while identifying auxiliary bypass mechanisms enabled by residual connections. 

**Strength:**
- Explains the inner workings of In-Context Learning (ICL) based on reasonable assumptions and robust investigative tools.
- Extensively analyzes all three steps of the proposed three-stage inference circuit.
- Conducts experiments on real-world LLMs and datasets, ensuring the insights are applicable in practice.

**Weakness:**
- While the proposed framework is logical, it is challenging to argue definitively that the core mechanism of ICL aligns with the assumptions presented.
- Limited clarification why the procedure conducted in this paper is particularly innovative, compelling, or novel.

Decision: Accept (Poster)