DHA: Learning Decoupled-Head Attention from Transformer Checkpoints via Adaptive Heads Fusion

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Chen, Yilong, Zhang, Linhao, Shang, Junyuan, Zhang, Zhenyu, Liu, Tingwen, Wang, Shuohuan, Sun, Yu
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866916511856197632
author Chen, Yilong
Zhang, Linhao
Shang, Junyuan
Zhang, Zhenyu
Liu, Tingwen
Wang, Shuohuan
Sun, Yu
author_facet Chen, Yilong
Zhang, Linhao
Shang, Junyuan
Zhang, Zhenyu
Liu, Tingwen
Wang, Shuohuan
Sun, Yu
contents Large language models (LLMs) with billions of parameters demonstrate impressive performance. However, the widely used Multi-Head Attention (MHA) in LLMs incurs substantial computational and memory costs during inference. While some efforts have optimized attention mechanisms by pruning heads or sharing parameters among heads, these methods often lead to performance degradation or necessitate substantial continued pre-training costs to restore performance. Based on the analysis of attention redundancy, we design a Decoupled-Head Attention (DHA) mechanism. DHA adaptively configures group sharing for key heads and value heads across various layers, achieving a better balance between performance and efficiency. Inspired by the observation of clustering similar heads, we propose to progressively transform the MHA checkpoint into the DHA model through linear fusion of similar head parameters step by step, retaining the parametric knowledge of the MHA checkpoint. We construct DHA models by transforming various scales of MHA checkpoints given target head budgets. Our experiments show that DHA remarkably requires a mere 0.25\% of the original model's pre-training budgets to achieve 97.6\% of performance while saving 75\% of KV cache. Compared to Group-Query Attention (GQA), DHA achieves a 5$\times$ training acceleration, a maximum of 13.93\% performance improvement under 0.01\% pre-training budget, and 4\% relative improvement under 0.05\% pre-training budget.
format Preprint
id arxiv_https___arxiv_org_abs_2406_06567
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle DHA: Learning Decoupled-Head Attention from Transformer Checkpoints via Adaptive Heads Fusion
Chen, Yilong
Zhang, Linhao
Shang, Junyuan
Zhang, Zhenyu
Liu, Tingwen
Wang, Shuohuan
Sun, Yu
Machine Learning
Artificial Intelligence
Computation and Language
Large language models (LLMs) with billions of parameters demonstrate impressive performance. However, the widely used Multi-Head Attention (MHA) in LLMs incurs substantial computational and memory costs during inference. While some efforts have optimized attention mechanisms by pruning heads or sharing parameters among heads, these methods often lead to performance degradation or necessitate substantial continued pre-training costs to restore performance. Based on the analysis of attention redundancy, we design a Decoupled-Head Attention (DHA) mechanism. DHA adaptively configures group sharing for key heads and value heads across various layers, achieving a better balance between performance and efficiency. Inspired by the observation of clustering similar heads, we propose to progressively transform the MHA checkpoint into the DHA model through linear fusion of similar head parameters step by step, retaining the parametric knowledge of the MHA checkpoint. We construct DHA models by transforming various scales of MHA checkpoints given target head budgets. Our experiments show that DHA remarkably requires a mere 0.25\% of the original model's pre-training budgets to achieve 97.6\% of performance while saving 75\% of KV cache. Compared to Group-Query Attention (GQA), DHA achieves a 5$\times$ training acceleration, a maximum of 13.93\% performance improvement under 0.01\% pre-training budget, and 4\% relative improvement under 0.05\% pre-training budget.
title DHA: Learning Decoupled-Head Attention from Transformer Checkpoints via Adaptive Heads Fusion
topic Machine Learning
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2406.06567