Deep DiveOlsson 외 Transformer Circuits Thread 원문 Key Concepts·Arguments 1–6·Evidence summary·Model Analysis Table·Appendix 직접 확인, Python 3.9.6 표준 라이브러리로 previous-token write와 induction selection·copy의 최소 알고리즘 직접 실행

Induction Head는 문맥의 다음을 어떻게 복사하는가

Olsson 외의 In-context Learning and Induction Heads 원문을 기준으로 [A][B] … [A] → [B] 패턴 복사를 구현하는 previous-token head와 induction head의 2-layer 회로, 논문이 정의한 in-context learning score, training phase change와 여섯 줄 증거의 강도, small attention-only model의 인과 증거와 large model의 상관 증거를 분리해 설명한다. Python 3.9.6으로 가장 작은 sequence-copy algorithm을 직접 실행한다.

4단계 네 번째 논문. 이 글은 Catherine Olsson 외의 In-context Learning and Induction Heads 원문을 직접 읽고 썼다. 원문 공개일은 2022-03-08이며 다운로드 PDF SHA-256은 9fa4a667e559431efac5bf1d9463f3b0005633e0b78f3ebbacfb901e4ed36e50다. Induction head(유도 헤드)는 [A][B] … [A]를 보면 앞의 A 뒤에 있던 B를 찾아 다음 token으로 B를 높이는 attention 회로다.

이 글에서 얻을 답과 범위

ICL(In-context Learning, 문맥 내 학습)은 “prompt 몇 개만 보고 새 task를 한다”는 말로 널리 쓰인다. 이 논문은 더 넓고 측정 가능한 뜻을 쓴다. context 뒤쪽 token일수록 앞 context를 많이 받으므로 loss가 낮아지는 현상이다. 그리고 그 현상의 상당 부분이 induction head라는 작은 회로에서 올 수 있다는 가설을 시험한다.

이 글을 읽은 뒤에는 다음을 설명할 수 있어야 한다.

  1. [A][B] … [A] → [B]가 fixed n-gram table 암기가 아니라 context 안에서 작동하는 algorithm인 이유.
  2. previous-token head와 induction head가 왜 서로 다른 layer에 있어야 하는지.
  3. 논문의 prefix matching과 copying이라는 empirical definition(경험적 정의).
  4. token index 50과 500의 loss 차이로 ICL을 어떻게 측정했는지.
  5. phase change, ablation, generality, continuity의 여섯 증거가 무엇을 보이고 무엇을 못 보이는지.
  6. small attention-only model의 causal evidence와 large MLP model의 correlational evidence를 왜 구분해야 하는지.

범위는 논문 자체의 induction mechanism과 증거 평가다. 모든 few-shot learning, prompt engineering, hidden reasoning의 단일 원인을 증명하지 않는다. 특히 논문 저자도 large model에서 “대부분의 ICL” 주장은 preliminary·indirect evidence이며 결론적이지 않다고 명시한다.

Induction head는 현재 A와 같은 A를 과거에서 찾는 head가 아니다. 앞 layer가 각 위치에 ‘바로 전 token’을 써 둔 덕분에, 현재 A가 앞에 있었던 위치의 다음 token B를 찾아 B를 복사하는 두 head 회로다.

왜 필요한가 — prompt가 weight를 바꾸지 않고도 행동을 바꾼다

GPT류 model은 API 호출 중 weight를 gradient로 update하지 않는다. 그런데 영어 cat → 한국어 고양이 같은 예를 context에 몇 개 놓으면 다음 쌍의 형식을 따라 한다. 이것을 “model이 runtime에 학습했다”라고 쉽게 말하지만, 어느 activation·head·circuit이 그것을 구현하는지는 별개 질문이다.

가장 작은 pattern completion부터 보자.

context      A  B  C  A
next token?              → B

앞에서 A 뒤에 B가 있었다. 마지막 A에서 B 확률을 높이면 context 안의 local rule을 사용한 것이다. A·B가 무엇이든 되는 규칙이므로 pretrained vocabulary의 A→B 고정 표를 직접 조회하는 것과 다르다. 이 회로가 fuzzy similarity(흐릿한 유사성)까지 일반화하면 prompt example의 input과 새 input을 대응시키는 시작점이 될 수 있다.

무엇인가 — two-layer pattern copying circuit

previous-token head

첫 layer의 previous-token head(이전 token 헤드)는 위치 i에서 i-1의 token 정보를 residual stream에 복사한다.

위치       0     1     2     3
token      A     B     C     A
복사된 전값  -     A     B     C

위치 1의 B는 자기 token B와 함께 “내 앞은 A였다”는 정보를 갖게 된다. 이것이 다음 layer가 A 뒤에 온 위치를 찾을 수 있게 하는 표지다.

induction head

마지막 위치 3의 current token A가 query가 된다. 두 번째 layer의 induction head는 key에서 “previous token이 A였던 위치”를 찾는다. 위치 1의 B가 선택된다. value·OV write가 B 정보를 마지막 residual에 쓰고 unembedding이 B logit을 높인다.

현재 A
  → previous=A를 가진 위치 B를 찾음
  → 그 위치의 token B value를 읽음
  → 현재 위치 residual에 B 방향을 write
  → 다음 token B의 logit 증가

이것이 논문이 말한 two-head circuit이다. 1-layer attention-only model은 첫 head가 만든 “previous token 정보”를 다음 layer head가 읽을 수 없으므로 이 정확한 구조를 만들기 어렵다.원문 Induction Heads

선행 개념 — attention pattern과 copying은 둘 다 필요하다

논문은 random repeated sequence에서 induction head를 다음 두 성질로 경험적으로 정의한다.

성질질문관찰
prefix matching올바른 과거 위치를 읽나current·recent token 뒤에 이어질 token 위치에 attention
copying읽은 token을 prediction으로 밀어 주나head output이 attended token logit을 증가

prefix matching만 있으면 올바른 위치를 보지만 아무 useful write를 안 할 수 있다. copying만 있으면 B를 쓰지만 A 뒤의 B를 찾지 못할 수 있다. 둘이 있어야 [A][B] … [A] → [B]가 된다.

QK(Query-Key) circuit은 어떤 위치를 고를지, OV(Output-Value) circuit은 고른 위치의 token을 output vocabulary 방향으로 어떻게 쓸지 결정한다. 이 논문은 Transformer Circuits framework의 residual stream·QK·OV language를 실제 behavior에 연결한다.

밑바닥 원리 — ICL score와 손실의 위치별 차이

각 position의 next-token negative log likelihood를 loss라고 하자. 논문은 token 50의 평균 loss와 token 500의 loss 차이를 평균내는 heuristic score를 썼다.

[ \operatorname{ICLScore}=\operatorname{Loss}{500}-\operatorname{MeanLoss}{50} \tag{1} ]

뒤쪽이 더 예측하기 쉬우면 Loss_500이 작아져 score는 음수가 된다. 숫자 50과 500은 원문도 somewhat arbitrary라고 밝힌 선택이며, context length 512에서 앞과 뒤를 비교하기 위한 operational metric이다. 이 metric은 task-specific few-shot accuracy가 아니라 “더 긴 context를 받았을 때 평균적으로 loss가 얼마나 낮아졌는가”를 보는 macro measurement다.원문 In-context Learning

따라서 ICL score가 좋아졌다고 번역·산술·코딩 모두를 잘한다는 뜻은 아니다. 반대로 특정 benchmark few-shot accuracy가 좋아졌다고 loss-at-position 현상이 전부 induction head라는 뜻도 아니다.

내부 구조와 실제 실행 흐름 — 여섯 증거를 같은 강도로 읽지 않기

논문은 34개 Transformer training trajectory와 50,000개 넘는 head ablation을 분석해 여섯 줄 증거를 제시한다.

  1. co-occurrence — early training의 loss bump에서 induction head 형성과 ICL 증가가 함께 나타난다.
  2. co-perturbation — architecture를 바꿔 induction bump 시점을 옮기면 ICL 변화 시점도 함께 옮겨진다.
  3. direct ablation — small model에서 induction head를 knockout하면 ICL이 크게 감소한다.
  4. generality examples — literal copying 외 abstract behavior와 translation 비슷한 사례를 보인다.
  5. mechanistic plausibility — small model 회로가 fuzzy·nearest-neighbor pattern completion으로 확장될 자연스러운 길을 제시한다.
  6. continuity — size가 커져도 관련 behavior와 data가 매끄럽게 이어진다는 관찰이다.

가장 중요한 표는 evidence strength다. small attention-only model에서는 “ICL 일부·다수에 기여” 주장에 strong causal evidence가 있지만, large model with MLPs에서 majority claim은 medium correlational evidence다. correlation(상관)은 같은 training phase에 제3의 mechanism이 같이 생겼을 가능성을 제거하지 못한다. 이 구분이 논문을 과장하지 않고 읽는 방법이다.원문 Summary of Evidence

직접 검증과 재현 — 가장 작은 sequence-copy algorithm

직접 실행 확인이다. 2026-07-24, Python 3.9.6 표준 라이브러리로 previous-token write와 induction selection을 문자열 수준에서 구현했다. 이는 attention weight를 학습한 Transformer가 아니라 두-head algorithm의 상태를 확인하는 최소 모델이다.

sequence: ['A', 'B', 'C', 'A']
previous-token information at each position: [None, 'A', 'B', 'C']
current token: A
selected position: 1
induction prediction: B

