6.3.6 · HinglishInterpretability & Explainability

Mechanistic interpretability

3,066 words14 min readRead in English

6.3.6 · AI-ML › Interpretability & Explainability

Mechanistic Interpretability Kya Hai?

Yeh kyun zaroori hai:

  1. Safety: Failure modes samajhne ke liye algorithm jaanna zaroori hai, sirf activations nahi
  2. Scientific understanding: Neural networks novel algorithms implement kar sakte hain jinse hum seekh sakte hain
  3. Debugging: Dhundho kahan computation galat ho rahi hai, na ki sirf kahan output galat hai
  4. Alignment: Ensure karo ki models us tarah reason karein jaise hum sochte hain woh karte hain

Core Principles & Approach

1. Circuits Hypothesis

First principles se derivation:

Ek transformer layer computation se shuru karo. Real transformers LayerNorm apply karte hain (ya to pre-norm ya post-norm). Common pre-norm form likhte hain:

LayerNorm explicitly kyun include karein? Normalization ki placement change karti hai ki nonlinearities kahan act karte hain, aur yeh residual-stream picture ke liye essential hai — yeh normalize karta hai ki har sublayer residual stream se kya padhta hai jabki stream khud raw sums accumulate karta rehta hai. Ise drop karna (jaise bare ) actual computation ko misrepresent karta hai.

Ab attention sublayer ko decompose karo. heads mein se har ek value-weighted sum compute karta hai, phir saare head outputs concatenate hote hain aur ek single output matrix apply hoti hai:

Equivalently, ko per-head blocks mein split karke jo har head ke slice par act karte hain, hum additive-over-heads form likh sakte hain:

Yahan independent projection matrices nahi hain — yeh single shared ke column-blocks hain. factor kyun? Yeh dot-product logits ko rescale karta hai taaki unka variance rahe regardless of head dimension , softmax ko saturation se baahir rakhta hai. Yeh decomposition kyun? Kyunki empirically, individual heads aksar distinct operations perform karte hain (jaise "previous token head", "induction head").

Ek circuit in heads + MLP neurons ka subset hota hai jo:

  1. Output par strong causal effect rakhta ho
  2. Ek coherent algorithm implement karta ho
  3. Minimally sufficient ho (components hatane se functionality toot jaaye)

2. Activation Patching & Causal Analysis

Sirf ablation ki bajaye patching kyun?

  • Ablation batata hai ki component matter karta hai ya nahi
  • Patching batata hai ki yeh kaunsi information compute karta hai aur kahan woh information flow karti hai

Patching method ki derivation:

Do inputs aur consider karo jahan model clean par succeed karta hai lekin corrupted par fail karta hai.

Maan lo component ki activation hai clean input par. Patching experiment:

Agar performance recover ho jaaye, component correct computation ko causally mediate karta hai.

Yeh kyun kaam karta hai: Agar success ke liye zaroori key information compute karta hai, toh us computation ko transplant karna functionality restore karta hai.

3. Superposition & Polysemanticity

Information theory se derivation:

Available capacity: dimensions Required features: features, har ek probability ke saath active

Agar features orthogonal hote, toh humein dimensions chahiye hote. Lekin sparsity ke saath:

  • Expected simultaneous features:
  • Agar , hum superposition ke zariye features pack kar sakte hain

Cost: Jab multiple features ek saath activate hote hain toh features ke beech interference.

Mathematical model (simplified toy example):

Feature vectors optimize karo interference minimize karne ke liye:

jahan orthonormal basis vectors hain ("ideal" non-interfering representation).

Consequence: Individual neurons polysemantic hote hain — yeh multiple unrelated features par respond karte hain.

Key Techniques

Logit Lens & Tuned Lens

Yeh kyun kaam karta hai:

Transformers mein, residual stream information accumulate karta hai:

Agar information linearly represented hai, toh early layers mein already partial "answers" hone chahiye jo unembedding matrix padh sake.

Derivation:

Final prediction hai:

Intermediate layer ke liye:

ko se compare karna batata hai ki predictions layers across kaise evolve hoti hain.

Attention Pattern Analysis

Common interpretable patterns:

  1. Previous token head:
  2. Induction head: high hota hai jab position par token position ke token se match karta hai (pattern completion)
  3. Duplicate token head: high hota hai jab positions aur par tokens identical hain

Patterns analyze kyun karein? Attention positions ke beech information move karne ka main mechanism hai. Pattern routing algorithm reveal karta hai.

Doosre Interpretability Methods Se Connections

vs. Feature visualization:

  • Feature viz dikhata hai ki component KYA respond karta hai
  • Mechanistic interpretability dikhati hai ki yeh KAISE compute karta hai aur yeh output ke liye KYU matter karta hai

vs. Saliency methods:

  • Saliency ek single decision ke liye importance dikhata hai
  • Mechanistic interpretability general algorithm dhundti hai

vs. Probing:

  • Probing: "Kya information X present hai?"
  • Mechanistic: "X kaise compute aur use hoti hai?"

Applications & Implications

  1. AI Safety: Deployment se pehle deceptive reasoning circuits detect karo
  2. Capability analysis: Samjho ki model kya seekh sakta hai uski limits kya hain
  3. Scientific discovery: Networks novel algorithms implement kar sakte hain jo humans ne design nahi kiye
  4. Model editing: Specific circuits target karke behavior surgically modify karo
Recall Ek 12-saal ke bacche ko explain karo

Socho tumhe ek super advanced alien computer mila hai jo chess bahut accha khelti hai, lekin tum samajh nahi rahe ki andar kaise kaam karta hai. Tumhare paas ise figure out karne ke do tarike hain: Purana tarika (regular interpretability): Dekho ise khelते aur notice karo "oh, jab board par queen hoti hai, yeh light blink karti hai." Tum sirf bahar se patterns notice kar rahe ho.

Naya tarika (mechanistic interpretability): Tum carefully ise kholo aur wires trace karo. Tumhein pata chalta hai ki parts ka ek group milkar "aisi pieces dhundta hai jo capture ho sakti hain", doosra group "evaluate karta hai ki king safe hai ya nahi", aur yeh groups ek specific tarike se connected hain decisions lene ke liye. Tumne woh actual step-by-step recipe figure out kar li jo computer use karta hai!

Mechanistic interpretability aise detective ki tarah hai jo sirf yeh nahi dekhta ki AI kya karta hai, balki actual "recipe" ya "algorithm" figure out karta hai jo woh follow kar raha hai, step by step, wire by wire. Yeh bahut zaroori hai kyunki agar hum AI par important decisions ke liye trust karne wale hain, toh hume sirf YEH nahi samajhna ki woh KYA decide karta hai, balki yeh bhi ki WOH KAISE SOCHTA HAI!

Connections

  • Feature Visualization — complementary: WHAT dikhata hai, mechanistic HOW dikhata hai
  • Attention Mechanisms — attention patterns study ka primary object hain
  • Sparse Autoencoders — polysemantic neurons decompose karne ka tool
  • Transformer Architecture — residual stream structure mechanistic analysis enable karta hai
  • Probing Classifiers — related lekin different: presence vs. computation
  • Model Editing — mechanistic understanding ke applications

#flashcards/ai-ml

Mechanistic interpretability kya hai aur yeh post-hoc interpretability se kaise differ karti hai? :: Mechanistic interpretability neural networks ke learned algorithms ko reverse-engineer karti hai individual components aur circuits analyze karke. Post-hoc interpretability decisions ke baad unhe explain karti hai; mechanistic interpretability woh computational mechanism explain karti hai jo decisions produce karta hai.

Circuits Hypothesis kya hai?
Yeh hypothesis ki neural networks circuits se bane hote hain — sparse subgraphs jo specific, interpretable algorithms implement karte hain. Har circuit ek human-understandable computation perform karta hai jaise edge detection ya pattern completion.
Attention score mein 1/√d_k scaling factor kyun hota hai?
Yeh query-key dot products ko rescale karta hai taaki unka variance approximately 1 rahe regardless of head dimension d_k, softmax ko uski saturated regime se baahir rakhta hai aur useful gradients preserve karta hai.
Multi-head attention mein, kya har head ke liye alag output matrix W_O hoti hai?
Nahi. H head outputs concatenate hote hain aur ek single shared output matrix W_O apply hoti hai. Per-head blocks W_O^(i) sirf us ek W_O ke column-slices hain, jo tumhein attention ko heads par additive sum ke roop mein likhne deta hai.
Activation patching kya hai aur yeh ablation se zyada powerful kyun hai?
Activation patching ek run ki activations ko doosre run ki activations se replace karta hai yeh test karne ke liye ki behavior transfer hota hai ya nahi. Yeh ablation se zyada powerful hai kyunki ablation sirf dikhata hai ki component matter karta hai ya nahi, jabki patching dikhata hai ki yeh KAUNSI information compute karta hai aur WOH information KAHAN flow karti hai.
Superposition kya hai aur yeh polysemanticity kyun cause karta hai?
Superposition tab hota hai jab networks apne dimensions se zyada features represent karte hain features ko non-orthogonal directions ke roop mein encode karke. Yeh polysemanticity cause karta hai (neurons multiple unrelated features par respond karte hain) kyunki features ek doosre ke saath interfere karte hain jab woh orthogonal nahi hote.
Logit lens technique kya hai?
Ek technique jo intermediate layer activations ko directly vocabulary logits mein project karti hai yeh reveal karne ke liye ki model har layer par kya "sochta" hai. Yeh kaam karta hai kyunki residual stream information linearly accumulate karta hai, toh early layers mein partial "answers" hote hain jo unembedding matrix padh sakti hai.
Induction head kya hai aur yeh kaunsa algorithm implement karta hai?
Ek induction head ek attention pattern hai jo repeated sequences complete karta hai. Yeh implement karta hai: "Current token ki previous occurrence dhundo, phir jo uske baad aaya tha use copy karo." Example: "A B ... A B" mein, yeh predict karta hai ki agla token wahi hona chahiye jo pehle "A B" ke baad aaya tha.
Neuron activation aur ek concept ke beech correlation yeh claim karne ke liye insufficient kyun hai ki neuron woh concept "detect" karta hai?
Correlation yeh prove nahi karta ki neuron woh concept COMPUTE karta hai — yeh spurious correlation ho sakta hai, aur yeh explain nahi karta ki neuron decisions mein KAISE contribute karta hai. Computational role verify karne ke liye causal methods (patching, ablation) use karne chahiye.

Dictionary learning polysemantic neurons decompose karne mein kaise help karta hai? :: Dictionary learning L1 penalty ke saath sparsity ke liye ek overcomplete basis (dimensions se zyada features) dhundta hai. Yeh ek single polysemantic neuron ko multiple interpretable features mein decompose karta hai jo superposition mein the, alag-alag computations ko separate karta hai.

Neural network mein circuit identify karne ke liye teen criteria kya hain?
1) Output par strong causal effect (ablation/patching ke zariye), 2) Ek coherent algorithm implement karta hai jo human-understandable ho, 3) Minimally sufficient ho (koi bhi component hatane se functionality toot jaaye).

Concept Map

contrasts with

reverse-engineers

analyzes

compose into

implement

enables

accumulates sums from

accumulates sums from

normalizes reads from

decomposed into

decomposed into

Mechanistic Interpretability

Post-hoc Interpretability

Learned Algorithms

Network Components

Circuits Hypothesis

Residual Stream

Attention Heads

MLP Sublayers

LayerNorm

Safety and Alignment