Views
No views yet
A_l, b_l fitted to the residual streams
of Gemma-3-1b and Llama-3.2-1B, by streaming ridge regression over a
corpus. They give you a reference for what each layer usually does to the
state, so you can score a single trajectory against it instead of against zero:h_{l+1} ≈ A_l · h_l + b_l (the reference prediction)
ε_l = h_{l+1} − (A_l · h_l + b_l) (the innovation — what it does NOT predict)torch.load these and subtract from your own hidden states.| file | contents |
|---|---|
operators_gemma.pt | Gemma-3-1b, d=1152, 26 layers (~790 MB) |
operators_llama.pt | Llama-3.2-1B, d=2048, 16 layers (~1.6 GB) |
load_operators.py | tiny loader: innovation(ops, h_l, h_next, layer) |
.pt is a self-describing dict:1{
2 "meta": { family, d, n_layers, hf_id_pt, hf_id_it, corpus, ridge_lambda, ... },
3 "PT-COMP": { "raw": {"A": [nL,d,d], "b": [nL,d]}, "normed": {...} },
4 "IT-COMP": { "raw": {...}, "normed": {...} },
5 "IT-CHAT": { "raw": {...}, "normed": {...} },
6}PT-COMP (base weights, no template), IT-COMP (instruct
weights, no template — the usual "deploy on the weights you'll use" default),
IT-CHAT (instruct weights, chat-templated).raw fits hidden_states as returned; normed fits
input_layernorm_l(h_l), i.e. what block l actually reads. The two diverge
strongly on Gemma because of its (1+γ) RMSNorm — use normed if you feed
normalised states.1import torch
2from load_operators import load_operators, innovation
3
4ops = load_operators("operators_gemma.pt") # or operators_llama.pt
5
6# your own hidden states for a prompt: hs[l] is [seq, d] (output_hidden_states=True)
7layer = 12
8eps = innovation(ops, hs[layer], hs[layer + 1], layer,
9 condition="IT-COMP", variant="raw") # [seq, d]predict_next(ops, h, layer, ...) gives the reference prediction alone.IT-CHAT.google/gemma-3-1b-pt / google/gemma-3-1b-it,
Gemma Terms of Use (https://ai.google.dev/gemma/terms).meta-llama/Llama-3.2-1B / meta-llama/Llama-3.2-1B-Instruct,
Llama 3.2 Community License.1@misc{manson_refpred_operators,
2 title = {Fitted reference operators for transformer residual streams},
3 author = {Manson, Rob},
4 year = {2026},
5 url = {https://robman.fyi}
6}