4단계 다섯 번째 논문. 이 글은 Kevin Wang 외의 Interpretability in the Wild — A Circuit for Indirect Object Identification in GPT-2 Small 원문을 직접 읽고 썼다. 확인한 판본은 arXiv v1, 2022-11-01이며 PDF SHA-256은
af0ea3ca3912f819d2cd06b0f36f5c20bfcab72fbc83816d830c286af6872c91다. 이 논문은 GPT-2 small이 자연어 IOI(Indirect Object Identification, 간접 목적어 식별) task를 푸는 26개 attention head의 7개 class 회로를 역추적했다.
이 글에서 얻을 답과 범위
When Mary and John went to the store, John gave a drink to의 다음 token은 Mary다. John은 subject로 두 번 나왔고 Mary만 간접 목적어이기 때문이다. 사람은 “중복 이름을 지우고 남은 이름을 답한다”라고 말한다. 논문 질문은 GPT-2 small이 실제로 어떤 internal computation으로 이를 하는가다.
이 글은 IOI dataset와 logit difference, circuit의 node·edge, 7 head class, pABC mean ablation, path patching, faithfulness·completeness·minimality의 뜻을 설명한다. 범위는 GPT-2 small, 15개 template, single-token name IOI task다. GPT-2 전체 언어 능력이나 모든 MLP 역할을 설명하지 않는다.
IOI circuit은 Mary를 기억한 head 하나가 아니다. John이 중복됐다는 정보를 END의 Name Mover가 읽지 못하게 만들고, 남은 Mary를 복사하도록 여러 head가 residual stream edge로 협력하는 circuit이다.
왜 필요한가 — 맞힌 output은 알고리즘 설명이 아니다
Model이 Mary 확률을 높였다는 사실만으로는 이름 빈도를 외웠는지, 문법을 넓게 흉내 냈는지, 중복 subject를 제거하는 algorithm을 실행했는지 알 수 없다. Mechanistic interpretability(기계론적 해석 가능성)는 output에서 거꾸로 component와 edge를 찾아 마지막 설명을 검증하려 한다.
이전 이름 Mary, John, John
중복 제거 John 제거
남은 token Mary
END prediction Mary
이 task는 target token이 명확하고 이름을 바꾼 counterfactual sentence를 쉽게 만들 수 있다. 그래서 큰 자연어 behavior를 모두 설명하기 전 circuit discovery workflow를 시험하기 좋다.
무엇인가 — IOI task와 logit difference
IO는 Mary, subject S는 John이다. Initial clause에 IO와 S1이 나오고 main clause에서 S2가 반복된다. 논문은 15 template에 random single-token name·place·item을 넣은 pIOI distribution을 만들었다.원 논문 2절·Appendix E
[ \operatorname{LogitDiff}=\operatorname{logit}(IO)-\operatorname{logit}(S) \tag{1} ]
양수면 IO raw score가 S보다 높다. IO probability는 softmax 뒤 IO 확률이다. 논문은 100,000 pIOI example에서 mean logit difference 3.56, IO를 S보다 높게 예측한 비율 99.3%, mean IO probability 49%를 보고했다. 이 수치는 그 template distribution과 GPT-2 small 설정의 결과다.원 논문 2절
선행 개념 — circuit은 node만이 아니라 edge다
Model M의 computational graph에서 node는 embedding·attention head·MLP 같은 forward-pass term이고 edge는 residual connection·attention·projection이다. Circuit C는 특정 behavior를 담당하는 M의 induced subgraph다.
name embedding
→ residual stream
→ attention head write
→ 다음 head의 Q·K·V read
→ END residual
→ unembedding
→ IO minus S logit difference
Head output을 0으로 치환하는 zero ablation은 mean activation 같은 constant signal도 지워 unnatural downstream state를 만들 수 있다. 논문은 reference distribution 평균 activation으로 치환하는 mean ablation을 사용했다. pIOI 평균은 name duplication signal을 남길 수 있으므로, 세 unrelated name A·B·C를 쓰되 문법 template은 유지한 pABC distribution에서 template별 평균을 만들었다.원 논문 2.1절
밑바닥 원리 — 7개 head class가 역할을 나눈다
| class | 역할 | algorithm 연결 |
|---|---|---|
| Duplicate Token Heads | S2에서 S1을 찾아 duplicate signal | John 반복 식별 |
| S-Inhibition Heads | END에서 S2를 읽고 Name Mover query 억제 | John을 읽지 못하게 함 |
| Name Mover Heads | END에서 name을 읽고 output logit 방향으로 copy | Mary 출력 |
| Negative Name Mover Heads | 정답 반대 direction write | confidence hedge 후보 |
| Previous Token Heads | S1 뒤 위치에 S 정보 copy | induction routing 준비 |
| Induction Heads | S2에서 S1 다음 위치를 찾아 duplicate signal | Duplicate Token 보조 경로 |
| Backup Name Mover Heads | regular Name Mover knockout 때 name copy | redundancy와 self-repair |
Duplicate Token·Induction head가 John의 중복을 찾고, S-Inhibition이 Name Mover의 subject attention을 막는다. Name Mover가 IO token에 attention해 IO name을 END residual과 unembedding 방향으로 쓴다. 논문은 MLP·LayerNorm·embedding에 intervention하지 않았다. Individual MLP knockout은 대체로 task를 유지하지만 post-first-layer MLP 전체 knockout은 task를 망가뜨렸다고 보고한다. 그러므로 attention head만으로 완전히 설명됐다는 말은 과장이다.원 논문 3절·Appendix J
내부 구조와 실제 실행 흐름 — logits에서 edge를 역추적한다
Activation patching은 node 값을 source input activation으로 교체한다. Path patching은 sender head h에서 receiver set R로 가는 특정 path만 source activation으로 바꾸고 R 뒤 계산은 정상 재실행한다.
x_orig pIOI sentence
x_new 같은 template의 pABC sentence
h에서 R로 직접 가는 path만 x_new activation으로 patch
→ IO minus S logit difference 변화 측정
그래서 h가 output에 간접 영향을 줬는지와 “어느 다음 head의 Q·K·V input에 영향을 줬는지”를 구분하려 한다. 논문은 END→logits에서 Name Mover를 찾고, Name Mover query를 바꾸는 S-Inhibition으로 역추적하는 식으로 circuit을 발견했다.원 논문 3절·Appendix B
| 기준 | 질문 | 실패 뜻 |
|---|---|---|
| faithfulness(충실도·근거성) | circuit만 남겨도 task를 푸나 | 발견 node가 충분하지 않음 |
| completeness(완전성) | circuit 밖을 지워도 task가 유지되나 | 중요한 node를 빼먹음 |
| minimality(최소성) | circuit 안 node가 모두 필요한가 | 불필요 node가 섞임 |
논문은 naive circuit보다 크게 개선했지만 가장 어려운 test를 모두 통과하지는 못했다고 보고한다. Backup Name Mover는 regular Name Mover를 ablate할 때만 등장해 intervention이 redundant computation을 드러내는 문제를 보였다.원 논문 4절
직접 검증과 재현 — task algorithm과 logit difference
직접 실행 확인이다. 2026-07-24, Python 3.9.6 표준 라이브러리로 IOI name rule과 식 (1)을 실행했다. GPT-2 weight·26 head·path patching을 재현한 실험은 아니다.
name occurrences in IOI template: ['Mary', 'John', 'John']
remove duplicated subject: Mary
logit difference IO minus S: 3.500000
checks passed
파일은 /tmp/ioi-circuit-research/verify_ioi.py다. 4.2−0.7=3.5가 양수임을 확인했다. 논문 circuit의 가치는 이 간단 algorithm을 GPT-2 residual stream에서 누가 어느 path로 구현하는지 찾는 데 있다.
성능과 트레이드오프 — 26 heads는 검증 시작점이다
논문 circuit은 26 attention head, 전체 head-position pair의 1.1%다. 작아 보여도 7 class와 redundant route가 있어 모든 edge effect를 test하는 비용은 크다. Larger model은 layer·head·position과 MLP feature 후보가 더 많아 circuit search가 급격히 어렵다.
| 방법 | 얻는 것 | 함정 |
|---|---|---|
| attention pattern | 역할 가설 | copying·causal role 미보장 |
| DLA | direct output alignment | indirect effect 누락 |
| mean ablation | constant signal 보존 | reference distribution 의존 |
| path patching | sender→receiver edge effect | 많은 forward pass·template 설계 |
| knockout | circuit function test | backup·self-repair |
IOI처럼 controlled distribution에서 성공한 workflow를 자연 대화·RAG에 가져가려면 answer target, counterfactual data, retrieval·reranker·generation 단계를 분리해야 한다. 이 논문의 실무 가치는 head 번호를 복사하는 일이 아니라 발견과 검증을 분리한 workflow다.
재현 실험을 설계하는 순서
IOI와 같은 circuit claim을 다시 검증하려면 순서를 뒤집지 않는다. 먼저 full model의 task metric을 고정한다. 다음으로 다른 이름·template에도 같은 output이 나오는지 확인한다. 그 뒤 output에 직접 쓰는 candidate를 찾고, candidate가 어디서 query·key·value 정보를 받는지 path patching으로 뒤로 추적한다. 마지막에 circuit만 남긴 실행과 circuit 밖 제거 실행, circuit 안 한 component 제거 실행을 각각 비교한다. 이 세 비교가 없으면 발견한 head 목록은 흥미로운 correlation일 수는 있어도 circuit explanation이라 부르기 어렵다.
특히 counterfactual sentence는 문법만 바뀌어서는 안 되고, 검증하려는 information variable만 바뀌어야 한다. IOI에서 pABC가 필요한 이유도 이것이다. A·B·C 이름을 무작위로 바꾸면서 template 역할은 유지해, “누가 중복인지”라는 task signal을 mean ablation reference에서 제거하려 했다. 이 설계가 나쁘면 patch 결과가 name identity가 아니라 문장 이상함 또는 token frequency 차이를 측정하게 된다. production prompt를 분석할 때도 같은 원칙으로 base prompt와 counterfactual prompt를 만든다.
Circuit 설명은 model behavior를 사람이 원하는 방식으로 다시 서술하는 일이 아니다. 정해 둔 metric이 intervention 뒤에도 유지되는지, 반대로 필요한 edge를 바꾸면 metric이 실제로 무너지는지를 반복하는 반증 가능한 주장이다. 그래서 예쁜 visualization보다 fixture, metric, reference distribution, patch 위치, seed와 실패 결과가 중요하다.
실패와 운영 기준 — attention 그림만으로 Mary를 설명하지 않기
- IO에 attention한다고 Name Mover라고 부르지 않는다. output이 IO logit 방향에 쓰이는지 본다.
- Zero ablation 결과를 feature necessity로 해석하지 않는다. mean·resample baseline을 대조한다.
- Reference distribution이 task signal을 남기면 knockout이 불완전하다.
- Circuit 밖과 안의 knockout을 모두 해 faithfulness·completeness·minimality를 분리한다.
- GPT-2 small layer.head 번호를 다른 architecture·tokenizer에 일반화하지 않는다.
IOI circuit이 한 task를 설명해도 LLM security가 해결되는 것은 아니다. Prompt injection, tool authorization, data access는 input·output boundary에서 별도 통제해야 한다.
대안과 선택 기준 — 질문에 맞는 검증을 고른다
| 질문 | 첫 실험 | 추가 검증 |
|---|---|---|
| structured next-token task | template·contrast token·logit diff | pABC 같은 counterfactual |
| name copying 오류 | Name Mover 후보 | tokenizer·name frequency control |
| head necessity | knockout | patching·self-repair |
| path 정보 흐름 | QK·OV composition | edge·path patching |
| large model feature | head class 후보 | SAE·feature intervention |
흔한 오해와 최초 질문에 대한 답
IOI circuit은 GPT-2가 문법을 이해했다는 증명인가
아니다. 한 template distribution에서 human-interpretable algorithm과 맞는 circuit explanation이다. 일반 자연어 이해 전체 증명이 아니다.
26 heads만 남기면 GPT-2가 완전히 같은 model인가
아니다. IOI behavior의 부분 그래프다. 논문도 세 validation 기준에서 남은 gap을 보고했다.
Backup Name Mover는 발견 실패인가
아니다. Regular head knockout 뒤에 드러난 redundant route다. Intervention이 model behavior를 바꿀 수 있다는 경고다.
Induction Head와 IOI는 어떻게 연결되나
IOI induction head는 Previous Token Head가 만든 정보로 S2가 S1 다음 위치를 찾아 duplicate signal을 만든다. IOI 전체는 inhibition·name movement·backup까지 포함한 더 큰 circuit이다.
출처 및 검증 경로
1차 자료
- Wang 외. Interpretability in the Wild — A Circuit for Indirect Object Identification in GPT-2 Small — Section 1–4, Appendices B·E·J을 직접 확인했다.
- Elhage 외. A Mathematical Framework for Transformer Circuits — residual stream·QK·OV circuit 배경이다.
- Olsson 외. In-context Learning and Induction Heads — IOI circuit의 induction·previous-token head 배경이다.
직접 실행 기록
- 환경 — macOS, Python 3.9.6, 외부 library 없음.
- 파일 —
/tmp/ioi-circuit-research/verify_ioi.py. - 검증 — IO, S1, S2 name occurrence에서 duplicated S 제거와 IO-S logit difference 계산.
- 한계 — GPT-2 small checkpoint, pIOI·pABC 100,000 sample, 26 head path patching과 mean ablation을 재현하지 않았다.
댓글