arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2502.07436cs.CV
收藏

Transformer中的知识蒸馏优化:消除对齐障碍实现多头注意力

Optimizing Knowledge Distillation in Transformers: Enabling Multi-Head Attention without Alignment Barriers

Zhaodong Bing, Linze Li, Jiajun Liang

AI总结:

针对Transformer知识蒸馏中师生注意力头数量不对齐的问题,提出无需额外参数或架构修改的Squeezing-Heads Distillation方法,通过线性近似压缩多头注意力图实现不同头数模型间的无缝知识迁移,在多任务上优于基线并取得最先进结果。

摘要:

Transformer中的知识蒸馏(KD)常因师生模型注意力头数量不对齐而面临挑战。现有方法要么要求头数相同,要么引入投影器以弥合维度差距,限制了灵活性与效率。我们提出压缩头蒸馏(SHD),一种通过高效线性近似压缩多头注意力图,实现不同头数模型间无缝知识迁移的新方法。与现有工作不同,SHD无需额外参数或架构修改即可消除对齐障碍。该方法动态将多个教师头的组合效应近似为更少的学生头,在减少冗余的同时保留细粒度注意力模式。在语言(LLaMA、GPT)和视觉(DiT、MDT)生成任务及视觉(DeiT)判别任务上的实验表明,SHD优于基于logit和特征对齐的KD基线,在图像分类、图像生成、语言微调及预训练中取得了最先进的结果。灵活的头压缩、无投影器设计及线性时间复杂度是其关键创新,使其成为蒸馏现代Transformer的通用且可扩展的解决方案。本工作弥合了KD中的关键差距,实现了紧凑模型的高效部署而不损失性能。

英文摘要:

Knowledge distillation (KD) in transformers often faces challenges due to misalignment in the number of attention heads between teacher and student models. Existing methods either require identical head counts or introduce projectors to bridge dimensional gaps, limiting flexibility and efficiency. We propose Squeezing-Heads Distillation (SHD), a novel approach that enables seamless knowledge transfer between models with varying head counts by compressing multi-head attention maps via efficient linear approximation. Unlike prior work, SHD eliminates alignment barriers without additional parameters or architectural modifications. Our method dynamically approximates the combined effect of multiple teacher heads into fewer student heads, preserving fine-grained attention patterns while reducing redundancy. Experiments across language (LLaMA, GPT) and vision (DiT, MDT) generative and vision (DeiT) discriminative tasks demonstrate SHD's effectiveness: it outperforms logit-based and feature-alignment KD baselines, achieving state-of-the-art results in image classification, image generation language fine-tuning, and language pre-training. The key innovations of flexible head compression, projector-free design, and linear-time complexity make SHD a versatile and scalable solution for distilling modern transformers. This work bridges a critical gap in KD, enabling efficient deployment of compact models without compromising performance.

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

↑