// Layer deep-dive: components strip + per-head attention breakdown + top features const { useMemo: useMemoLD } = React; function LayerDeepDive({ selected, onPickCell }) { const { layer, component } = selected; const allComps = AtlasData.COMPONENTS; const isAttn = ['heads', 'q', 'k', 'v'].includes(component); const headLikeComp = isAttn ? component : 'heads'; const heads = useMemoLD( () => (AtlasData.headBreakdown ? AtlasData.headBreakdown(layer, headLikeComp) : []), [layer, headLikeComp] ); const feats = useMemoLD( () => (AtlasData.topFeatures ? AtlasData.topFeatures(layer, component) : []), [layer, component] ); const componentRow = AtlasData.FSTAT[layer] || []; const compIndex = allComps.findIndex(c => c.id === component); const cellVal = componentRow[compIndex]; return (
Layer deep-dive
L{layer} · {component}
position {(layer / Math.max(1, AtlasData.N_LAYERS - 1) * 100).toFixed(0)}% through stack · kind {allComps.find(c => c.id === component)?.kind || '—'} · F-stat {Number.isFinite(cellVal) ? cellVal.toFixed(2) : '—'}
Components in this layer
{allComps.map((c, ci) => { const v = componentRow[ci]; const active = c.id === component; const hasData = Number.isFinite(v); return ( ); })}
{isAttn ? <>Attention {component} heads · top_sep_score : <>Heads in this layer · top_sep_score}
{heads.length === 0 ? (
No per-head data for L{layer} · {headLikeComp} yet — this layer hasn't been ingested.
) : (
{heads.map((h) => (
H{String(h.head).padStart(2, '0')} {h.role} {h.fstat.toFixed(2)}
))}
)} {heads.length > 0 && heads[0].taxonomy && (
dim taxonomy · top head ({heads[0] && `H${String(heads[0].head).padStart(2, '0')}`})
)}
Top compliance features at L{layer} · {component}
{feats.length === 0 ? (
No compliance features for L{layer} · {component} — likely not in the analyzed component set (compliance analysis runs on mlp and gate right now).
) : (
{feats.map((f, i) => (
f{f.feature} {f.leaning}-leaning F {f.fstat?.toFixed(1)} Δ {f.delta?.toFixed(2)}
{f.desc}
))}
)}
); } function Taxonomy({ tax, dims }) { const order = ['broadly_shared', 'partial_shared', 'all_shared', 'non_activated']; const keys = order.filter(k => k in tax).concat(Object.keys(tax).filter(k => !order.includes(k))); const total = dims || keys.reduce((a, k) => a + (tax[k] || 0), 0) || 1; const TONE = { broadly_shared: 'lavender', partial_shared: 'rose', all_shared: 'gold', non_activated: 'sage', }; return (
{keys.map(k => ( ))}
{keys.map(k => ( {k.replace('_', ' ')} {tax[k]} ))}
); } window.LayerDeepDive = LayerDeepDive;