arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2604.00004cs.CLcs.AI
收藏

线性记忆注意力蒸馏:用于RoPE修复的线性内存注意力蒸馏

LinearARD: Linear-Memory Attention Distillation for RoPE Restoration

Institute of Automation, Chinese Academy of Sciences(中国科学院自动化研究所);Southwest University(西南大学);Dalian University of Technology(大连理工大学);University of Science and Technology Beijing(北京科技大学);University College London(伦敦大学学院)

Ning Yang, Hengyu Zhong, Wentao Wang, Baoliang Tian, Yuan Zhou, Haijun Zhang, Jun Wang

AI总结:

本文提出LinearARD,通过冻结的原生RoPE教师模型,利用注意力结构一致性恢复RoPE缩放的学生模型,以线性内存核克服二次内存瓶颈,提升长上下文性能。

摘要:

大型语言模型扩展上下文窗口通常通过缩放位置编码后进行轻量级连续预训练(CPT)实现。尽管有效于处理长序列,但此范式常破坏原始模型能力,导致在标准短文本基准上的性能下降。我们提出LinearARD,一种自蒸馏方法,通过冻结的原生RoPE教师模型,利用注意力结构一致性恢复RoPE缩放的学生模型。而非匹配模糊的隐藏状态,LinearARD对密集的Q/Q、K/K和V/V自关系矩阵的行分布进行对齐,直接监督注意力动态。为克服n×n关系图的二次内存瓶颈,我们引入线性内存核。该核利用每token的log-sum-exp统计信息,并将logit重计算融合到反向传播中,以计算精确的Kullback-Leibler散度和梯度。在LLaMA2-7B扩展从4K到32K的情况下,LinearARD恢复了最先进基线在短文本性能上的98.3%,并在长上下文基准上超越了基线。值得注意的是,我们的方法仅使用4.25M个训练token,而LongReD和CPT需要256M个token。我们的代码可在https://github.com/gracefulning/LinearARD上获取。

英文摘要:

The extension of context windows in Large Language Models is typically facilitated by scaling positional encodings followed by Continued Pre-Training (CPT). While effective, this paradigm is notoriously data-hungry and computationally expensive, requiring massive long-text corpora to recalibrate the model to the shifted positional distribution. We propose LinearARD, a restoration distillation method that restores Rotary Position Embedding (RoPE)-scaled students through attention-structure consistency with a frozen native-RoPE teacher. Rather than next-token prediction or opaque hidden-state matching, LinearARD aligns row-wise distributions of dense $Q/Q$, $K/K$, and $V/V$ self-relation matrices from the final attention layer to directly supervise attention dynamics. To remove the quadratic memory bottleneck of $n \times n$ relation maps, we introduce a linear-activation-memory kernel that stores only per-token log-sum-exp statistics and recomputes logits in the backward pass to obtain exact Kullback-Leibler divergence gradients. Across LLaMA2-7B, LLaMA3-8B, and Mistral-7B-v0.1 extended to 32K context, LinearARD recovers 93.1%/94.2%/94.3% of native short-context performance and achieves strong long-context robustness on RULER using only 4.25M tokens---amounting to just 1.6% (a $\sim$60$\times$ reduction) of the 256M-token budget required by state-of-the-art baselines. Under this severely constrained budget, CPT and LongReD remain near zero on RULER, demonstrating that relation-level restoration provides a substantially better efficiency-quality tradeoff. Our code is available at https://github.com/gracefulning/LinearARD.

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

↑