MCPcopy Index your code
hub / github.com/RiddleHe/llm-interp

github.com/RiddleHe/llm-interp @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
204 symbols 511 edges 6 files 17 documented · 8%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

LLM Brain Surgeon

A collection of lightweight, standalone scripts to perform mechanistic interpretability observations on chosen LLMs. Topics include the geometric mechanism of attention sinks, the isolated simulations of non-deterministic attention outputs, etc.

In each subdir, which is headed by a research topic, a readme.md is (or will be) available for instructions on how to run the single python script.

Research topics

Attention sinks (actively developing)

We want to understand when attention sinks occur, and what are some causal factors that contribute to its emergence.

We find that token 0 manipulates a particular layer output to reside in a low-variance manifold, which it can then linearly transform into strong signals for alignment when doing QK computation.

Deterministic attention

We want to understand when nondeterministic inference occurs even with temperature=0.

We find that by changing the prefilling strategy or batch size, softmax outputs drift from the baseline.

Thinking budget

We want to study how models track and budget the number of thinking tokens in their CoT, especially for ByteDance-Seed/Seed-OSS-36B-Instruct by ByteDance.

We find that special layers are activated before the budgeting occurs to only focus its attention on the last two tokens.

Core symbols most depended-on inside this repo

_topk_energy_dims
called by 12
attention_sink/analyze_sink.py
prefill
called by 12
attention_sink/analyze_sink.py
_print_list
called by 12
attention_sink/analyze_sink.py
_plot_progression_multi
called by 10
attention_sink/analyze_sink.py
_cloud_radius
called by 9
attention_sink/analyze_sink.py
_topk_vals_mu_sd_str
called by 9
attention_sink/analyze_sink.py
_mean_vec_norm
called by 7
attention_sink/analyze_sink.py
_fracmass_on_set
called by 6
attention_sink/analyze_sink.py

Shape

Function 204

Languages

Python100%

Modules by API surface

attention_sink/analyze_sink.py171 symbols
attention_nondeterministic/analyze_attention_nondeterministic.py15 symbols
thinking_budget/analyze_seed_thinking_budget.py11 symbols
thinking_budget/utils.py5 symbols
thinking_budget/rope.py2 symbols

For agents

$ claude mcp add llm-interp \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact