超越均匀查询分布:键驱动的分组查询注意力
Beyond Uniform Query Distribution: Key-Driven Grouped Query Attention
AI总结:
针对自注意力内存占用问题,提出KDGQA、DGQA和PGQA方法,利用键头范数动态分配查询,在图像分类任务中使ViT-L准确率提升达8%。
摘要:
Transformer架构通过其自注意力机制彻底改变了深度学习,该机制能有效捕捉上下文信息。然而,自注意力的内存占用对长序列任务提出了重大挑战。Grouped Query Attention (GQA)(分组查询注意力)通过对查询进行分组并对相应的键值头进行均值池化来解决这一问题,它以灵活的方式减少了整体参数数量和内存需求,同时不会对模型准确性造成不利影响。在本研究中,我们引入了对GQA的增强,重点关注两种偏离分组静态特性的新方法:Key-Distributed GQA (KDGQA)(键分布GQA)和Dynamic Key-Distributed GQA (DGQA)(动态键分布GQA),它们利用键头范数的信息来指导查询分配。具体而言,KDGQA关注每次前向传播期间键头范数的比率,而DGQA则研究范数比率在训练过程中的演变。此外,我们提出了Perturbed GQA (PGQA)(扰动GQA)作为案例研究,它通过从注意力图中减去噪声来引入(静态)分组形成中的可变性。我们在CIFAR-10、CIFAR-100、Food101和Tiny ImageNet等数据集上,对经过向上训练的Vision Transformers进行图像分类的实验表明,这些变体通过更明智和自适应的分组机制在原始GQA上展现出改进的潜力:具体而言,与GQA和其他变体相比,ViT-L在使用DGQA时准确率提高了高达8%。我们进一步分析了Key-Value Heads数量对性能的影响,强调了利用查询-键亲和力的重要性。代码可在GitHub上获取。
英文摘要:
The Transformer architecture has revolutionized deep learning through its Self-Attention mechanism, which effectively captures contextual information. However, the memory footprint of Self-Attention presents significant challenges for long-sequence tasks. Grouped Query Attention (GQA) addresses this issue by grouping queries and mean-pooling the corresponding key-value heads - reducing the number of overall parameters and memory requirements in a flexible manner without adversely compromising model accuracy. In this work, we introduce enhancements to GQA, focusing on two novel approaches that deviate from the static nature of grouping: Key-Distributed GQA (KDGQA) and Dynamic Key-Distributed GQA (DGQA), which leverage information from the norms of the key heads to inform query allocation. Specifically, KDGQA looks at the ratios of the norms of the key heads during each forward pass, while DGQA examines the ratios of the norms as they evolve through training. Additionally, we present Perturbed GQA (PGQA) as a case-study, which introduces variability in (static) group formation via subtracting noise from the attention maps. Our experiments with up-trained Vision Transformers, for Image Classification on datasets such as CIFAR-10, CIFAR-100, Food101, and Tiny ImageNet, demonstrate the promise of these variants in improving upon the original GQA through more informed and adaptive grouping mechanisms: specifically ViT-L experiences accuracy gains of up to 8% when utilizing DGQA in comparison to GQA and other variants. We further analyze the impact of the number of Key-Value Heads on performance, underscoring the importance of utilizing query-key affinities. Code is available on GitHub.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。