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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
base_model:
|
| 6 |
+
- meta-llama/Llama-3.2-3B
|
| 7 |
+
tags:
|
| 8 |
+
- interpretability
|
| 9 |
+
- activation-verbalization
|
| 10 |
+
- prefix-tuning
|
| 11 |
+
- nla
|
| 12 |
+
- frozen-backbone
|
| 13 |
+
- cross-backbone-transfer
|
| 14 |
+
library_name: pytorch
|
| 15 |
+
pipeline_tag: feature-extraction
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# srt-nla-av-llama32-3b — Activation Verbalizer for Llama-3.2-3B (L20)
|
| 19 |
+
|
| 20 |
+
**Read a single hidden activation as a sentence — on a different backbone family.**
|
| 21 |
+
A 9.44M-parameter prefix adapter over a fully frozen `meta-llama/Llama-3.2-3B`
|
| 22 |
+
that, given a layer-20 last-token hidden state `v ∈ ℝ³⁰⁷²`, generates text
|
| 23 |
+
whose own re-encoded L20 hidden state `h` maximizes the anisotropy-corrected
|
| 24 |
+
reconstruction `fve_nrm_cen(h, v) = ½(1 + cos(h − μ, v − μ))`.
|
| 25 |
+
|
| 26 |
+
This is the **cross-backbone replication** of
|
| 27 |
+
[`RiverRider/srt-nla-av-v1`](https://huggingface.co/RiverRider/srt-nla-av-v1)
|
| 28 |
+
(Qwen2.5-7B). Same training pipeline, same hyperparameters, different
|
| 29 |
+
model family and different size. Result: every qualitative finding of the
|
| 30 |
+
original paper (saturating ceiling at best-of-K, log-linear K-curve, death
|
| 31 |
+
of logp-rerank) reproduces. See `paper_nla.md` §10.
|
| 32 |
+
|
| 33 |
+
**TL;DR:** at best-of-64 sampling the AV exceeds the NN-retrieval ceiling
|
| 34 |
+
(`fve_nrm_cen = 0.858 > 0.756`). Greedy decoding remains the open problem
|
| 35 |
+
(`0.633` centered), still below the retrieval baseline.
|
| 36 |
+
|
| 37 |
+
## Card metadata
|
| 38 |
+
|
| 39 |
+
| | |
|
| 40 |
+
|---|---|
|
| 41 |
+
| **Backbone (frozen)** | `meta-llama/Llama-3.2-3B`, bf16 |
|
| 42 |
+
| **Layer / target** | `ℓ = 20` (71% depth, mirrors Qwen's L20/28), last-valid-token hidden of a 64-token Llama continuation |
|
| 43 |
+
| **AV trainable params** | 9.44M (1 static prefix token + 1 inject slot + projection); smaller than the Qwen AV due to `hidden_size = 3072` and tied 128k-vocab lm_head |
|
| 44 |
+
| **Training objective** | Token CE on (v, text) pairs, where text is a Llama continuation |
|
| 45 |
+
| **Training data** | `srt-nla-targets-llama32-3b-v1` (30K (v, text) pairs, seed=1) |
|
| 46 |
+
| **Headline metric** | best-of-64 `fve_nrm_cen = 0.858` (M=32) → exceeds NN ceiling 0.756 (M=200) → `ρ_norm ≈ 1.40` |
|
| 47 |
+
| **License** | Apache-2.0 (weights). Backbone subject to Llama 3.2 community license at load time. |
|
| 48 |
+
|
| 49 |
+
## Files
|
| 50 |
+
|
| 51 |
+
| File | Notes |
|
| 52 |
+
|---|---|
|
| 53 |
+
| `best_av.pt` | Best SFT checkpoint (val fve_nrm 0.332 at step 5000/5337, 3 epochs on 28,465 train pairs) |
|
| 54 |
+
| `config.json` | `NLAConfig` JSON; reproduces verbalizer geometry |
|
| 55 |
+
| `eval/centered_eval.json` | M=32, K=64 centered eval |
|
| 56 |
+
| `eval/rerank_eval.json` | M=200, K=32 K-curve + cheap-rerank diagnostics |
|
| 57 |
+
| `eval/oracle_ceiling.json` | M=200 replay/random/NN/paraphrase ceilings |
|
| 58 |
+
|
| 59 |
+
## How to load
|
| 60 |
+
|
| 61 |
+
```python
|
| 62 |
+
import torch
|
| 63 |
+
from huggingface_hub import hf_hub_download
|
| 64 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 65 |
+
from srt.nla import ActivationVerbalizer, NLAConfig
|
| 66 |
+
|
| 67 |
+
repo = "RiverRider/srt-nla-av-llama32-3b"
|
| 68 |
+
cfg = NLAConfig.from_json(hf_hub_download(repo, "config.json"))
|
| 69 |
+
|
| 70 |
+
bb = AutoModelForCausalLM.from_pretrained(
|
| 71 |
+
"meta-llama/Llama-3.2-3B", torch_dtype=torch.bfloat16
|
| 72 |
+
).cuda().eval()
|
| 73 |
+
for p in bb.parameters():
|
| 74 |
+
p.requires_grad = False
|
| 75 |
+
tok = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-3B")
|
| 76 |
+
|
| 77 |
+
av = ActivationVerbalizer(cfg, backbone=bb, tokenizer=tok).cuda().eval()
|
| 78 |
+
state = torch.load(hf_hub_download(repo, "best_av.pt"), map_location="cuda",
|
| 79 |
+
weights_only=False)
|
| 80 |
+
av.load_state_dict(state, strict=False)
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
To **verbalize** an activation vector `v ∈ ℝ³⁰⁷²` extracted from layer 20 of
|
| 84 |
+
the frozen backbone, draw a best-of-K rollout and score each candidate by
|
| 85 |
+
`fve_nrm_cen` (centered cosine vs `v`); pick argmax. See
|
| 86 |
+
`scripts/centered_eval.py` for the canonical eval loop.
|
| 87 |
+
|
| 88 |
+
## Evaluation
|
| 89 |
+
|
| 90 |
+
`fve_nrm_cen` = anisotropy-corrected (subtract pool μ before cosine).
|
| 91 |
+
Pool size 2,000 in all rows.
|
| 92 |
+
|
| 93 |
+
### M=200 oracle ceiling (`scripts/oracle_ceiling.py`)
|
| 94 |
+
|
| 95 |
+
| anchor | raw fve_nrm | centered fve_nrm |
|
| 96 |
+
|---|---|---|
|
| 97 |
+
| replay (sanity) | 0.904 | 0.881 |
|
| 98 |
+
| paraphrase best-of-8 (Llama) | 0.764 | 0.720 |
|
| 99 |
+
| NN-in-pool | 0.785 | **0.756** ← used as ceiling |
|
| 100 |
+
| random floor | 0.569 | 0.498 |
|
| 101 |
+
|
| 102 |
+
Note: on Llama-3.2-3B base, the bare paraphrase prompt
|
| 103 |
+
underperforms NN-retrieval — the "paraphrase ceiling" is an
|
| 104 |
+
instruction-following ceiling of the base model, not a property of the
|
| 105 |
+
verbalization problem. We use **NN-in-pool as the headline ceiling** for
|
| 106 |
+
this release.
|
| 107 |
+
|
| 108 |
+
### M=32 centered eval (K=64; `scripts/centered_eval.py`)
|
| 109 |
+
|
| 110 |
+
| condition | raw fve_nrm | centered fve_nrm |
|
| 111 |
+
|---|---|---|
|
| 112 |
+
| greedy | 0.672 | 0.633 |
|
| 113 |
+
| sampled (mean) | 0.684 | 0.637 |
|
| 114 |
+
| **best-of-64** | **0.873** | **0.858** |
|
| 115 |
+
| NN-retrieval | 0.837 | 0.820 |
|
| 116 |
+
| random floor | 0.569 | 0.500 |
|
| 117 |
+
|
| 118 |
+
### M=200 K-curve (`scripts/rerank_eval.py`)
|
| 119 |
+
|
| 120 |
+
| K | centered fve_nrm |
|
| 121 |
+
|---|---|
|
| 122 |
+
| 1 | 0.636 |
|
| 123 |
+
| 2 | 0.678 |
|
| 124 |
+
| 4 | 0.716 |
|
| 125 |
+
| 8 | 0.748 |
|
| 126 |
+
| 16 | 0.780 |
|
| 127 |
+
| 32 | 0.809 |
|
| 128 |
+
|
| 129 |
+
Log-linear: ~+0.034 centered per doubling of K (within sampling noise of
|
| 130 |
+
Qwen's +0.030).
|
| 131 |
+
|
| 132 |
+
- **logp-rerank gives 0.624 centered** (+0.005 vs greedy 0.619, Spearman 0.055
|
| 133 |
+
with the oracle) — same death-of-logp-rerank result as Qwen.
|
| 134 |
+
- **NN-anchor rerank gives 0.783 centered**, well above greedy.
|
| 135 |
+
|
| 136 |
+
## Known limitations
|
| 137 |
+
|
| 138 |
+
- **Llama-3.2-3B base paraphrase prompt is a weaker ceiling than Qwen's.**
|
| 139 |
+
The bare instruction `"Paraphrase the following text using different
|
| 140 |
+
words but the same meaning."` zero-shots cleanly on Qwen-2.5-7B base
|
| 141 |
+
but underperforms NN-retrieval on Llama-3.2-3B base. Comparisons across
|
| 142 |
+
the two releases should use centered fve_nrm directly, not normalize to
|
| 143 |
+
a backbone-specific paraphrase ceiling.
|
| 144 |
+
- **Greedy gap is the open problem here too.** Without K-way sampling, the
|
| 145 |
+
AV under-performs a 1-line numpy NN-lookup against the same pool — same
|
| 146 |
+
shape as Qwen v1.
|
| 147 |
+
- **Same-layer transfer only.** The release uses ℓ=20 (71% depth, mirrors
|
| 148 |
+
Qwen's L20/28). Other layers were not evaluated.
|
| 149 |
+
|
| 150 |
+
## Recommended deployment
|
| 151 |
+
|
| 152 |
+
Best-of-K oracle rerank (sample K, score each by `fve_nrm_cen`, return
|
| 153 |
+
argmax). At K=64 this delivers `fve_nrm_cen ≈ 0.86`, exceeding the
|
| 154 |
+
NN-retrieval baseline.
|
| 155 |
+
|
| 156 |
+
## Citation
|
| 157 |
+
|
| 158 |
+
```bibtex
|
| 159 |
+
@misc{lancaster2026nlareframe,
|
| 160 |
+
title = {Natural-Language Activation Verbalization:
|
| 161 |
+
Probing the Decodability of Frozen Hidden States via Prefix-Tuned Generation},
|
| 162 |
+
author = {Lancaster, Burton},
|
| 163 |
+
year = {2026},
|
| 164 |
+
note = {Draft; see github.com/space-bacon/SRT/blob/main/paper_nla.md (§10 cross-backbone)},
|
| 165 |
+
}
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
## Related
|
| 169 |
+
|
| 170 |
+
- Code: <https://github.com/space-bacon/SRT> (`nla-v1.1.0` tag)
|
| 171 |
+
- Targets dataset: [`RiverRider/srt-nla-targets-llama32-3b-v1`](https://huggingface.co/datasets/RiverRider/srt-nla-targets-llama32-3b-v1)
|
| 172 |
+
- Qwen sibling: [`RiverRider/srt-nla-av-v1`](https://huggingface.co/RiverRider/srt-nla-av-v1)
|