docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
---
|
||||
id: wiki-2026-0508-mechanistic-interpretability-기계적
|
||||
title: Mechanistic Interpretability (기계적 해석 가능성)
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [Mech Interp, Circuit Analysis, MI, 기계적 해석성]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [ai, interpretability, alignment, anthropic, transformer, safety]
|
||||
raw_sources: [Anthropic Transformer Circuits, Towards Monosemanticity, Scaling Monosemanticity]
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack: { language: python, framework: transformer-lens-sae-lens }
|
||||
---
|
||||
|
||||
# Mechanistic Interpretability (기계적 해석 가능성)
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 뉴런을 회로로 읽는다"**. 모델 내부를 black-box 통계가 아니라 명시적 알고리즘(회로/feature)으로 reverse-engineer 하는 분야. Anthropic의 SAE/circuit 연구가 주축.
|
||||
|
||||
## 매 핵심
|
||||
### 매 핵심 개념
|
||||
- **Circuit**: 특정 행동을 구현하는 attention head + MLP 신경 sub-graph.
|
||||
- **Feature**: 활성화 공간의 의미 단위 (한 방향 벡터).
|
||||
- **Polysemanticity**: 한 뉴런이 여러 개념 인코딩 → superposition.
|
||||
- **SAE (Sparse Autoencoder)**: superposition을 풀어 monosemantic feature 추출.
|
||||
- **Probing / Logit Lens / Activation Patching**: 진단 도구.
|
||||
|
||||
### 매 핵심 발견
|
||||
1. **Induction heads** (2022) - in-context learning 구현 회로.
|
||||
2. **IOI circuit** (2022) - Indirect Object Identification.
|
||||
3. **Toy Models of Superposition** (2022) - feature가 압축되는 이유.
|
||||
4. **Towards Monosemanticity** (2023) - SAE로 feature 추출 가능.
|
||||
5. **Scaling Monosemanticity** (2024) - Claude 3 Sonnet에 SAE 적용, "Golden Gate Bridge feature" 등.
|
||||
6. **Circuit Tracing / Attribution Graphs** (2025) - feature 간 인과 추적.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Pattern 1 — TransformerLens (회로 분석)
|
||||
```python
|
||||
import transformer_lens as tl
|
||||
model = tl.HookedTransformer.from_pretrained('gpt2-small')
|
||||
logits, cache = model.run_with_cache("The capital of France is")
|
||||
# cache['blocks.5.attn.hook_pattern'] - attention 패턴 검사
|
||||
```
|
||||
|
||||
### Pattern 2 — Activation Patching
|
||||
```python
|
||||
def patch_hook(act, hook):
|
||||
act[:, pos] = clean_cache[hook.name][:, pos]
|
||||
return act
|
||||
patched = model.run_with_hooks(corrupted, fwd_hooks=[(name, patch_hook)])
|
||||
# 어느 위치/layer가 차이를 만드는지 인과 측정
|
||||
```
|
||||
|
||||
### Pattern 3 — Logit Lens
|
||||
```python
|
||||
for layer in range(model.cfg.n_layers):
|
||||
resid = cache[f'blocks.{layer}.hook_resid_post']
|
||||
logits = model.unembed(model.ln_final(resid))
|
||||
print(layer, model.to_str_tokens(logits.argmax(-1)[0, -1]))
|
||||
```
|
||||
|
||||
### Pattern 4 — Sparse Autoencoder
|
||||
```python
|
||||
import torch.nn as nn
|
||||
class SAE(nn.Module):
|
||||
def __init__(self, d_model, d_sae):
|
||||
super().__init__()
|
||||
self.W_enc = nn.Linear(d_model, d_sae)
|
||||
self.W_dec = nn.Linear(d_sae, d_model, bias=False)
|
||||
def forward(self, x):
|
||||
f = torch.relu(self.W_enc(x)) # sparse activations
|
||||
return self.W_dec(f), f
|
||||
# Loss = recon + λ·||f||_1
|
||||
```
|
||||
|
||||
### Pattern 5 — Feature Attribution (sae-lens)
|
||||
```python
|
||||
from sae_lens import SAE
|
||||
sae = SAE.from_pretrained('gpt2-small-res-jb', 'blocks.8.hook_resid_pre')
|
||||
features = sae.encode(activations)
|
||||
top_features = features.topk(10, dim=-1)
|
||||
```
|
||||
|
||||
### Pattern 6 — Causal Steering
|
||||
```python
|
||||
# Golden Gate Claude 식: feature 활성화 강제
|
||||
def steer(act, hook, feature_idx, scale):
|
||||
act += scale * sae.W_dec[feature_idx]
|
||||
return act
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 목표 | 도구 |
|
||||
|---|---|
|
||||
| 작은 모델 회로 발견 | TransformerLens + activation patching |
|
||||
| Feature 추출 (큰 모델) | SAE (sae-lens, dictionary_learning) |
|
||||
| 행동 인과성 검증 | Activation patching, ablation |
|
||||
| Feature 간 관계 | Attribution graphs / circuit tracing |
|
||||
| 안전 alignment | Steering vectors, refusal feature |
|
||||
| Production 배포 | 아직 일러 — 연구 단계 |
|
||||
|
||||
**기본값**: 2026 기준 SAE + circuit tracing이 메인 파라다임.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[AI_Safety_and_Alignment|AI-Alignment]]
|
||||
- 변형: [[Sparse-Autoencoder]], [[Circuit-Analysis]], [[Activation-Patching]]
|
||||
- 응용: [[AI Safety]]
|
||||
- Adjacent: [[Transformer_Architecture_and_LLM_Foundations|Transformer-Architecture]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**:
|
||||
- 논문 요약 (Anthropic transformer-circuits.pub).
|
||||
- TransformerLens / sae-lens 코드 작성.
|
||||
- 가설 생성 (어떤 회로가 행동 X를 만드는가?).
|
||||
|
||||
**언제 X**:
|
||||
- 새로운 mech interp 발견 주장 (실험 필수).
|
||||
- 특정 feature ID의 의미 단정 (모델별 다름).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- Single neuron = single concept 가정 (superposition 무시).
|
||||
- Probing 정확도 = 회로 존재 (correlational, 인과 X).
|
||||
- Attention 시각화만으로 결론 (MLP가 더 큰 역할 종종).
|
||||
- SAE feature = ground truth 가정 (해석은 hypothesis).
|
||||
- Toy model 결론을 frontier model에 무비판 외삽.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified. Anthropic 2024-2025 SAE 결과 기준. 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup |
|
||||
Reference in New Issue
Block a user