about
Contextualize-Then-Aggregate: Circuits for In-Context Learning in Gemma-2 2B (arxiv.org)
1 point by PaulHoule on Apr 9, 2025 | hide | past | pdf | discuss on HN

In plain words: By cutting and swapping internal signals in a 2B model across five tasks, they traced how it learns the task from a few examples. It first builds each example's meaning in lower layers, then combines them higher up; linking examples matters more with confusing ones.

Abstract · Contextualize-then-Aggregate: Circuits for In-Context Learning in Gemma-2 2B

In-Context Learning (ICL) is an intriguing ability of large language models (LLMs). Despite a substantial amount of work on its behavioral aspects and how it emerges in miniature setups, it remains unclear which mechanism assembles task information from the individual examples in a fewshot prompt. We use causal interventions to identify information flow in Gemma-2 2B for five naturalistic ICL tasks. We find that the model infers task information using a two-step strategy we call contextualize-then-aggregate: In the lower layers, the model builds up representations of individual fewshot examples, which are contextualized by preceding examples through connections between fewshot input and output tokens across the sequence. In the higher layers, these representations are aggregated to identify the task and prepare prediction of the next output. The importance of the contextualization step differs between tasks, and it may become more important in the presence of ambiguous examples. Overall, by providing rigorous causal analysis, our results shed light on the mechanisms through which ICL happens in language models.

Aleksandra Bakalova, Yana Veitsman, Xinting Huang, Michael Hahn
arXiv:2504.00132 · cs.CL, cs.LG · submitted Mar 31, 2025 · updated Sep 17, 2025
abstract · pdf · html

add comment on HN