Loading…
Loading…
This is an experimental research model, not an improved version. Starting from MiniMind's 64M pretrained weights, we edited the weights of two attention heads directly, to test whether "editing weights based on an understanding of the mechanism" can improve benchmark scores. It cannot: every change is within the error bars.
pretrain_768.pth (pretraining only, no SFT), hidden size 768, 8 layers, ~64M parametersQwen3ForCausalLM); logits match the original implementationOne change only: in layer 4, the 96 columns of o_proj that belong to attention heads 0 and 1 (L4H0, L4H1) were multiplied by 1.5. All other weights are identical to the base model.
An induction head finds an earlier position in the context holding the same token as the current one, and copies the token that followed it, e.g. after "A B … A" it predicts "B".
o_proj columns):| Scale | Δ total loss | Second-copy loss | Greedy repetition (rep-4) |
|---|---|---|---|
| ×0 | +0.484 | 12.15 | 0.11 |
| ×1 (base) | 0 | 2.56 | 0.33 |
| ×2 | +0.091 | 1.39 | 0.43 |
| ×3 | +0.266 | 1.75 | 0.52 |
At ×2 copying is strongest, but total loss gets worse and generations repeat more; at ×3 greedy generation starts producing garbled text. This model uses ×1.5 as a compromise.
Note: the losses in this table and in items 3–4 were measured on the last 500 lines of MiniMind's pretraining file (pretrain_t2t_mini.jsonl), which are English text.
lm-evaluation-harness, 0-shot, fp32, Apple MPS, identical settings for both models. Every prompt starts with the BOS token (see Usage for why this matters):
| Benchmark | Metric | Base | This model | Std. err. |
|---|---|---|---|---|
| C-Eval (valid) | acc | 23.85 | 23.70 | ±1.16 |
| CMMLU | acc | 25.53 | 25.14 | ±0.41 |
| ARC-Easy | acc_norm | 30.89 | 30.72 | ±0.95 |
| PIQA | acc | 53.92 | 53.70 | ±1.16 |
| OpenBookQA | acc_norm | 24.20 | 24.00 | ±1.92 |
| HellaSwag | acc_norm | 27.69 | 27.53 | ±0.45 |
| Social IQa | acc | 35.52 | 35.77 | ±1.08 |
A paired, question-by-question comparison gives the same answer: on every benchmark the difference between the two models is below one paired standard error (|z| < 1).
On held-out Chinese text, language-modelling loss goes from 2.318 to 2.343 (1.1% worse).
Interpretation: the edit does not change benchmark scores; the small differences go both ways and cannot be told apart from noise. The base model is close to chance on these benchmarks because it lacks knowledge; this edit only adjusts an existing copy-from-context mechanism and cannot add knowledge.
Note on BOS: by default, lm-evaluation-harness does not add BOS for this tokenizer, and add_bos_token=True has no effect on it. Our first run had no BOS; there, too, the edit made no significant difference (base vs. this model: C-Eval 24.89 / 26.00, CMMLU 24.88 / 24.67, ARC-Easy 28.16 / 28.28, PIQA 52.77 / 53.32, OpenBookQA 24.60 / 24.60, HellaSwag 28.29 / 28.25, Social IQa 34.54 / 33.62). Adding BOS mainly raised ARC-Easy for both models (base 28.16 → 30.89). To reproduce the table above, use a tokenizer whose post-processor prepends <|im_start|>.
The tokenizer does not add the BOS token (<|im_start|>) automatically, and this model needs it: later layers use BOS as an attention sink. Without BOS the model degenerates (e.g. it emits end-of-text immediately or repeats a word).
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "<this-repo>"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo)
ids = tok(tok.bos_token + "中国的首都是", return_tensors="pt").input_ids # prepend BOS manually
print(tok.decode(model.generate(ids, max_new_tokens=10, do_sample=False)[0]))
Apache 2.0, inherited from MiniMind. The only modification to the original weights is described under "What was changed".
这是一个研究用的实验模型,不是改进版。它在 MiniMind 的 64M 预训练权重上直接修改了两个注意力头的权重,用来检验“基于对机制的理解去编辑权重,能否提升 benchmark”。结论是不能:所有变化都在误差范围内。
pretrain_768.pth(只做过预训练,没有 SFT),hidden 768,8 层,约 64M 参数Qwen3ForCausalLM),转换后 logits 与原版一致只改了一处:第 4 层第 0、1 号注意力头(L4H0、L4H1)在 o_proj 中对应的 96 列,乘以 1.5。其余权重与原模型完全相同。
“归纳头”指的是这样一种注意力头:在上文中找到和当前 token 相同的位置,再把那个位置后面的 token 复制过来,例如看到 “A B … A” 时预测 “B”。
o_proj 列):| 倍数 | 总 loss 变化 | 重复序列第二遍 loss | 贪心生成复读率(rep-4) |
|---|---|---|---|
| ×0 | +0.484 | 12.15 | 0.11 |
| ×1(原模型) | 0 | 2.56 | 0.33 |
| ×2 | +0.091 | 1.39 | 0.43 |
| ×3 | +0.266 | 1.75 | 0.52 |
放大到 2 倍时照抄能力最强,但总 loss 变差、复读变多;3 倍时贪心生成开始出现乱码。本模型取折中的 1.5 倍。
注:上表和第 3、4 条的 loss 是在 MiniMind 预训练数据文件(pretrain_t2t_mini.jsonl)的最后 500 行上测的,这部分是英文文本。
lm-evaluation-harness,0-shot,fp32,Apple MPS,两个模型使用完全相同的评测设置,每道题开头都加了 BOS(原因见“使用”一节):
| benchmark | 指标 | 原模型 | 本模型 | 标准误 |
|---|---|---|---|---|
| C-Eval (valid) | acc | 23.85 | 23.70 | ±1.16 |
| CMMLU | acc | 25.53 | 25.14 | ±0.41 |
| ARC-Easy | acc_norm | 30.89 | 30.72 | ±0.95 |
| PIQA | acc | 53.92 | 53.70 | ±1.16 |
| OpenBookQA | acc_norm | 24.20 | 24.00 | ±1.92 |
| HellaSwag | acc_norm | 27.69 | 27.53 | ±0.45 |
| Social IQa | acc | 35.52 | 35.77 | ±1.08 |
按题目逐一配对比较,结论相同:每个 benchmark 上两个模型的差距都小于 1 倍配对标准误(|z| < 1)。
在中文留出文本上,语言建模 loss 从 2.318 变为 2.343,变差 1.1%。
解读:这个编辑没有改变 benchmark 成绩,微小的差距有涨有跌,和噪声无法区分。原模型在这些 benchmark 上本身就接近随机水平,它缺的是知识;这个编辑只是调整了已有的“照抄上文”机制,补不出知识。
关于 BOS:对这个分词器,lm-evaluation-harness 默认不加 BOS,add_bos_token=True 选项也不起作用。我们第一次测试没有加 BOS,那一组的结论同样是编辑没有显著影响(原模型 / 本模型:C-Eval 24.89 / 26.00,CMMLU 24.88 / 24.67,ARC-Easy 28.16 / 28.28,PIQA 52.77 / 53.32,OpenBookQA 24.60 / 24.60,HellaSwag 28.29 / 28.25,Social IQa 34.54 / 33.62)。加上 BOS 后,两个模型的 ARC-Easy 都明显上升(原模型 28.16 → 30.89)。要复现上表,需要使用一个会在开头自动加 <|im_start|> 的分词器。
分词器不会自动在开头加 BOS(<|im_start|>),但这个模型需要它:后几层把 BOS 当作注意力汇。不加 BOS 时模型会退化,比如直接输出结束符,或者一直复读同一个词。
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "<本仓库名>"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo)
ids = tok(tok.bos_token + "中国的首都是", return_tensors="pt").input_ids # prepend BOS manually
print(tok.decode(model.generate(ids, max_new_tokens=10, do_sample=False)[0]))
Apache 2.0,沿用原项目 MiniMind。本仓库对原权重的唯一修改见上文“改了什么”。