Datasets:
|
Download README.md from syvb/qwen3-last-position-patching: direct link, hf CLI and curl.
- Browser
- Download file 5.66 kB
-
https://huggingface.co/datasets/syvb/qwen3-last-position-patching/resolve/main/README.md
- Command line
-
hf download hf://datasets/syvb/qwen3-last-position-patching/README.md
-
curl -L -o README.md https://huggingface.co/datasets/syvb/qwen3-last-position-patching/resolve/main/README.md
5.66 kB
| license: odc-by | |
| tags: | |
| - interpretability | |
| - activation-patching | |
| - qwen3 | |
| # Qwen3 last-position residual patching | |
| This is the data from an experiment on how "self-correcting" the Qwen3 base models are (0.6B, 1.7B, 4B, 8B, 14B). | |
| For a held-out FineWeb document cut at position T, the residual stream at the **last position** is replaced at one | |
| site with an ablated value. We then measure how far every later site's residual stream at that position moves from | |
| the clean run, and how much the next-token prediction changes. | |
| Code: https://github.com/syvb/act-experiments (branch `self-correction`). The README there defines the metrics, | |
| and RESULTS.md has the findings. | |
| - **Sites**: 0 = token embeddings, i = residual stream after i blocks (before the final norm). | |
| - **Ablations**: | |
| - `mean`: per-token mean residual over other contexts ending in the same token. | |
| - `resample`: the residual of one other real context (a different doc) ending in the same token. | |
| - `global`: the mean over all tokens. | |
| - **Data**: HuggingFaceFW/fineweb `sample/10BT/000_00000.parquet`. Docs are truncated to 512 tokens and positions | |
| [64, 512) are used. Means come from the first ~34k docs of the file (10M positions). Test samples come from the | |
| last 10k docs, iterated from the end of the file; `doc` indexes that reversed order. | |
| - **Precision**: means were computed in bf16, and patching in fp32 (no TF32). Checks on 0.6B and 14B found the | |
| bf16-vs-fp32 gap in the means is 70–2000× below their sampling noise. | |
| ## Files (one set per model size) | |
| `means_{size}.pt` (torch): `token_ids [K]`, `counts [K]` (occurrences; only tokens with ≥ 500 are kept), | |
| `means [n_sites, K, d]` fp32, `global_mean [n_sites, d]`, `model`, `dtype`. | |
| `metrics_{size}.npz` (numpy): per-sample results for 3,000 samples, with ablation order `ablations`. | |
| - `doc`, `T`, `token`, `donor_doc`, `donor_T` | |
| - `spread [n, site]` = |clean − token mean|²; `donor_gap [n, site]` = |clean − donor|² | |
| - `sq [n, abl, patch site, measured site]` = |patched − clean|² | |
| - `proj [...]` = ⟨patched − clean, injected⟩ | |
| - `pull [...]` = ⟨patched − donor, clean − donor⟩ | |
| - `attn_repair`, `mlp_repair [n, abl, patch site, block]` = −⟨Δ block output, injected⟩ | |
| - `kl [n, abl, patch site]` = KL(clean ‖ patched) of the next-token distribution | |
| - `dloss [n, abl, patch site]` = increase in loss on the true next token | |
| `acts_{size}.pt` (torch, bf16 activations): | |
| - `ids`: list of token-id tensors, each holding the context, the final token, and the true next token | |
| - `clean [n, n_sites, d]`: clean last-position residuals of every sample | |
| - `patched [32, abl, 1 + n_sites, n_sites, d]`: every patched run of the first 32 samples (row 0 = clean, row 1 + s = | |
| patched at site s) | |
| - also `doc`, `T`, `model`, `ablations` | |
| `metrics_robust_{size}.npz`: a separate 1,000-sample pass. It has the same fields, plus `sq_no_massive` / | |
| `spread_no_massive`, which leave out the 5 dims with the largest |mean| (`massive_dims`). In Qwen3-4B and 8B, the | |
| patch switches a massive activation on or off in a few samples: |patched − clean| reaches 4,000–13,000 in those dims | |
| from site 17 on, where clean values are normally below ~200. In the main run, for patches at sites 1–16, 3 of the | |
| 3,000 samples carry 74% (4B) and 93% (8B) of the mean-ablation perturbation measured at sites 17–25. They also | |
| distort averages of `proj` (8B's retained share at 75% depth is 0.83 with them and 1.31 without). Use the | |
| `_no_massive` fields, or drop those samples, when averaging. In every model except 0.6B, the massive dims also | |
| inflate final-site disruption for late patches by up to ~25%. | |
| `metrics_noise_14B.npz`: the noise run on 14B (`run_noise.sh`). It has the same fields as `metrics_robust_{size}.npz`, | |
| for the same 3,000 samples and donors as `metrics_14B.npz`. The conditions are `mean`, `resample`, `add_context_x{s}` | |
| and `add_random_x{s}` for s = 0.25, 1, 4 and 16. `add_context` adds s × (donor − token mean) to the clean residual, | |
| and `add_random` adds a random direction of the same size. Plots and a summary are in `plots_noise/`, and the log is in | |
| `logs/noise.log`. | |
| `steer/`: a 0.6B steering prototype, run on CPU. | |
| - `vectors_0.6B.pt`: `topics` (weddings, football, cooking) and `vectors [topic, n_sites, d]`. Each vector is the mean | |
| of (residual − token mean) after the first mention, in 200 FineWeb docs per topic from the start of the file. | |
| - `steer_0.6B.npz`: one row per (sample, topic), with `on_topic`, `topic`, `doc`, `T`, `token`, `clean_topic_logp` | |
| and `spread`. Conditions are `steer_x{s}` and `random_x{s}` for s = 1 to 32. Per condition, with the same shapes as | |
| above: `sq`, `proj`, `concept` (= ⟨patched − clean, topic vector at the measured site⟩), `kl`, and `dtopic` (the | |
| change in log P of the topic words). `vector_dot [topic, site, site]` holds the dot products of the topic vectors. | |
| - Plots and a summary are in `plots_steer/`. | |
| `check_means_14B_{bfloat16,float32}.pt`: 14B means over 300k positions in both precisions, used for | |
| `plots/check_means_14B.txt`. | |
| `plots/` (main run) and `plots_robust/` (robust pass) hold heatmaps per model, the cross-size figure, | |
| `summary.txt`, and `key_numbers.txt`. `logs/` holds the run logs. | |
| Licensing: the token ids are derived from FineWeb (ODC-By 1.0), and the Qwen3 models are Apache-2.0. | |
| ## Loading | |
| ```python | |
| import numpy as np, torch | |
| from huggingface_hub import hf_hub_download | |
| f = np.load(hf_hub_download("syvb/qwen3-last-position-patching", "metrics_4B.npz", repo_type="dataset")) | |
| acts = torch.load(hf_hub_download("syvb/qwen3-last-position-patching", "acts_4B.pt", repo_type="dataset")) | |
| ``` | |