sequence: ['red', 'blue', 'red']
previous-token information at each position: [None, 'red', 'blue']
current token: red
selected position: 1
induction prediction: blue
checks passed

파일은 /tmp/induction-heads-research/verify_induction.py다. 알고리즘은 current A와 같은 previous-token marker를 가진 가장 최근 위치를 선택하고 그 위치의 token을 반환한다. 실제 head는 token equality if문이 아니라 QK dot product·softmax·OV matrix로 이와 같은 behavior를 근사한다. 그래서 이 실행은 mechanism의 논리 구조를 검증할 뿐, 논문 model의 causal ablation을 재현하지 않는다.

성능과 트레이드오프 — phase change는 운영 경보가 아니다

논문은 many model에서 early training 약 2.5–5 billion token 부근에 ICL 증가와 induction head 형성이 함께 나타났다고 보고한다. 그러나 이 위치·loss 값·training token 수는 model architecture, dataset, optimizer, context length마다 달라질 수 있다. training loss curve의 bump 하나로 production capability가 생겼다고 알람을 울리면 안 된다.

관찰얻는 것부족한 것
per-token losscontext 길이 효과어떤 task가 좋아졌는지
attention patternprefix-match 가설copying과 output effect
OV·logit attributionB write 방향total causal effect
ablation특정 model·prompt의 intervention effect모든 model의 일반 원인
smooth scaling continuity같은 mechanism 가능성mechanism 동일성 증명

large model은 layers·MLPs가 많고 head 하나를 zero ablate하면 downstream self-repair가 생길 수 있다. 더 강한 주장에는 activation patching, edge/path patching, control prompt, 다양한 seed·paraphrase를 함께 써야 한다.

실패와 운영 기준 — induction과 prompt magic을 혼동하지 않기

  1. A B … A → B가 되는 한 example로 head label을 붙이지 않는다. random repeated sequence에서 prefix matching과 copying을 분리해 측정한다.
  2. “attention이 A를 봤다”만으로 copying을 주장하지 않는다. attended token의 logit 증가를 봐야 한다.
  3. model size가 크면 small-model circuit proof를 그대로 전이하지 않는다. 논문도 large-model claim을 상관 증거로 한정한다.
  4. ICL score index 50·500을 다른 context length에 그대로 복사하지 않는다. 비교 index, corpus, tokenizer, loss reduction 방식을 명시한다.
  5. ICL을 user task 성능·안전성·tool use 성공률의 대체 지표로 쓰지 않는다.

Induction head를 찾아도 RAG citation 검증, tool permission, structured output validation은 독립적으로 필요하다. pattern copying은 좋은 demonstration format을 따라 할 수도 있고, 잘못된 context pattern을 그대로 따라 할 수도 있다.

대안과 선택 기준 — 질문이 다르면 실험도 다르다

질문첫 실험다음 검증
literal repeated sequence 복사random repeated tokensprefix matching과 copying 분리
특정 few-shot task 적응held-out demonstrationstask accuracy와 logit difference
head가 정말 필요함head ablationpatching·self-repair 확인
어느 path가 정보를 전달함QK·OV compositionedge·path patching
abstract in-context neighborrepresentation similarity probecounterfactual feature intervention

흔한 오해와 최초 질문에 대한 답

induction head가 모든 few-shot learning을 설명하나

아직 아니다. 논문은 majority hypothesis에 preliminary·indirect evidence를 제공한다. small attention-only model에서는 강한 인과 증거가 있지만 larger MLP model에서는 상관 근거가 중심이다.

induction head는 A token 자체를 복사하나

아니다. A가 이전에 있었던 다음 위치의 token B를 찾아 B를 높인다. A를 찾는 정보는 previous-token head가 만든 marker를 통해 간접적으로 얻는다.

prompt example을 많이 넣으면 항상 좋아지나

아니다. context window, attention budget, conflicting example, retrieval noise, task format에 따라 악화될 수 있다. induction mechanism은 context를 쓸 수 있는 한 길일 뿐이다.

이 논문 다음에 IOI circuit을 읽는 이유는 무엇인가

Induction head는 일반 pattern completion 회로다. IOI(Indirect Object Identification) circuit은 더 구체적 문장 task에서 head와 MLP가 어떤 edge를 통해 이름을 선택하는지 보여 주므로 circuit discovery의 다음 단계가 된다.

출처 및 검증 경로

1차 자료

직접 실행 기록

  • 환경 — macOS, Python 3.9.6, 외부 library 없음.
  • 파일 — /tmp/induction-heads-research/verify_induction.py.
  • 검증 — previous-token marker, current token과 같은 marker 위치 선택, selected position token copy.
  • 한계 — exact equality로 표현한 최소 알고리즘이다. trained Transformer QK·OV weights, 34 model trajectory, 50,000 ablation을 재현한 실험은 아니다.
대화

댓글

0
댓글을 불러오는 중입니다.