arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.21249cs.LGcs.CL
收藏

RoPE 是阻止还是削弱检索头?跨模型族的机制分析

Does RoPE Prevent or Degrade Retrieval Heads? A Mechanistic Analysis Across Model Families

Independent Researcher(独立研究员)

Cengizhan Bayram

AI总结:

通过因果掩码和维度修补实验,发现旋转位置嵌入(RoPE)的低频维度对检索头功能至关重要,但高频维度无影响,且检索头数量与RoPE基超参数θ无关。

摘要:

检索头(retrieval heads)是从早期上下文复制信息到当前位置的注意力头,被认为是长上下文回忆的机制基础。旋转位置嵌入(RoPE)通过随基超参数θ衰减的频率旋转查询和键,一个自然的假设是这种旋转要么阻止检索头的形成,要么削弱其功能。我们在四个开源7-8B模型(涵盖多头和分组查询注意力,θ跨度100倍)上,使用配对种子的针尖搜索测试、层聚类置换和因果头掩码进行了测试。(i) 检索头是因果必要的:在OLMo-2中掩码87个检测到的头,回忆从1.00降至0.00,而掩码匹配的随机头无影响;这在Qwen中重复。(ii) 更高的θ不会减少检索头数量(LLaMA-3.1在θ=500K时有47个头,而LLaMA-2在θ=10K时有42个),反驳了阻止假设。(iii) 范数-效用关系是族特定的,且方向相反(Qwen d=-0.49,OLMo d=+0.50,均显著;LLaMA无显著);由于OLMo和LLaMA-3.1共享θ=500K但结果不同,该效应不是由θ驱动的。(iv) 基于Chiang和Yogatama (2025),一个受控修补实验表明,将检索头的最低频率RoPE维度置零会剂量依赖地降低回忆(当128个维度中的32个被置零时,回忆从1.00降至0.18,而随机维度为0.98);该效应是头特定和任务特定的。因果变量是RoPE频率,而非范数-效用。该方向在所有五个修补模型(OLMo-2, Qwen2.5-7B/14B, Gemma-2, Mistral)中保持一致,涵盖四个谱系和两个规模。我们不声称跨模型幅度。代码和配对种子工具已发布。

英文摘要:

Retrieval heads, attention heads that copy information from earlier context to the current position, have been proposed as the mechanistic substrate for long-context recall. Rotary position embeddings (RoPE) rotate queries and keys by frequencies decaying with a base hyperparameter theta, and a natural hypothesis is that this rotation either prevents retrieval heads from forming or degrades their function. We test both across four open-weight 7-8B models spanning multi-head and grouped-query attention and a 100x range of theta, using paired-seed needle-in-a-haystack tests, layer-clustered permutation, and causal head-masking. (i) Retrieval heads are causally necessary: masking the 87 detected heads in OLMo-2 collapses recall from 1.00 to 0.00, while masking matched random heads has no effect; this replicates in Qwen. (ii) Higher theta does not reduce retrieval-head count (LLaMA-3.1 at theta=500K has 47 heads vs LLaMA-2 at theta=10K with 42), refuting the prevention hypothesis. (iii) The norm-utility relation is family-specific and significant in opposite directions (Qwen d=-0.49, OLMo d=+0.50, both significant; LLaMA null); since OLMo and LLaMA-3.1 share theta=500K yet differ, the effect is not theta-driven. (iv) Building on Chiang and Yogatama (2025), a controlled patch shows that zeroing the lowest-frequency RoPE dimensions of retrieval heads degrades recall dose-dependently (1.00 to 0.18 when 32 of 128 dimensions are zeroed, vs 0.98 for random dimensions); the effect is head-specific and task-specific. The causal variable is RoPE frequency, not norm-utility. The direction holds in all five models patched (OLMo-2, Qwen2.5-7B/14B, Gemma-2, Mistral) across four lineages and two scales. We do not claim cross-model magnitude. Code and a paired-seed harness are released.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