프로필

설정

불러오는 중…

← 홈

도움말·문의

자주 묻는 질문

어떤 기능에 로그인이 필요한가요?

공개 논문의 해설과 논문 정보, 모델 구조, 관련 논문, 용어는 로그인 없이 볼 수 있습니다. 논문 올리기, 내 보관함, 읽기 기록, 논문 평가, 관심 분야 추천, 메일과 알림은 로그인해야 쓸 수 있습니다.

PDF 파일로도 올릴 수 있나요?

논문은 arXiv나 DOI 링크로 올리고, 해설은 모두에게 공개됩니다. 출처와 이용 조건이 확인되지 않아 해설을 공개할 수 없는 논문은 올릴 수 없습니다. PDF 파일 올리기와 나만 보기는 구독 회원만 쓸 수 있고, 파일로 올린 논문은 나만 보기로만 저장합니다. 제목으로 공식 정보를 찾는 검색은 버튼을 누를 때만 합니다.

그림과 AI 해설은 정확한가요?

그림은 논문 원본만 쓰고 이용 허락이 확인된 것만 보여 줍니다. 해설은 AI가 쓴 글이라 틀릴 수 있습니다. 중요한 주장과 수치, 그림의 맥락은 원문 근거로 확인해 주세요.

저작권 문제를 알리고 싶어요.

이용 조건과 원문 출처는 논문 정보 탭에 있습니다. 문제가 있으면 ‘문의하기’에서 ‘논문 내용·그림·저작권’을 골라 논문 링크와 문제가 되는 부분, 권리를 확인할 수 있는 근거를 보내 주세요. 접수만으로 권리가 확정되거나 바로 삭제되지는 않습니다. 검토 결과는 ‘내 문의’에서 볼 수 있습니다.

비밀번호를 잊었어요.

이메일로 가입했다면 로그인 창의 비밀번호 찾기에서 인증한 이메일로 다시 설정할 수 있습니다. Google, 네이버, 카카오로 가입했다면 그 서비스에서 비밀번호를 바꿔 주세요.

문의할 때 무엇을 적어야 하나요?

어느 화면에서 무엇을 하다 생긴 문제인지 논문 링크와 함께 적어 주세요. 비밀번호, API 키, 인증 코드, 전화번호 같은 개인정보는 적지 마세요. 문의와 답변은 Refivu에 저장되고 ‘내 문의’에서 볼 수 있습니다.

회원탈퇴는 어떻게 하나요?

설정의 내 계정에서 회원탈퇴를 누르세요. 지워지는 내용을 확인하고 본인 확인을 마치면 탈퇴됩니다. 다른 요청은 ‘문의하기’에서 ‘계정’을 골라 남겨 주세요.

논문 해설

A Circuit for In-Context Learning

문맥 내 학습을 위한 회로

  • 연구 문제 사전학습된 언어모델이 임의 라벨의 few-shot 문장 분류를 단일 forward pass에서 수행할 때, 어떤 헤드와 방향이 어떤 순서로 결합되는지가 문제입니다.
  • 연구 방법 라벨 토큰을 key-value 메모리 칸으로 보고, writer 헤드가 key를 기록하며 reader 헤드가 질의 클래스와 맞는 slot을 softmax로 읽는 회로로 설명합니다. 반복 신호가 gate로 읽기를 열고, brake가 최근성 편향을 상쇄합니다.
  • 주요 결과 Qwen3-4B-Base에서 reader 20개 제거는 −0.74 nats, brake 24개 제거는 +1.39 nats의 margin 변화를 보였고, 두 집단 모두 무작위 헤드 대조군과 뚜렷이 구분되었습니다. 어떤 단일 헤드도 답을 혼자 만들지 못했습니다.

임의 라벨 in-context learning의 문제

이 논문은 사전학습된 언어모델이 프롬프트의 시연만으로 임의 라벨을 따라 문장을 분류하는 능력이 내부에서 어떤 구성요소의 조합으로 구현되는지를 묻습니다. 임의 라벨은 모델이 pre-training에서 외운 적이 없는 대응이므로, 답을 맞히려면 프롬프트 안에서 대응을 얻어야 합니다. 기존 연구는 유도 헤드, 과제 벡터, 라벨 토큰 같은 후보 부품을 찾았지만 이 부품들이 어떻게 합성되는지는 충분히 설명하지 못했습니다. 이 논문은 소수 문장 분류의 임의 라벨 설정에서 이 합성을 회로 수준으로 제시합니다.

Figure 1: One twelve-demonstration prompt, stage by stage. Columns are tokens (sentences si,
arrows, labels and the query q) and rows are layers of Qwen3-4B. E…

Figure 1 : One twelve-demonstration prompt, stage by stage. Columns are tokens (sentences si, arrows, labels and the query q) and rows are layers of Qwen3-4B. Each coloured block marks the tokens and layers where a stage acts: the duplicate detectors and the encoder early on, the writers into the label tokens in the middle layers, and then, at the query arrow, the query code, the gate, the readers, the brakes and the readout band. Later sections give the intervention behind each block.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 3쪽에서 그림 영역을 추출했습니다.
Figure 2: The circuit for few-shot in-context learning in Qwen3-4B-Base. Prompt tokens run down
the left (sentences Si, labels Li, the query Q and its arrow EN…

Figure 2 : The circuit for few-shot in-context learning in Qwen3-4B-Base. Prompt tokens run down the left (sentences Si, labels Li, the query Q and its arrow END). Boxes are classes of attention heads, with layer.head numbers beneath. Writer heads give each label token a key (the class of its sentence) alongside its value (the label). At END, reader heads match the query’s class against those keys and copy the matching labels, copier heads write the logits, and brake heads write against the most recent label. The gate g, assembled by the pooling heads, opens the read by lowering the readers’ attention-sink logit (dashed). Sections 3–8 give the intervention behind each arrow.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 5쪽에서 그림 영역을 추출했습니다.

라벨 토큰의 key-value 메모리

회로의 첫 단계는 각 라벨 토큰의 잔차 스트림을 slot으로 보는 것입니다. 중간 층의 writer 헤드가 라벨 토큰에서 자기 문장으로 주의를 보내 그 문장의 클래스를 key로 기록하고, 라벨의 정체성은 value로 남습니다. 패칭 실험에서 라벨을 서로 바꾸면 값 쪽의 활성이 답의 방향을 옮기고, 문장을 바꾸면 key 쪽이 옮깁니다. 따라서 value와 key는 어텐션의 서로 다른 쪽에서 읽힙니다. 같은 클래스의 다른 문장으로 바꾼 대조군은 답을 0.08 nats 이내에서만 움직여, 슬롯이 문장 자체가 아니라 클래스를 저장함을 보여 줍니다.

Figure 4: The four main interventions, each drawn on the end of a 12-shot prompt. The red component
is replaced or steered, and the output is read at END. (a)…

Figure 4 : The four main interventions, each drawn on the end of a 12-shot prompt. The red component is replaced or steered, and the output is read at END. (a) Sentence swap: the keys at a label token come from the twin in which that demonstration’s sentence belongs to the other class, so the slot’s key no longer matches its value. (b) Label swap: the values at the label token come from the twin with the labels exchanged. (c) Gate steering: the model’s own gate direction g is added at END at its natural magnitude, before the reader layers, and we measure the readers’ attention to the sink and to the matching slots. (d) Query-code handoff: the outputs of the two query heads at END come from the twin whose query is of the other class; later attention outputs can be held fixed to test whether the effect passes through them.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 6쪽에서 그림 영역을 추출했습니다.
Figure 5: Anatomy of a slot. The residual stream at a label token holds two things, which are read
through two different matrices. The label’s identity comes f…

Figure 5 : Anatomy of a slot. The residual stream at a label token holds two things, which are read through two different matrices. The label’s identity comes from the token’s own embedding and the early layers, and is read by the readers’ WV . The class of the preceding sentence is written in by middle-layer heads that attend back to the sentence, and is read by the readers’ WK as the key that the query’s class is matched against.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 7쪽에서 그림 영역을 추출했습니다.
Figure 6: The slot holds a value and a key on different sides of attention. (a) Exchanging the labels:
in all three models the effect runs through the values a…

Figure 6 : The slot holds a value and a key on different sides of attention. (a) Exchanging the labels: in all three models the effect runs through the values at the label tokens. (b) Changing a sentence while keeping its label: the effect runs through the keys at the label tokens, and only in the middle layers. (c) Handoffs from a same-class sentence of the same length move the answer by at most 0.06 nats. Bars are paired effects on the margin with 95% bootstrap intervals; grey bars are size-matched random controls.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 8쪽에서 그림 영역을 추출했습니다.

softmax 조회와 null action

상위 층의 reader 헤드는 질의 화살표에서 slot들에 대해 일반적인 softmax를 수행합니다. 질의의 클래스와 key가 맞는 slot으로 주의가 몰리고 그 value가 복사됩니다. 위치 0의 attention sink도 같은 softmax에 참여하며, 반복된 라벨이 없을 때 reader는 sink에 주의를 두어 아무 라벨도 복사하지 않습니다. 이것이 null action입니다. 논문은 일치하는 slot의 질량을 로그 항의 softmax 식으로 적고, 헤드마다 세 상수를 적합합니다. 명제 1은 이 식이 대조 질의 세트에서 측정된 질량과 맞는지를 다룹니다.

Figure 9: Within a regime the read follows a softmax law, and the law transfers to fewer slots per class
but not to longer prompts. Each point is one head at o…

Figure 9 : Within a regime the read follows a softmax law, and the law transfers to fewer slots per class but not to longer prompts. Each point is one head at one slot count, showing the measured matching- slot mass against the prediction of Equation 1 from twelve-demonstration constants. (a) Qwen, in the fitted regime. (b) Qwen and Llama, one slot per class (held out). (c) Qwen and Llama, eighteen demonstrations (held out; the prediction fails). Sharp readers sit on the line and diffuse heads fall below it.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 10쪽에서 그림 영역을 추출했습니다.
Figure 11: What a reader looks at. Attention from the query arrow to the first position (the sink) and
to the four label slots, for three Qwen3-4B readers, ave…

Figure 11 : What a reader looks at. Attention from the query arrow to the first position (the sink) and to the four label slots, for three Qwen3-4B readers, averaged over 30 four-demonstration prompts. Top row: two labels, each used twice; the matching slot (slot 3 or 4, depending on the prompt) draws the attention. Middle row: the same prompts with the sixteen repeat-detector heads mean-ablated. L29h11 moves back toward the sink (0.21 to 0.40), while L24h21 and L22h20 do not, so the detectors’ signal reaches some readers and not others. Bottom row: four distinct labels, none repeated; L29h11 puts 0.91 of its attention on the sink and reads nothing.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 12쪽에서 그림 영역을 추출했습니다.

반복 신호가 여는 게이트

반복 라벨이 있을 때에만 읽기가 일어나도록 하는 신호는 잔차 스트림의 한 방향 g입니다. 중복 토큰 헤드가 반복 라벨을 탐지하고, 20~23층의 pooling 헤드가 이를 질의 화살표에 모읍니다. g는 reader의 sink 로짓을 낮춰 읽기를 엽니다. 중복 토큰 헤드 16개를 평균 절제하면 반복 프롬프트의 g 투영은 +18.3에서 −0.3으로 떨어집니다. 이 게이트는 Qwen에서 확인되었고, 같은 방향을 다른 모델에서도 측정했지만 모든 연결이 같은 강도로 복제된 것은 아닙니다.

Figure 10: The gate lowers the null logit and moves matching far less. (a) Projection of the arrow
residual onto g for prompts with repeated and with unique la…

Figure 10 : The gate lowers the null logit and moves matching far less. (a) Projection of the arrow residual onto g for prompts with repeated and with unique labels, intact and with the sixteen duplicate- token heads ablated, with random and induction-scored sets as controls. (b) Change in each reader’s sink-minus-match logit when g is added at natural and double dose; same-norm random directions in grey. (c) Change in the same readers’ match-minus-other logit.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 12쪽에서 그림 영역을 추출했습니다.
Figure 17: The null action in two families. (a) Llama-3.2-3B emits a label on 67% of unique-label
prompts and Qwen3-4B on 10%: the same fallback, gated much mo…

Figure 17 : The null action in two families. (a) Llama-3.2-3B emits a label on 67% of unique-label prompts and Qwen3-4B on 10%: the same fallback, gated much more weakly in Llama. (b) In Qwen, adding the gate signal g at its natural dose lowers the sink logit relative to the matching slots at the three strongest readers (red), and moves matching relative to the other slots much less (grey). (c) In Llama, knocking out the sixteen heads that a generic induction score selects moves the middle-layer readers’ attention out of the sink and onto the slots, so in Llama the induction-scored heads hold the read closed.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 20쪽에서 그림 영역을 추출했습니다.
Figure 22: Token observatory for one 12-shot prompt (symbol labels, answer foo) in Qwen3-4B.
(a) Summed head write norm at every layer and position (log scale)…

Figure 22 : Token observatory for one 12-shot prompt (symbol labels, answer foo) in Qwen3-4B. (a) Summed head write norm at every layer and position (log scale); white lines mark the label slots, and cyan marks the query arrow. (b) At the query arrow, the residual’s projection onto the gate direction g (green) and onto the repeat-flag direction Ul (blue) by layer, intact (solid) and with every unnamed head mean-ablated at the arrow (dashed). (c) Attention of the three heads that write most at the arrow in each layer, split by what they read.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 35쪽에서 그림 영역을 추출했습니다.

질의 코드, reader와 brake의 집단 작동

질의 클래스 코드는 두 헤드(L22h10, L23h26)가 질의 화살표에 씁니다. 이 코드는 slot key 방향 u와 다르며, 26~29층 reader의 매칭 함수가 이루는 부분공간에 들어갑니다. 약 90개 reader 중 하나만 제거하면 효과가 작지만, 20개 reader를 함께 제거하면 margin이 −0.74 nats 떨어지고 같은 층의 무작위 20개 헤드는 +0.02입니다. 24개 brake를 함께 제거하면 margin이 +1.39 nats 증가해 거의 세 배가 되고, 무작위 24개는 +0.22입니다. 마지막 층의 copier 헤드는 reader가 모은 값을 로짓으로 바꿉니다.

Figure 12: Two heads write a query code that the reader population consumes. (a) Share of the
query-flip effect carried by the pair L22h10+L23h26 and by all at…

Figure 12 : Two heads write a query code that the reader population consumes. (a) Share of the query-flip effect carried by the pair L22h10+L23h26 and by all attention in layers 21–29, and what remains when downstream attention queries are held at their intact values. (b) Energy of the pair’s write in the span of the readers’ match functionals, against random subspaces of the same dimension.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 13쪽에서 그림 영역을 추출했습니다.
Figure 14: Readers and brakes act as populations with opposite signs. (a) Joint knockout of 20
readers, of 24 brakes, and of both, on a fresh draw, against si…

Figure 14 : Readers and brakes act as populations with opposite signs. (a) Joint knockout of 20 readers, of 24 brakes, and of both, on a fresh draw, against size-matched random sets (grey). (b) Order effect: the margin against the position of the last matching demonstration, intact and with the brakes knocked out.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 15쪽에서 그림 영역을 추출했습니다.
Figure 16: The answer as a sum of bands. Left: the intact twelve-demonstration margin in Qwen,
built up band by band; the copier band of layers 30–35 writes al…

Figure 16 : The answer as a sum of bands. Left: the intact twelve-demonstration margin in Qwen, built up band by band; the copier band of layers 30–35 writes almost all of it. Right: the change under the exact class flip. The copier band carries most of the swing and the readers a quarter, and the late MLPs push the other way.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 16쪽에서 그림 영역을 추출했습니다.
Table 6: Effects behind the main text (nats; paired against the intact run; 95% bootstrap intervals)

Table 6 : Effects behind the main text (nats; paired against the intact run; 95% bootstrap intervals).

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 30쪽에서 그림 영역을 추출했습니다.

개별 헤드의 이득 한계와 집단 구조

명제 2는 헤드 i가 질량 m_i로 값 차이 Δv를 가진 slot에 주의를 둘 때 직접 기여가 m_i ∥W_OV Δv∥ ∥w∥/ρ 이하라고 말합니다. 어떤 헤드도 직접 기여가 0.2 nats를 넘지 않으므로, 1.3 nats의 margin은 최소 7개 이상의 헤드 합입니다. 실제 모델은 절반의 flip에 14개 헤드를 쓰고 80%에는 46개를 씁니다. 이 상한은 개별 헤드에 신호가 부족해서가 아니라 출력 이득이 부족해서 집단이 생긴다는 해석의 근거입니다.

Figure 13: No single head carries the answer. Each cell is the effect on the 12-shot class margin of
knocking out one head at the query position (mean over 144…

Figure 13 : No single head carries the answer. Each cell is the effect on the 12-shot class margin of knocking out one head at the query position (mean over 144 prompts from six label families; blue lowers the margin and red raises it; colour clipped at ±0.15 nats), for every head in the reader layers of Qwen3-4B-Base (layers 21–35) and Llama-3.2-3B (layers 16–27). Outlined cells are the five most negative and five most positive heads. The largest single-head effects are −0.14 nats (Qwen L23h26, a query head) and +0.13 (Qwen L31h30, a brake), and −0.09 and +0.12 in Llama (L18h10, L19h1), against a 1.3-nat margin. The sets built from these rankings move the margin by −0.74 and +1.39 in Qwen and by−0.56and+1.90in Llama when knocked out together (Table 6).

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 14쪽에서 그림 영역을 추출했습니다.

적용 범위와 검증되지 않은 예측

회로는 두 클래스 라벨 검색과 함수 선택, 짧은 문장과 단일 토큰 라벨, 최대 12개 시연, 세 기반 모델(3~4B)에서 기술됩니다. 명령 따르기, 긴 생성, 다중 클래스 binding은 범위 밖입니다. softmax 법칙은 12-demonstration 프롬프트에서 적합된 상수로 1-slot-per-class에는 맞았지만, 18-demonstration 프롬프트에는 전이되지 않았습니다. 저자들은 이를 헤드의 sink 질량과 총 매칭 질량이 거의 고정되어 있고, 추가된 매칭 slot이 이 고정된 예산을 나누어 가진다는 관찰로 설명합니다. 이 해석이 왜 그런 고정성을 갖는지는 아직 설명되지 않았습니다.

Table 4: Each link of the account in three models.Forced: follows from the architecture and is
expected in every model.Implementation: set by training and repo…

Table 4 : Each link of the account in three models.Forced: follows from the architecture and is expected in every model.Implementation: set by training and reported per model.Named: a small set of heads is necessary and sufficient.Population: no single head is necessary, and the link is characterized by a direction with a size-matched random control. –: not run.

원문 · CC BY 4.0 · Andrew Gao, William Gao · A Circuit for In-Context Learning · 원문 그림 인용 · 원본 PDF 20쪽에서 그림 영역을 추출했습니다.

논문 정보

저자
Andrew Gao, William Gao
학회·저널
arXiv · 프리프린트
최초 공개일
2026년 11월 3일
등록일
2026년 11월 6일
수정일
2026년 11월 3일
버전
v1
arXiv
2611.05344
분류
cs.CL · cs.LG
원문 이용 조건
CC BY 4.0
제공 범위
논문 정보, 해설, 허용된 원문 그림

AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.

초록

In-context learning (ICL) lets a pretrained language model perform a task specified by demonstrations in its prompt, with no parameter updates. With arbitrary labels the model must acquire a mapping it cannot have memorized, so the learning happens within a single forward pass. Prior work found candidate parts but not how they compose. We give the composition for few-shot sentence classification with arbitrary labels in three 3-4B-parameter transformers. The model implements a key-value memory over label-token positions: each label token's residual stream encodes the label's identity, and middle-layer attention heads write into it the class of the preceding demonstration as its key. At the query, upper-layer heads match the query's class against the stored keys and copy out the matching labels. An early-layer signal encoding whether any label has repeated gates this readout; in its absence the readers attend to the start of the prompt and no label is favored. A separate set of heads suppresses the most recently seen label. Each step is established causally by activation patching, head ablations against random-head baselines, and steering with the model's own signals. A softmax model of the readout with two constants per head, fit on one prompt distribution, predicts another. The computation is conserved across the three models, the named heads alone reproduce the behaviour, and a transformer trained from scratch grows the same parts. The circuit transfers to semantic concepts and to labels with meaning, and the same parts, with a causal gate, appear from 0.6B to 8B in one family and survive instruction tuning. ICL in this setting is a gated associative lookup built from a few identifiable component types, traced causally from demonstrations to prediction.

원문 인용

Andrew Gao, William Gao (2026). A Circuit for In-Context Learning. arXiv:2611.05344v1. https://arxiv.org/abs/2611.05344v1

BibTeX
@misc{gao2026circuit,
  title = {{A Circuit for In-Context Learning}},
  author = {Andrew Gao and William Gao},
  year = {2026},
  eprint = {2611.05344},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.05344v1}
}

관련 논문 보기다른 논문 둘러보기

논문 미리 보기
계정 보안

Google 계정 연결

Google 계정을 연결하면 그 계정으로도 로그인할 수 있습니다.

Refivu

회원탈퇴

Refivu
Refivu

회원가입