arXiv:2508.04581cs.CLcs.AI2025-08AAAI被引 5

通过矩阵字典学习实现注意力层间权重共享,大幅压缩模型参数。

Share Your Attention: Transformer Weight Sharing via Matrix-based Dictionary Learning

  • 将注意力矩阵分解为共享字典原子,跨层复用权重
  • 参数减少66.7%且性能与原模型持平
  • 无需微调或结构改动,适合快速部署到各类模型

大型语言模型虽推动了AI应用,但其高计算与内存开销限制了广泛部署。现有压缩技术多聚焦层内优化(如低秩近似或注意力剪枝),而变压器的重复分层结构暗示着显著的层间冗余——这一维度长期未被充分探索,除键值缓存外。受卷积网络字典学习启发,我们提出一种跨层结构化权重共享框架。该方法将注意力投影矩阵(Q、K、V、O)分解为共享字典原子,使注意力模块参数减少66.7%,同时保持性能相当。与需蒸馏或架构修改的复杂方法不同,MASA(注意力中的矩阵原子共享)作为即插即用替换,使用标准优化器训练,并将每层权重表示为共享矩阵原子的线性组合。在100M至700M参数规模下实验表明,MASA在基准准确率和困惑度上优于GQA、低秩基线及近期的Repeat-all-over/Sequential共享方法,且在相近参数预算下表现更优。消融实验验证了字典大小的鲁棒性以及共享表示对跨层统计规律的捕捉能力。扩展至视觉变压器(ViT),MASA在图像分类任务中以66.7%更少的注意力参数达到相当性能。通过结合字典学习与变压器效率,MASA为无性能损失的参数高效模型提供了可扩展范式。最后,我们探究了将MASA应用于大预训练模型的可行性,在不造成显著性能下降的前提下减少其参数量。

原文摘要 · Abstract (English)

Large language models have revolutionized AI applications, yet their high computational and memory demands hinder their widespread deployment. Existing compression techniques focus on intra-block optimizations (e.g., low-rank approximation or attention pruning), while the repetitive layered structure of transformers implies significant inter-block redundancy - a dimension largely unexplored beyond key-value (KV) caching. Inspired by dictionary learning in convolutional networks, we propose a framework for structured weight sharing across transformer layers. Our approach decomposes attention projection matrices (Q, K, V, O) into shared dictionary atoms, reducing the attention module's parameters by 66.7\% while achieving on-par performance. Unlike complex methods requiring distillation or architectural changes, MASA (Matrix Atom Sharing in Attention) operates as a drop-in replacement-trained with standard optimizers - and represents each layer's weights as linear combinations of shared matrix atoms. Experiments across scales (100M-700M parameters) show that MASA achieves better benchmark accuracy and perplexity than GQA, low-rank baselines and recent Repeat-all-over/Sequential sharing at comparable parameter budgets. Ablation studies confirm robustness to the dictionary size and the efficacy of shared representations in capturing cross-layer statistical regularities. Extending to Vision Transformers (ViT), MASA matches performance metrics on image classification tasks with 66.7\% fewer attention parameters. By combining dictionary learning strategies with transformer efficiency, MASA offers a scalable blueprint for parameter-efficient models without sacrificing performance. Finally, we investigate the possibility of employing MASA on large pretrained models to reduce their number of parameters without experiencing any significant drop in their performance.

模型压缩注意力机制权重共享Transformer

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。