6.3.9 · HinglishInterpretability & Explainability

Activation patching

2,337 words11 min readRead in English

6.3.9 · AI-ML › Interpretability & Explainability

Activation patching ek causal intervention technique hai mechanistic interpretability mein jo kisi component (neuron, attention head, layer) ke specific role ko isolate karta hai — ek input ki activations ko doosre input ki activations se replace karke, phir model behavior par downstream effect measure karke.

Figure — Activation patching

Core Intuition

Sirf Attention Weights Kyun Nahi Dekhte?

Attention weights correlation dikhate hain, causation nahi. Ek head pronouns par attend kar sakta hai lekin us information ka actual use nahi karta. Patching test karta hai: "Agar mein is component ki clean input dekhne ki ability hata dun, to kya model ka behavior badlega?"

The Mechanism

Worked Examples

Common Mistakes

Variants & Extensions

1. Activation Addition (Opposite Direction)

Clean activations se replace karne ki bajaye, ek steering vector add karo:

Use hota hai: Capabilities enhance karne ke liye (jaise, translation mein "zyada French-ness add karo")

2. Path Patching

Poori layer patch mat karo — sirf component A → component B tak ki path patch karo.

Kyun? Direct vs. indirect effects isolate karta hai. Ho sakta hai head 3.2 directly task solve nahi karta, lekin head 5.1 ko feed karta hai jo karta hai.

Technique: Specifically A→B se residual stream contribution replace karo, baaki paths intact rakhho.

3. Iterative Patching

Components ko sequence mein patch karo, hamesha previous steps ke best patches rakhte hue. Ek minimal circuit build karta hai jo behavior explain kare.

Connections

  • Mechanistic Interpretability: Activation patching circuit discovery ke liye primary tool hai
  • Causal Scrubbing: Formalization jo patching ko ground-truth circuits ke saath generalize karta hai
  • Ablation Studies: Components remove karna "zeros se patch karna" hai — counterfactual patching se kam informative
  • Logit Lens: Patching ka complement jo dikhata hai ki kya representations exist karte hain; patching dikhata hai kyun woh matter karte hain
  • Causal Mediation Analysis: Statistical framework jise patching neural networks ke liye implement karta hai

Active Recall

Recall Ek 12-saal ke bachche ko explain karo

Socho tumhara dimaag ek math problem solve kar raha hai, lekin ek part galat number deta hai. Tum figure out karna chahte ho: "Mere dimaag ka kaun sa hissa gadbad kar raha tha?"

Yeh karo: Problem do baar solve karo. Pehli baar galat ho jaata hai. Doosri baar, koi tumhare dimaag mein sirf ek step ke liye sahi number whisper karta hai. Agar achanak poori problem sahi ho jaaye, to tum jaante ho: "Aha! Woh step wahi tha jo matter karta tha!"

Yahi hai activation patching. Hum ek robot brain (neural network) ko kuch galat karte hue lete hain, aur secretly use ek tiny hisse ke liye "correct" information dete hain. Agar robot achanak kaam karne lage, to hum jaante hain woh hissa super important tha. Yeh detective banne jaisa hai, lekin robot thoughts ke liye!

#flashcards/ai-ml

Activation patching kya hai? :: Ek causal intervention technique jahan tum ek component ki activations ko corrupted run se clean run ki activations se replace karte ho, phir measure karte ho ki behavior restore hota hai ya nahi — yeh prove karte hue ki woh component sahi behavior ke liye causally responsible tha.

Activation magnitude measure karne se patching behtar kyun hai? :: Activation magnitude correlation dikhati hai (kya saath fire karta hai), lekin patching causation dikhata hai (kya actually necessary hai). Ek neuron strongly activate kar sakta hai lekin redundant ya epiphenomenal ho sakta hai.

Causal effect ka formula likho aur har term explain karo :: . Yeh component C patch karne par loss reduction measure karta hai. Positive Δ matlab patching ne help ki (loss kam hua), bade values matlab stronger causal role.

Patching aur ablation mein kya difference hai?
Ablation ek component remove karta hai (zero/mean par set karta hai), dikhata hai kya hota hai uske bina. Patching ek counterfactual activation se replace karta hai, dikhata hai kya hota hai different information ke saath. Patching cleaner causal attribution deta hai.
Tum head 4.2 patch karte ho aur behavior nahi badlta. Iska kya matlab hai?
Head 4.2 is specific behavior ke liye causally important nahi hai, chahe woh activate bhi kare. Yeh redundant, epiphenomenal, ya kisi doosre task par kaam kar raha ho sakta hai.
Path patching kya hai?
Sirf component A se component B tak ke specific information flow ko patch karna, baaki paths intact rakhte hue. Direct causal effects ko indirect ones se isolate karta hai.
Tum kaise detect karte ho ki do components redundant hain ya synergistic?
Synergy calculate karo = Δ(A∪B) - (ΔA + ΔB). Negative synergy matlab redundant (overlap), positive matlab synergistic (woh cooperate karte hain), zero matlab independent.
Tumhara metric tumhare research question se match kyun karna chahiye?
Generic metrics (jaise overall cross-entropy) saare behaviors par average karte hain. Agar tum toxicity detection study kar rahe ho, to tumhein specific toxic token logit measure karna hoga, na ki saare tokens par average loss.

Concept Map

is a

isolates role of

provides

run with

replaces C in

measured by

quantifies

large positive means

shows correlation only, so use

Activation patching

Causal intervention

Clean input x_clean

Corrupted input x_corrupt

Target component C

Patched run

Causal effect delta_C

Loss vs clean answer

Attention weights

Clean activation

Causally important