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:
Antigravity Agent
2026-07-05 00:33:48 +09:00
parent 1cfd3bbb56
commit 9148c358d0
6455 changed files with 1 additions and 86875 deletions
@@ -0,0 +1,229 @@
---
id: wiki-2026-0508-feature-clamping-피처-고정
title: Feature Clamping (피처 고정)
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [feature clamping, activation clamping, SAE feature steering, mechanistic intervention]
duplicate_of: none
source_trust_level: A
confidence_score: 0.92
verification_status: applied
tags: [interpretability, mechanistic, sae, feature-clamping, anthropic, steering]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: Python
framework: TransformerLens / PyTorch / Anthropic SAE
---
# Feature Clamping (피처 고정)
## 매 한 줄
> **"매 SAE feature 의 activation 의 specific value 의 force"**. 매 model behavior 의 causally test. Anthropic 'Towards Monosemanticity' (2023), 'Golden Gate Claude' (2024). 매 mechanistic interpretability + 매 model steering 의 핵심 도구.
## 매 핵심
### 매 mechanism
1. **SAE 학습**: 매 layer activation → 매 sparse feature.
2. **Identify feature**: 매 interpret what feature represents.
3. **Clamp**: 매 forward pass 의 의 의 feature value 의 fix.
4. **Observe**: 매 output behavior change.
### 매 응용
- **Causal understanding**: 매 feature → behavior.
- **Steering**: 매 desired behavior 의 amplify.
- **Refusal modify**: 매 safety adjust (carefully).
- **Concept editing**: 매 specific concept 의 emphasize.
### 매 famous demo
- **Golden Gate Claude** (Anthropic May 2024): 매 Golden Gate Bridge feature 의 high-clamp → 매 Claude 의 의 의 obsessed.
- **Refusal feature**: 매 clamp = 매 always-refuse or never-refuse.
- **Sycophancy feature**: 매 clamp 의 study.
### 매 trade-off
- ✅ Causal evidence.
- ✅ Steering control.
- ❌ Other capabilities 의 degrade (over-clamp).
- ❌ SAE feature 의 monosemantic 의 X (often).
## 💻 패턴
### Basic SAE clamp
```python
import torch
def clamp_feature(model, layer, sae, feature_idx, value):
"""매 forward pass 시 의 feature 의 fix."""
def hook(module, input, output):
z = sae.encode(output)
z[:, :, feature_idx] = value # 매 clamp
return sae.decode(z)
handle = model.transformer.h[layer].register_forward_hook(hook)
return handle # 매 unregister 시 handle.remove()
```
### Steered generation
```python
def generate_with_clamp(model, sae, layer, feature_idx, value, prompt, max_tokens=100):
handle = clamp_feature(model, layer, sae, feature_idx, value)
try:
return model.generate(prompt, max_new_tokens=max_tokens)
finally:
handle.remove()
```
### Multi-feature clamp
```python
def clamp_multi(model, layer, sae, features: dict):
def hook(module, input, output):
z = sae.encode(output)
for idx, val in features.items():
z[:, :, idx] = val
return sae.decode(z)
return model.transformer.h[layer].register_forward_hook(hook)
# 매 example: amplify "kindness", suppress "hostility"
features = {KINDNESS_FEATURE: 5.0, HOSTILITY_FEATURE: 0.0}
```
### Identify feature (find by activation)
```python
def find_feature_for_concept(sae, examples_of_concept):
"""매 매 example 매 매 max-activating feature."""
activations = []
for ex in examples_of_concept:
with model.run_with_cache(ex) as cache:
z = sae.encode(cache[layer])
activations.append(z.max(dim=1).values)
avg_activation = torch.stack(activations).mean(0)
return avg_activation.topk(10).indices
```
### Causal trace (clamp ablation)
```python
def ablation_study(model, sae, feature_idx, prompts):
"""매 feature 의 ablate (=0) → 매 behavior shift."""
results = {'normal': [], 'ablated': []}
# 매 normal
for p in prompts:
results['normal'].append(model.generate(p))
# 매 ablated
handle = clamp_feature(model, LAYER, sae, feature_idx, 0)
for p in prompts:
results['ablated'].append(model.generate(p))
handle.remove()
return results
```
### Saturation level (Golden Gate-style)
```python
def saturation_clamp(model, sae, layer, feature_idx, levels=[0, 1, 5, 10, 50]):
outputs = {}
for v in levels:
handle = clamp_feature(model, layer, sae, feature_idx, v)
outputs[v] = model.generate("Tell me about yourself.", max_new_tokens=100)
handle.remove()
return outputs
```
### Refusal feature
```python
# 매 careful — safety implication
REFUSAL_FEATURES = [...] # 매 from interpretability research
def adjust_refusal(model, sae, level):
"""매 level: 0 = unrestricted, 1 = normal, 2 = strict."""
if level == 0: value = -2.0 # 매 suppress
elif level == 1: value = None # 매 don't clamp
else: value = 5.0 # 매 amplify
if value is not None:
return clamp_feature(model, LAYER, sae, REFUSAL_FEATURES[0], value)
return None
```
### Train SAE
```python
class SparseAutoencoder(torch.nn.Module):
def __init__(self, d_model, d_sae, l1_coef=1e-3):
super().__init__()
self.W_enc = torch.nn.Linear(d_model, d_sae)
self.W_dec = torch.nn.Linear(d_sae, d_model, bias=False)
self.l1_coef = l1_coef
def forward(self, x):
z = torch.relu(self.W_enc(x))
x_recon = self.W_dec(z)
loss = ((x - x_recon) ** 2).mean() + self.l1_coef * z.abs().sum(-1).mean()
return x_recon, z, loss
```
### Activation patching (alternative)
```python
def patch_activation(model, layer, source_run_cache, target_prompt):
def hook(module, input, output):
return source_run_cache[layer]
h = model.transformer.h[layer].register_forward_hook(hook)
out = model.generate(target_prompt)
h.remove()
return out
```
### Eval (specificity)
```python
def evaluate_clamp(model, sae, feature_idx, value, target_topic, neutral_topics):
"""매 clamp 의 target 의 affect, 매 neutral 매 not."""
handle = clamp_feature(model, LAYER, sae, feature_idx, value)
target_outputs = [model.generate(p) for p in target_topic]
neutral_outputs = [model.generate(p) for p in neutral_topics]
handle.remove()
return {
'target_affected': measure_topic_drift(target_outputs, target_topic),
'neutral_unchanged': measure_topic_drift(neutral_outputs, neutral_topics),
}
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Mechanistic study | Clamp + ablate |
| Behavior steering | Clamp at moderate level |
| Concept editing | Multi-feature clamp |
| Safety study | Refusal feature (research only) |
| Demo | Saturation clamp (Golden Gate) |
**기본값**: 매 SAE 학습 → 매 feature 의 identify → 매 clamp + 매 ablate causal evidence + 매 specificity eval.
## 🔗 Graph
- 부모: [[Mechanistic-Interpretability]] · [[Explainable-AI-XAI]]
- 변형: [[Activation-Patching]]
- Adjacent: [[Sparse-Autoencoder]]
## 🤖 LLM 활용
**언제**: 매 interpretability research. 매 alignment study.
**언제 X**: 매 production user-facing (unstable).
## ❌ 안티패턴
- **High clamp 의 production**: 매 capability degrade.
- **Single-feature 의 trust**: 매 monosemanticity 의 false.
- **No specificity eval**: 매 unwanted side effect.
- **Refusal manipulation**: 매 safety 의 break.
## 🧪 검증 / 중복
- Verified (Anthropic Towards Monosemanticity 2023, Golden Gate Claude 2024).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-04-26 | CLAMP auto |
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — clamp + 매 SAE / hook / ablation / saturation code |