v2: mean-replacement edit (same 64 neurons) that keeps GSM8K/MMLU/ARC; v1 kept on branch v1
Browse files- README.md +52 -74
- apply_patch.py +49 -27
- config.json +1 -1
- model.safetensors +2 -2
- neurons.json +68 -3
- results.json +0 -131
- results_eval_v2.json +0 -35
- results_v2.json +91 -0
README.md
CHANGED
|
@@ -9,98 +9,80 @@ tags:
|
|
| 9 |
- minicpm5
|
| 10 |
---
|
| 11 |
|
| 12 |
-
# MiniCPM5-1B-WSP-NoLoop
|
| 13 |
|
| 14 |
-
A training-free, sparse
|
| 15 |
|
| 16 |
-
Part of the Weight-Space Programming (WSP) series: diagnose a behaviour defect, localize it in the weights, repair it with a minimal direct edit, verify that nothing else broke.
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
> |---|---|---|---|
|
| 23 |
-
> | GSM8K, 250 test problems, greedy, 768 tokens | 70.0% | 61.2% | 0.002 |
|
| 24 |
-
> | MMLU, 600 test questions | 47.2% | 44.7% | 0.03 |
|
| 25 |
-
> | ARC-Challenge, 400 test questions | 43.8% | 41.0% | 0.05 |
|
| 26 |
-
>
|
| 27 |
-
> The GSM8K figure in the first version of this card (65.0% vs 65.0%) was not independent: 40 of those 60 problems were also used as protected examples during neuron selection. Use this checkpoint for loop-prone long-form generation, not for math or knowledge tasks. A v2 with capability-protected neuron selection is in progress.
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
- **What changed:** 64 MLP neurons (0.058% of the model's 110,592 MLP neurons) are silenced by zeroing their columns in `mlp.down_proj.weight`.
|
| 32 |
-
- **Where:** mostly layers 7 to 14 (layer 9: 11, layer 8: 8, layer 13: 7, layers 10/12/14: 6 each, rest spread over layers 4 to 22). Full list in `neurons.json`.
|
| 33 |
-
- **No training, no data fine-tuning, no inference-time hooks.** Architecture and file format are unchanged; the model runs anywhere the base model runs.
|
| 34 |
-
- **Reversible:** the edit is fully described by the 64 (layer, neuron) pairs in `neurons.json`. `apply_patch.py --revert` copies the original columns back from the base model, restoring it bit for bit. `--scale` between 0.0 and 1.0 gives a partial edit.
|
| 35 |
-
|
| 36 |
-
## How the neurons were found
|
| 37 |
-
|
| 38 |
-
1. **Diagnosis.** Greedy decoding on long-form prompts showed sentence-level loops. The SFT checkpoint (`MiniCPM5-1B-SFT`) loops more than the final RL+OPD checkpoint, so the defect predates RL and reverting toward SFT would make it worse.
|
| 39 |
-
2. **Contrast set.** From the model's own fluent outputs, a sentence S is taken and the context is built with S written once, then twice. The repair target is the log-probability of re-emitting S (copy onset and loop continuation). The protected targets are the true next sentence, in-context lookup/verbatim copy answers, and GSM8K reference solutions.
|
| 40 |
-
3. **Attribution.** Gradient x activation on every MLP neuron estimates how much zeroing it lowers repeat probability versus how much it moves the protected targets. Neurons are ranked by benefit minus 2x harm, then the top-k are validated by real ablation.
|
| 41 |
-
4. **Approaches tried and rejected:**
|
| 42 |
-
- Removing the residual "copy-mode" direction *increased* repetition. That direction acts as the model's own "already said this" signal.
|
| 43 |
-
- Amplifying it worked but cost about as much fluency as it saved.
|
| 44 |
-
- Scaling induction attention heads (L14H13, L15H7, ...) cut loops but broke format following (the model stopped copying "Answer:" and ran on) and verbatim copy.
|
| 45 |
-
- Neuron-level edits gave the cleanest trade-off. k=64 was chosen; k=128 started to hurt copying and math.
|
| 46 |
|
| 47 |
-
##
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
-
##
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
|
| 61 |
-
|
| 62 |
|
| 63 |
-
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|---|---|---|
|
| 67 |
-
| 300 synthetic long-form prompts, greedy, 1024 tokens: hard loops | 42 / 300 | **8 / 300** (38 fixed, 4 new) |
|
| 68 |
-
| 200 real user prompts (No Robots test), greedy: hard loops | 17 / 200 | **6 / 200** (11 fixed, 0 new) |
|
| 69 |
-
| 100 think-mode prompts, 1200 tokens: hard loops | 12 / 100 | 7 / 100 (9 fixed, 4 new) |
|
| 70 |
-
| 300 prompts, recommended sampling: hard loops | 1 / 300 | 1 / 300 |
|
| 71 |
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
-
|
|
| 75 |
|---|---|---|
|
| 76 |
-
|
|
| 77 |
-
|
|
| 78 |
-
|
|
| 79 |
-
| WikiText-2 perplexity (20 x 512 tokens) | 37.19 | 37.60 (+1.1%) |
|
| 80 |
-
| In-context code lookup (120 items) | 85.8% | 86.7% |
|
| 81 |
-
| Verbatim sentence copy on request (40 items) | 92.5% | 92.5% |
|
| 82 |
-
| Natural next-sentence log-prob (held out) | -1.444 | -1.475 |
|
| 83 |
|
| 84 |
-
###
|
| 85 |
|
| 86 |
-
|
|
| 87 |
-
|---|---|---|
|
| 88 |
-
|
|
| 89 |
-
|
|
|
|
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
### Teacher-forced (held-out sentences)
|
| 94 |
-
|
| 95 |
-
Chance of re-emitting a sentence that has already appeared twice: per-token log-prob -0.389 to -1.897 (about 68% to 15% per token).
|
| 96 |
|
| 97 |
## Limitations
|
| 98 |
|
| 99 |
-
-
|
| 100 |
-
-
|
| 101 |
- The edit targets sentence and block loops. It does not fix factual errors of the 1B base model.
|
|
|
|
| 102 |
- English and Chinese only, as with the base model.
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
## Usage
|
| 105 |
|
| 106 |
```python
|
|
@@ -109,8 +91,4 @@ tok = AutoTokenizer.from_pretrained("yasserrmd/MiniCPM5-1B-WSP-NoLoop")
|
|
| 109 |
model = AutoModelForCausalLM.from_pretrained("yasserrmd/MiniCPM5-1B-WSP-NoLoop", dtype="auto")
|
| 110 |
```
|
| 111 |
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
```bash
|
| 115 |
-
python apply_patch.py --out ./MiniCPM5-1B-WSP-NoLoop
|
| 116 |
-
```
|
|
|
|
| 9 |
- minicpm5
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# MiniCPM5-1B-WSP-NoLoop (v2)
|
| 13 |
|
| 14 |
+
A training-free, sparse weight edit of [openbmb/MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B) that reduces degenerate repetition loops (the model re-emitting the same sentence or block until it runs out of tokens) **without measurable loss on GSM8K, MMLU or ARC-Challenge**.
|
| 15 |
|
| 16 |
+
Part of the Weight-Space Programming (WSP) series: diagnose a behaviour defect, localize it in the weights, repair it with a minimal direct edit, verify on held-out data that nothing else broke.
|
| 17 |
|
| 18 |
+
| Version | Where | Edit | Loops | Math / knowledge |
|
| 19 |
+
|---|---|---|---|---|
|
| 20 |
+
| **v2 (this, `main`)** | `main` | 64 neurons mean-replaced | about 40% fewer hard loops | no measurable change |
|
| 21 |
+
| v1 | branch `v1` | same 64 neurons zeroed | about 70% fewer hard loops | GSM8K -8.8 pts, MMLU -2.5, ARC -2.8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
Use v2 by default. Use v1 only for long-form generation where loops matter more than math or factual accuracy.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
## The edit
|
| 26 |
|
| 27 |
+
- **What changed:** 64 MLP neurons (0.058% of the model's 110,592 MLP neurons) in layers 4 to 22, mostly 7 to 14. Each neuron's column in `mlp.down_proj.weight` is set to zero and its *average* contribution is added back as a constant `down_proj` bias. The neuron therefore always outputs its mean value instead of an input-dependent value.
|
| 28 |
+
- **Why mean replacement:** v1 simply zeroed these neurons. That also removed their average output, which shifts the residual stream for every token and was the cause of v1's math and knowledge loss. On 1,230 tuning questions, zeroing gave 45.8% (base 48.1%, p=0.0005); mean replacement of the same neurons gave 48.1% (p=1.0).
|
| 29 |
+
- **Format:** standard `LlamaForCausalLM` with `mlp_bias: true` in `config.json`. All `gate_proj` / `up_proj` biases and the `down_proj` biases of untouched layers are zero. Loads in Transformers as is. Runtimes that ignore MLP biases (check your GGUF converter) will not reproduce the edit.
|
| 30 |
+
- **No training, no fine-tuning data, no inference-time hooks.**
|
| 31 |
+
- **Reproducible:** `neurons.json` lists the 64 (layer, neuron) pairs and their mean activations. `python apply_patch.py --out ./v2` rebuilds this checkpoint from the base model bit for bit.
|
| 32 |
|
| 33 |
+
## How it was built
|
| 34 |
|
| 35 |
+
1. **Diagnosis.** Greedy decoding on long-form prompts shows sentence-level loops. The SFT checkpoint loops more than the final RL+OPD checkpoint, so the defect predates RL.
|
| 36 |
+
2. **Localization.** Contrast sets from the model's own fluent outputs: a sentence written once vs. written again. Gradient x activation attribution over every MLP neuron finds neurons that drive re-emitting an already written sentence (details in the v1 notes below).
|
| 37 |
+
3. **Capability protection (new in v2).** Separate selection, tuning and test splits:
|
| 38 |
+
- *Selection:* repetition contrasts from 40 prompts; the model's own correct GSM8K **train** solutions; MMLU validation and ARC-Challenge train questions; in-context copy tasks.
|
| 39 |
+
- *Tuning:* 120 loop-prone prompts, 200 GSM8K train problems, 1,230 MMLU validation and ARC validation questions.
|
| 40 |
+
- *Final test (below):* never used for any decision.
|
| 41 |
+
4. **Choice rule (fixed before testing):** the most loop reduction with no GSM8K or knowledge drop on the tuning sets. Candidates were the v1 neurons and a newly ranked set of 32 to 128 neurons, all mean-replaced. The v1 neurons won (tuning: hard loops 11 to 6, GSM8K 69.5% to 71.5%, knowledge 48.1% to 48.1%).
|
| 42 |
|
| 43 |
+
## Final held-out results (base vs v2, same session)
|
| 44 |
|
| 45 |
+
Greedy decoding. "Hard loop" = output ends in a periodic repeat, or one sentence appears 5+ times without the model stopping. p-values are paired McNemar tests.
|
| 46 |
|
| 47 |
+
### Repetition
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
| Test | Base | v2 | Fixed / new | p |
|
| 50 |
+
|---|---|---|---|---|
|
| 51 |
+
| 300 synthetic long-form prompts, 1024 tokens | 35 hard loops | **20** | 26 / 11 | 0.02 |
|
| 52 |
+
| 200 real user prompts (No Robots test), 1024 tokens | 18 | **12** | 10 / 4 | 0.18 |
|
| 53 |
+
| 100 think-mode prompts, 1200 tokens | 16 | **10** | 10 / 4 | 0.18 |
|
| 54 |
+
| All 600 pooled | 69 | **42** | 46 / 19 | 0.001 |
|
| 55 |
|
| 56 |
+
| Metric (300 synthetic prompts) | Base | v2 |
|
| 57 |
|---|---|---|
|
| 58 |
+
| Degenerate outputs (sentence 3x or tail loop) | 26.7% | 13.7% |
|
| 59 |
+
| Duplicated sentences | 12.9% | 5.4% |
|
| 60 |
+
| Repeated 4-grams | 0.202 | 0.142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
+
### Capabilities
|
| 63 |
|
| 64 |
+
| Benchmark | Base | v2 | p |
|
| 65 |
+
|---|---|---|---|
|
| 66 |
+
| GSM8K, 250 test problems, 768 tokens | 67.2% | 68.4% | 0.74 |
|
| 67 |
+
| MMLU, 600 test questions | 47.2% | 46.7% | 0.69 |
|
| 68 |
+
| ARC-Challenge, 400 test questions | 43.8% | 44.0% | 1.0 |
|
| 69 |
|
| 70 |
+
Absolute base scores differ slightly from the v1 evaluation (for example GSM8K 70.0% there vs 67.2% here) because of batch size and padding differences between sessions; each comparison above is base vs v2 in the same run.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
## Limitations
|
| 73 |
|
| 74 |
+
- v2 removes fewer loops than v1. It is the safer trade-off, not the strongest loop fix.
|
| 75 |
+
- Per-split loop improvements on real prompts and think mode are not individually significant (p=0.18); the pooled improvement is (p=0.001).
|
| 76 |
- The edit targets sentence and block loops. It does not fix factual errors of the 1B base model.
|
| 77 |
+
- With the recommended sampling settings (T=1.0, top_p=0.95, min_p=0) the base model rarely loops, so the benefit is mainly for greedy and low-temperature use.
|
| 78 |
- English and Chinese only, as with the base model.
|
| 79 |
|
| 80 |
+
## v1 notes (zero ablation, branch `v1`)
|
| 81 |
+
|
| 82 |
+
v1 zeroes the same 64 neurons. On held-out tests it cut hard loops more (300 synthetic prompts: 42 to 8; 200 real prompts: 17 to 6) but lowered GSM8K from 70.0% to 61.2% (p=0.002), MMLU from 47.2% to 44.7% (p=0.03) and ARC-Challenge from 43.8% to 41.0% (p=0.05). Its first model card reported GSM8K 65.0% vs 65.0% on 60 problems, 40 of which had also been used as protected examples during selection; that check was not independent.
|
| 83 |
+
|
| 84 |
+
Approaches tried and rejected along the way: removing the residual "copy-mode" direction (it increased repetition, since that direction is the model's own "already said this" signal), amplifying it (fluency cost about equal to the gain), and scaling induction attention heads (broke format following and verbatim copying).
|
| 85 |
+
|
| 86 |
## Usage
|
| 87 |
|
| 88 |
```python
|
|
|
|
| 91 |
model = AutoModelForCausalLM.from_pretrained("yasserrmd/MiniCPM5-1B-WSP-NoLoop", dtype="auto")
|
| 92 |
```
|
| 93 |
|
| 94 |
+
v1: add `revision="v1"`.
|
|
|
|
|
|
|
|
|
|
|
|
apply_patch.py
CHANGED
|
@@ -1,37 +1,59 @@
|
|
| 1 |
"""
|
| 2 |
-
WSP
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
"""
|
| 6 |
-
import argparse
|
|
|
|
| 7 |
from collections import defaultdict
|
|
|
|
| 8 |
import torch
|
| 9 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 10 |
BASE = "openbmb/MiniCPM5-1B"
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
by_layer = defaultdict(list)
|
| 13 |
-
for layer, neuron in
|
| 14 |
by_layer[layer].append(neuron)
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
for
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
return model
|
|
|
|
|
|
|
| 26 |
if __name__ == "__main__":
|
| 27 |
ap = argparse.ArgumentParser()
|
| 28 |
-
ap.add_argument("--neurons", default="neurons.json")
|
| 29 |
-
ap.add_argument("--
|
| 30 |
-
a = ap.parse_args()
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
model = AutoModelForCausalLM.from_pretrained(BASE, dtype=torch.bfloat16); apply(model, by_layer, a.scale)
|
| 36 |
-
model.save_pretrained(a.out, safe_serialization=True); tok.save_pretrained(a.out)
|
| 37 |
-
print(("Reverted" if a.revert else "Patched"), sum(len(v) for v in by_layer.values()), "neurons ->", a.out)
|
|
|
|
| 1 |
"""
|
| 2 |
+
WSP NoLoop v2 patch for openbmb/MiniCPM5-1B (mean-replacement edit).
|
| 3 |
+
|
| 4 |
+
For each of the 64 MLP neurons listed in neurons.json:
|
| 5 |
+
* its column in model.layers[l].mlp.down_proj.weight is set to zero, and
|
| 6 |
+
* its average contribution (column x mean activation) is added to a constant
|
| 7 |
+
down_proj bias,
|
| 8 |
+
so the neuron always outputs its average value instead of its input-dependent
|
| 9 |
+
value. This removes the repetition-driving signal without shifting the
|
| 10 |
+
residual stream, which is what cost math and knowledge in v1 (plain zeroing).
|
| 11 |
+
|
| 12 |
+
The model is saved with config.mlp_bias = True. gate_proj / up_proj biases and
|
| 13 |
+
the down_proj bias of untouched layers are all zero.
|
| 14 |
+
|
| 15 |
+
Usage:
|
| 16 |
+
python apply_patch.py --out ./MiniCPM5-1B-WSP-NoLoop-v2
|
| 17 |
"""
|
| 18 |
+
import argparse
|
| 19 |
+
import json
|
| 20 |
from collections import defaultdict
|
| 21 |
+
|
| 22 |
import torch
|
| 23 |
+
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
|
| 24 |
+
|
| 25 |
BASE = "openbmb/MiniCPM5-1B"
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
@torch.no_grad()
|
| 29 |
+
def build(neurons_path, base=BASE):
|
| 30 |
+
spec = json.load(open(neurons_path))
|
| 31 |
by_layer = defaultdict(list)
|
| 32 |
+
for layer, neuron in spec["neurons"]:
|
| 33 |
by_layer[layer].append(neuron)
|
| 34 |
+
means = {tuple(map(int, k.split(","))): v for k, v in spec["neuron_means"].items()}
|
| 35 |
+
|
| 36 |
+
cfg = AutoConfig.from_pretrained(base)
|
| 37 |
+
cfg.mlp_bias = True
|
| 38 |
+
model = AutoModelForCausalLM.from_pretrained(base, config=cfg, dtype=torch.bfloat16)
|
| 39 |
+
for layer in model.model.layers:
|
| 40 |
+
for lin in (layer.mlp.gate_proj, layer.mlp.up_proj, layer.mlp.down_proj):
|
| 41 |
+
lin.bias.zero_()
|
| 42 |
+
for l, idx in by_layer.items():
|
| 43 |
+
W = model.model.layers[l].mlp.down_proj.weight
|
| 44 |
+
mu = torch.tensor([means[(l, n)] for n in idx], dtype=torch.float32)
|
| 45 |
+
bias = (W[:, idx].float() * mu[None, :]).sum(1)
|
| 46 |
+
model.model.layers[l].mlp.down_proj.bias.copy_(bias.to(W.dtype))
|
| 47 |
+
W[:, idx] = 0
|
| 48 |
return model
|
| 49 |
+
|
| 50 |
+
|
| 51 |
if __name__ == "__main__":
|
| 52 |
ap = argparse.ArgumentParser()
|
| 53 |
+
ap.add_argument("--neurons", default="neurons.json")
|
| 54 |
+
ap.add_argument("--out", required=True)
|
| 55 |
+
a = ap.parse_args()
|
| 56 |
+
model = build(a.neurons)
|
| 57 |
+
model.save_pretrained(a.out, safe_serialization=True)
|
| 58 |
+
AutoTokenizer.from_pretrained(BASE).save_pretrained(a.out)
|
| 59 |
+
print(f"Patched model saved to {a.out}")
|
|
|
|
|
|
|
|
|
config.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
| 16 |
"initializer_range": 0.02,
|
| 17 |
"intermediate_size": 4608,
|
| 18 |
"max_position_embeddings": 131072,
|
| 19 |
-
"mlp_bias":
|
| 20 |
"model_type": "llama",
|
| 21 |
"num_attention_heads": 16,
|
| 22 |
"num_hidden_layers": 24,
|
|
|
|
| 16 |
"initializer_range": 0.02,
|
| 17 |
"intermediate_size": 4608,
|
| 18 |
"max_position_embeddings": 131072,
|
| 19 |
+
"mlp_bias": true,
|
| 20 |
"model_type": "llama",
|
| 21 |
"num_attention_heads": 16,
|
| 22 |
"num_hidden_layers": 24,
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c53b69374c73832d18027fe2185c9a3c673995c1accd3038b0e11308308432fb
|
| 3 |
+
size 2161814712
|
neurons.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"base_model": "openbmb/MiniCPM5-1B",
|
| 3 |
-
"edit": "
|
| 4 |
-
"scale": 0.0,
|
| 5 |
"neurons": [
|
| 6 |
[
|
| 7 |
4,
|
|
@@ -260,5 +259,71 @@
|
|
| 260 |
3315
|
| 261 |
]
|
| 262 |
],
|
| 263 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"base_model": "openbmb/MiniCPM5-1B",
|
| 3 |
+
"edit": "mean-replace 64 MLP neurons: zero their down_proj columns and add their mean contribution as a constant down_proj bias (config.mlp_bias=True; gate/up biases are zero)",
|
|
|
|
| 4 |
"neurons": [
|
| 5 |
[
|
| 6 |
4,
|
|
|
|
| 259 |
3315
|
| 260 |
]
|
| 261 |
],
|
| 262 |
+
"neuron_means": {
|
| 263 |
+
"4,3046": 0.15633822977542877,
|
| 264 |
+
"4,3960": 0.12714824080467224,
|
| 265 |
+
"5,1196": -0.008657004684209824,
|
| 266 |
+
"5,4111": 0.038103289902210236,
|
| 267 |
+
"6,3828": -0.0022156054619699717,
|
| 268 |
+
"6,4200": -0.05240264907479286,
|
| 269 |
+
"7,239": -0.04617900401353836,
|
| 270 |
+
"7,885": 0.01954524964094162,
|
| 271 |
+
"7,2953": 0.02141941338777542,
|
| 272 |
+
"7,3212": 0.10538264364004135,
|
| 273 |
+
"7,4012": -0.09967049211263657,
|
| 274 |
+
"8,586": -0.01796388253569603,
|
| 275 |
+
"8,588": -0.023761309683322906,
|
| 276 |
+
"8,927": -0.03230719640851021,
|
| 277 |
+
"8,1677": -0.1275164932012558,
|
| 278 |
+
"8,3410": -0.04631464555859566,
|
| 279 |
+
"8,3535": 0.028190797194838524,
|
| 280 |
+
"8,4253": -0.04892460256814957,
|
| 281 |
+
"8,4304": 0.12063247710466385,
|
| 282 |
+
"9,291": -0.02793567255139351,
|
| 283 |
+
"9,593": 0.037329141050577164,
|
| 284 |
+
"9,1754": 0.09268363565206528,
|
| 285 |
+
"9,2033": 0.0055300467647612095,
|
| 286 |
+
"9,2114": 0.2221062183380127,
|
| 287 |
+
"9,2554": -0.12832699716091156,
|
| 288 |
+
"9,2624": -0.0693473145365715,
|
| 289 |
+
"9,2728": -0.12955614924430847,
|
| 290 |
+
"9,2986": -0.01657879538834095,
|
| 291 |
+
"9,3062": -0.2862870991230011,
|
| 292 |
+
"9,3140": -0.02082534320652485,
|
| 293 |
+
"10,613": -0.07572967559099197,
|
| 294 |
+
"10,727": -0.0913601890206337,
|
| 295 |
+
"10,1507": -0.023053744807839394,
|
| 296 |
+
"10,2245": -0.027268782258033752,
|
| 297 |
+
"10,3764": 0.020790470764040947,
|
| 298 |
+
"10,4476": -0.028169697150588036,
|
| 299 |
+
"11,1989": 0.01975252851843834,
|
| 300 |
+
"11,2301": -0.00821990892291069,
|
| 301 |
+
"11,4363": -0.0156070152297616,
|
| 302 |
+
"12,594": -0.005323260091245174,
|
| 303 |
+
"12,1853": 0.02051396109163761,
|
| 304 |
+
"12,2133": 0.00015633417933713645,
|
| 305 |
+
"12,2656": -0.042101744562387466,
|
| 306 |
+
"12,2761": 0.06966610252857208,
|
| 307 |
+
"12,4329": 0.31016841530799866,
|
| 308 |
+
"13,1116": -0.0005765727255493402,
|
| 309 |
+
"13,2002": 0.13307589292526245,
|
| 310 |
+
"13,2027": 0.1657835841178894,
|
| 311 |
+
"13,2759": 0.01270247995853424,
|
| 312 |
+
"13,3354": -0.12637662887573242,
|
| 313 |
+
"13,3689": 0.32833215594291687,
|
| 314 |
+
"13,4539": -0.014106840826570988,
|
| 315 |
+
"14,633": 0.7563517093658447,
|
| 316 |
+
"14,2298": -0.012896858155727386,
|
| 317 |
+
"14,2362": 0.04864812269806862,
|
| 318 |
+
"14,3408": 0.02054949849843979,
|
| 319 |
+
"14,3561": 0.04915745183825493,
|
| 320 |
+
"14,3631": -0.36456298828125,
|
| 321 |
+
"15,2001": 0.0010740152793005109,
|
| 322 |
+
"15,2896": 0.07591841369867325,
|
| 323 |
+
"16,2829": 0.047841839492321014,
|
| 324 |
+
"16,3292": -0.3738148510456085,
|
| 325 |
+
"17,279": -0.8090575933456421,
|
| 326 |
+
"22,3315": 0.3364357650279999
|
| 327 |
+
},
|
| 328 |
+
"means_source": "mean MLP activation over 120 chat-formatted samples of the model's own fluent outputs (no-think and think)"
|
| 329 |
}
|
results.json
DELETED
|
@@ -1,131 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"stress_120_greedy_1024": {
|
| 3 |
-
"base": {
|
| 4 |
-
"hard_loops": "17/120",
|
| 5 |
-
"n": 120,
|
| 6 |
-
"rep4": 0.1621,
|
| 7 |
-
"degenerate": 0.192,
|
| 8 |
-
"dup_sent": 0.0714,
|
| 9 |
-
"no_eos": 0.5,
|
| 10 |
-
"mean_len": 837.4
|
| 11 |
-
},
|
| 12 |
-
"edited": {
|
| 13 |
-
"hard_loops": "1/120",
|
| 14 |
-
"n": 120,
|
| 15 |
-
"rep4": 0.0739,
|
| 16 |
-
"degenerate": 0.025,
|
| 17 |
-
"dup_sent": 0.004,
|
| 18 |
-
"no_eos": 0.342,
|
| 19 |
-
"mean_len": 831.0
|
| 20 |
-
},
|
| 21 |
-
"fixed": 16,
|
| 22 |
-
"new": 0
|
| 23 |
-
},
|
| 24 |
-
"eval_72_greedy_768": {
|
| 25 |
-
"base": {
|
| 26 |
-
"n": 72,
|
| 27 |
-
"rep4": 0.1308,
|
| 28 |
-
"loop_rate": 0.028,
|
| 29 |
-
"tail_rep_any": 0.028,
|
| 30 |
-
"no_eos": 0.528,
|
| 31 |
-
"mean_len": 651.6,
|
| 32 |
-
"dup_sent": 0.0263,
|
| 33 |
-
"degenerate": 0.083
|
| 34 |
-
},
|
| 35 |
-
"edited": {
|
| 36 |
-
"n": 72,
|
| 37 |
-
"rep4": 0.0801,
|
| 38 |
-
"degenerate": 0.042,
|
| 39 |
-
"dup_sent": 0.0093,
|
| 40 |
-
"no_eos": 0.569,
|
| 41 |
-
"mean_len": 669.2
|
| 42 |
-
}
|
| 43 |
-
},
|
| 44 |
-
"eval_72_sampled_T1.0": {
|
| 45 |
-
"base": {
|
| 46 |
-
"n": 72,
|
| 47 |
-
"rep4": 0.0421,
|
| 48 |
-
"degenerate": 0.042,
|
| 49 |
-
"dup_sent": 0.0026,
|
| 50 |
-
"no_eos": 0.625,
|
| 51 |
-
"mean_len": 670.0
|
| 52 |
-
},
|
| 53 |
-
"edited": {
|
| 54 |
-
"n": 72,
|
| 55 |
-
"rep4": 0.0362,
|
| 56 |
-
"degenerate": 0.028,
|
| 57 |
-
"dup_sent": 0.0018,
|
| 58 |
-
"no_eos": 0.653,
|
| 59 |
-
"mean_len": 690.8
|
| 60 |
-
}
|
| 61 |
-
},
|
| 62 |
-
"think_32_greedy_1200": {
|
| 63 |
-
"base": {
|
| 64 |
-
"hard_loops": "3/32",
|
| 65 |
-
"n": 32,
|
| 66 |
-
"rep4": 0.2242,
|
| 67 |
-
"degenerate": 0.312,
|
| 68 |
-
"dup_sent": 0.0705,
|
| 69 |
-
"no_eos": 0.406,
|
| 70 |
-
"mean_len": 1031.9
|
| 71 |
-
},
|
| 72 |
-
"edited": {
|
| 73 |
-
"hard_loops": "1/32",
|
| 74 |
-
"n": 32,
|
| 75 |
-
"rep4": 0.1849,
|
| 76 |
-
"degenerate": 0.219,
|
| 77 |
-
"dup_sent": 0.0435,
|
| 78 |
-
"no_eos": 0.438,
|
| 79 |
-
"mean_len": 997.7
|
| 80 |
-
}
|
| 81 |
-
},
|
| 82 |
-
"teacher_forced_heldout": {
|
| 83 |
-
"base": {
|
| 84 |
-
"rep1": -1.5677,
|
| 85 |
-
"rep2": -0.3893,
|
| 86 |
-
"nat": -1.4443
|
| 87 |
-
},
|
| 88 |
-
"edited_delta": {
|
| 89 |
-
"rep1": -1.185,
|
| 90 |
-
"rep2": -1.508,
|
| 91 |
-
"nat": -0.031
|
| 92 |
-
},
|
| 93 |
-
"harm_delta": {
|
| 94 |
-
"copy_lp": 0.0115,
|
| 95 |
-
"gsm_lp": -0.0261
|
| 96 |
-
}
|
| 97 |
-
},
|
| 98 |
-
"wikitext2_ppl": {
|
| 99 |
-
"base": 37.188,
|
| 100 |
-
"edited": 37.6
|
| 101 |
-
},
|
| 102 |
-
"gsm8k_60_greedy_768": {
|
| 103 |
-
"base": {
|
| 104 |
-
"acc": 0.65,
|
| 105 |
-
"ended": 0.767
|
| 106 |
-
},
|
| 107 |
-
"edited_N32": {
|
| 108 |
-
"acc": 0.667,
|
| 109 |
-
"ended": 0.817
|
| 110 |
-
},
|
| 111 |
-
"edited": {
|
| 112 |
-
"acc": 0.65,
|
| 113 |
-
"ended": 0.767
|
| 114 |
-
}
|
| 115 |
-
},
|
| 116 |
-
"gsm8k_60_greedy_384": {
|
| 117 |
-
"base": 0.617,
|
| 118 |
-
"edited": {
|
| 119 |
-
"acc": 0.633,
|
| 120 |
-
"ended": 0.583
|
| 121 |
-
}
|
| 122 |
-
},
|
| 123 |
-
"copy_lookup_120": {
|
| 124 |
-
"base": 0.858,
|
| 125 |
-
"edited": 0.867
|
| 126 |
-
},
|
| 127 |
-
"copy_verbatim_40": {
|
| 128 |
-
"base": 0.925,
|
| 129 |
-
"edited": 0.925
|
| 130 |
-
}
|
| 131 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results_eval_v2.json
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"model": "yasserrmd/MiniCPM5-1B-WSP-NoLoop (N64) vs openbmb/MiniCPM5-1B",
|
| 3 |
-
"note": "All prompts and benchmark items below are disjoint from those used to select the neurons.",
|
| 4 |
-
"repetition": {
|
| 5 |
-
"synthetic_300_greedy_1024": {
|
| 6 |
-
"base": {"hard_loops": "42/300", "degenerate": 0.26, "dup_sent": 0.1152, "rep4": 0.1941, "no_eos": 0.353},
|
| 7 |
-
"edited": {"hard_loops": "8/300", "degenerate": 0.067, "dup_sent": 0.0143, "rep4": 0.1018, "no_eos": 0.373},
|
| 8 |
-
"fixed": 38, "new": 4
|
| 9 |
-
},
|
| 10 |
-
"real_no_robots_200_greedy_1024": {
|
| 11 |
-
"base": {"hard_loops": "17/200", "degenerate": 0.135, "dup_sent": 0.0581, "rep4": 0.1323, "no_eos": 0.095},
|
| 12 |
-
"edited": {"hard_loops": "6/200", "degenerate": 0.07, "dup_sent": 0.0205, "rep4": 0.0793, "no_eos": 0.06},
|
| 13 |
-
"fixed": 11, "new": 0
|
| 14 |
-
},
|
| 15 |
-
"think_100_greedy_1200": {
|
| 16 |
-
"base": {"hard_loops": "12/100", "degenerate": 0.24, "dup_sent": 0.0952, "rep4": 0.2073},
|
| 17 |
-
"edited": {"hard_loops": "7/100", "degenerate": 0.17, "dup_sent": 0.0539, "rep4": 0.17},
|
| 18 |
-
"fixed": 9, "new": 4
|
| 19 |
-
},
|
| 20 |
-
"synthetic_300_sampled_T1.0_top_p0.95": {
|
| 21 |
-
"base": {"hard_loops": "1/300", "rep4": 0.0369, "dup_sent": 0.0015},
|
| 22 |
-
"edited": {"hard_loops": "1/300", "rep4": 0.0279, "dup_sent": 0.0003}
|
| 23 |
-
}
|
| 24 |
-
},
|
| 25 |
-
"capabilities": {
|
| 26 |
-
"gsm8k_test_250_unseen_greedy_768": {"base": 0.700, "edited": 0.612, "base_only_correct": 34, "edited_only_correct": 12, "mcnemar_p": 0.0016},
|
| 27 |
-
"mmlu_test_600": {"base": 0.4717, "edited": 0.4467, "base_only_correct": 29, "edited_only_correct": 14, "mcnemar_p": 0.0315},
|
| 28 |
-
"arc_challenge_test_400": {"base": 0.4375, "edited": 0.41, "base_only_correct": 19, "edited_only_correct": 8, "mcnemar_p": 0.0522},
|
| 29 |
-
"mmlu_val_1300_plus_arc_train_200": {"base": 0.458, "edited": 0.4453, "mcnemar_p": 0.0448}
|
| 30 |
-
},
|
| 31 |
-
"neuron_count_sweep_mmlu600_arc400": {
|
| 32 |
-
"base": [0.4717, 0.4375], "N16": [0.4583, 0.42], "N32": [0.4533, 0.415], "N48": [0.45, 0.415], "N64_half_strength": [0.4633, 0.4175], "N64": [0.4467, 0.41]
|
| 33 |
-
},
|
| 34 |
-
"earlier_gsm8k_check_caveat": "The earlier 60-problem GSM8K result (65.0% vs 65.0%) overlapped with 40 problems used as protected examples during neuron selection, so it overstated safety."
|
| 35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results_v2.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"syn": {
|
| 3 |
+
"base": {
|
| 4 |
+
"n": 300,
|
| 5 |
+
"hard_loops": 35,
|
| 6 |
+
"rep4": 0.2015,
|
| 7 |
+
"degenerate": 0.267,
|
| 8 |
+
"dup_sent": 0.1291,
|
| 9 |
+
"no_eos": 0.337
|
| 10 |
+
},
|
| 11 |
+
"v2": {
|
| 12 |
+
"n": 300,
|
| 13 |
+
"hard_loops": 20,
|
| 14 |
+
"rep4": 0.142,
|
| 15 |
+
"degenerate": 0.137,
|
| 16 |
+
"dup_sent": 0.0544,
|
| 17 |
+
"no_eos": 0.35
|
| 18 |
+
},
|
| 19 |
+
"fixed": 26,
|
| 20 |
+
"new": 11,
|
| 21 |
+
"mcnemar_p": 0.0201
|
| 22 |
+
},
|
| 23 |
+
"real": {
|
| 24 |
+
"base": {
|
| 25 |
+
"n": 200,
|
| 26 |
+
"hard_loops": 18,
|
| 27 |
+
"rep4": 0.15,
|
| 28 |
+
"degenerate": 0.135,
|
| 29 |
+
"dup_sent": 0.0688,
|
| 30 |
+
"no_eos": 0.12
|
| 31 |
+
},
|
| 32 |
+
"v2": {
|
| 33 |
+
"n": 200,
|
| 34 |
+
"hard_loops": 12,
|
| 35 |
+
"rep4": 0.1138,
|
| 36 |
+
"degenerate": 0.1,
|
| 37 |
+
"dup_sent": 0.0414,
|
| 38 |
+
"no_eos": 0.095
|
| 39 |
+
},
|
| 40 |
+
"fixed": 10,
|
| 41 |
+
"new": 4,
|
| 42 |
+
"mcnemar_p": 0.1796
|
| 43 |
+
},
|
| 44 |
+
"think": {
|
| 45 |
+
"base": {
|
| 46 |
+
"n": 100,
|
| 47 |
+
"hard_loops": 16,
|
| 48 |
+
"rep4": 0.2222,
|
| 49 |
+
"degenerate": 0.3,
|
| 50 |
+
"dup_sent": 0.1177,
|
| 51 |
+
"no_eos": 0.56
|
| 52 |
+
},
|
| 53 |
+
"v2": {
|
| 54 |
+
"n": 100,
|
| 55 |
+
"hard_loops": 10,
|
| 56 |
+
"rep4": 0.193,
|
| 57 |
+
"degenerate": 0.21,
|
| 58 |
+
"dup_sent": 0.0789,
|
| 59 |
+
"no_eos": 0.58
|
| 60 |
+
},
|
| 61 |
+
"fixed": 10,
|
| 62 |
+
"new": 4,
|
| 63 |
+
"mcnemar_p": 0.1796
|
| 64 |
+
},
|
| 65 |
+
"pooled_loops": {
|
| 66 |
+
"fixed": 46,
|
| 67 |
+
"new": 19,
|
| 68 |
+
"mcnemar_p": 0.00109
|
| 69 |
+
},
|
| 70 |
+
"gsm": {
|
| 71 |
+
"a": 0.672,
|
| 72 |
+
"b": 0.684,
|
| 73 |
+
"a_only": 17,
|
| 74 |
+
"b_only": 20,
|
| 75 |
+
"p": 0.7428
|
| 76 |
+
},
|
| 77 |
+
"mmlu": {
|
| 78 |
+
"a": 0.4717,
|
| 79 |
+
"b": 0.4667,
|
| 80 |
+
"a_only": 14,
|
| 81 |
+
"b_only": 11,
|
| 82 |
+
"p": 0.69
|
| 83 |
+
},
|
| 84 |
+
"arc": {
|
| 85 |
+
"a": 0.4375,
|
| 86 |
+
"b": 0.44,
|
| 87 |
+
"a_only": 5,
|
| 88 |
+
"b_only": 6,
|
| 89 |
+
"p": 1.0
|
| 90 |
+
}
|
| 91 |
+
}
|