Papers › MoH: Multi-Head Attention as Mixture-of-Head Attention

MoH: Multi-Head Attention as Mixture-of-Head Attention

15 Oct 2024arXiv:2410.11842archive 2025-07-28

Peng Jin, Bo Zhu, Li Yuan, Shuicheng Yan

In this work, we upgrade the multi-head attention mechanism, the core of the Transformer model, to improve efficiency while maintaining or surpassing the previous accuracy level. We show that multi-head attention can be expressed in the summation form. Drawing on the insight that not all attention heads hold equal significance, we propose Mixture-of-Head attention (MoH), a new architecture that treats attention heads as experts in the Mixture-of-Experts (MoE) mechanism. MoH has two significant advantages: First, MoH enables each token to select the appropriate attention heads, enhancing inference efficiency without compromising accuracy or increasing the number of parameters. Second, MoH replaces the standard summation in multi-head attention with a weighted summation, introducing flexibility to the attention mechanism and unlocking extra performance potential. Extensive experiments on ViT, DiT, and LLMs demonstrate that MoH outperforms multi-head attention by using only 50%-90% of the attention heads. Moreover, we demonstrate that pre-trained multi-head attention models, such as LLaMA3-8B, can be further continue-tuned into our MoH models. Notably, MoH-LLaMA3-8B achieves an average accuracy of 64.0% across 14 benchmarks, outperforming LLaMA3-8B by 2.4% by utilizing only 75% of the attention heads. We believe the proposed MoH is a promising alternative to multi-head attention and provides a strong foundation for developing advanced and efficient attention-based models.

PaperPDFCodeCode Syntology ran

In Syntology View this paper on Syntology: its repositories, every harvested function with whether it ran, its licence and the call to fetch it.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2410.11842")

Code

Syntology Ran 14 of 18 code samples harvested from 3 repositories linked to this paper; 4 have no recorded run. Of those that ran: 5 ran · our draft was wrong; 3 ran · fixture could not drive it; 6 ran with no contract checked.

By repository: official repository: 4 samples from 1 repository, 3 ran; community (archive-listed): 11 samples from 2 repositories, 8 ran; 3 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

skyworkai/moh officialmentioned in papermentioned on GitHubpytorch report
pku-yuangroup/chat-univi mentioned on GitHubpytorchApache-2.0 report
skyworkai/moe-plus-plus mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

18 samples harvested; 14 ran; 0 honoured the contract we drafted; 4 have no recorded run. Read from Syntology's graph 2026-09-25; that is when this build read the record, not when the samples ran.

5ran · our draft was wrong
3ran · fixture could not drive it
6ran
4unverified

Licence: 3 of the 18 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 3 repositories linked to this paper, official or community; each sample names its own and says which. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

normal_kl SkyworkAI/MoH/MoH-DiT/diffusion/diffusion_utils.py official repository ran · fixture could not drive it fingerprinted Apache-2.0 (permissive) · 3f37a54ade181a61 · report
approx_standard_normal_cdf SkyworkAI/MoH/MoH-DiT/diffusion/diffusion_utils.py official repository ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · d6a68e210556f857 · report
continuous_gaussian_log_likelihood SkyworkAI/MoH/MoH-DiT/diffusion/diffusion_utils.py official repository ran · our draft was wrong Apache-2.0 (permissive) · 57848f6ed380e2e5 · report
Attention skyworkai/moh/MoH-ViT/attention.py official repository unverified Apache-2.0 (permissive) · 7b9f5a8e366cc24e · report
DynamicNTKScalingRotaryEmbedding skyworkai/moe-plus-plus/MoE++/modeling_moe_plus_plus.py community (archive-listed) ran Apache-2.0 (permissive) · c39d2f7f60570686 · report
LinearScalingRotaryEmbedding skyworkai/moe-plus-plus/MoE++/modeling_moe_plus_plus.py community (archive-listed) ran Apache-2.0 (permissive) · eebf71aed18a0f87 · report
MoeConfig skyworkai/moe-plus-plus/MoE++/modeling_moe_plus_plus.py community (archive-listed) ran Apache-2.0 (permissive) · 420932dc6224ccb9 · report
NTKScalingRotaryEmbedding skyworkai/moe-plus-plus/MoE++/modeling_moe_plus_plus.py community (archive-listed) ran Apache-2.0 (permissive) · 9a1f7fea1bda87f8 · report
RotaryEmbedding skyworkai/moe-plus-plus/MoE++/modeling_moe_plus_plus.py community (archive-listed) ran Apache-2.0 (permissive) · 4390a52a532857aa · report
get_chunk pku-yuangroup/chat-univi/ChatUniVi/eval/model_coco_vqa.py community (archive-listed) ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · 42a46570620cd9fa · report
read_json pku-yuangroup/chat-univi/ChatUniVi/eval/model_video_qa.py community (archive-listed) ran Apache-2.0 (permissive) · c578a6846674ff45 · report
split_list pku-yuangroup/chat-univi/ChatUniVi/eval/model_coco_vqa.py community (archive-listed) ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · 076c252c52cbb161 · report
Attention skyworkai/moe-plus-plus/MoE++/modeling_moe_plus_plus.py community (archive-listed) unverified Apache-2.0 (permissive) · 513d27b0995b5f3e · report
save_image_to_local pku-yuangroup/chat-univi/main_demo_13B.py community (archive-listed) unverified Apache-2.0 (permissive) · e2e5c3a95a6aebb4 · report
save_video_to_local pku-yuangroup/chat-univi/main_demo_13B.py community (archive-listed) unverified Apache-2.0 (permissive) · cab3546afd60006d · report
repeat_kv identical code first harvested elsewhere ran · fixture could not drive it fingerprinted licence of this copy not recorded · 30d7eec482ebf6b1 · report
apply_rotary_pos_emb identical code first harvested elsewhere ran · fixture could not drive it licence of this copy not recorded · d61c483a3c2b3156 · report
rotate_half identical code first harvested elsewhere ran · our draft was wrong fingerprinted licence of this copy not recorded · b99eea6376d1e212 · report

Tasks

Mixture-of-Experts

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutLabel SmoothingLayer NormalizationLinear LayerMulti-Head AttentionPosition-Wise Feed-Forward LayerResidual ConnectionSoftmaxTransformer

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections