{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/cascaded-head-colliding-attention","title":"Cascaded Head-colliding Attention","arxiv_id":"2105.14850","date":"2021-05-31","proceeding":"ACL 2021 5","authors":["Lin Zheng","Zhiyong Wu","Lingpeng Kong"],"abstract":"Transformers have advanced the field of natural language processing (NLP) on a variety of important tasks. At the cornerstone of the Transformer architecture is the multi-head attention (MHA) mechanism which models pairwise interactions between the elements of the sequence. Despite its massive success, the current framework ignores interactions among different heads, leading to the problem that many of the heads are redundant in practice, which greatly wastes the capacity of the model. To improve parameter efficiency, we re-formulate the MHA as a latent variable model from a probabilistic perspective. We present cascaded head-colliding attention (CODA) which explicitly models the interactions between attention heads through a hierarchical variational distribution. We conduct extensive experiments and demonstrate that CODA outperforms the transformer baseline, by $0.6$ perplexity on \\texttt{Wikitext-103} in language modeling, and by $0.6$ BLEU on \\texttt{WMT14 EN-DE} in machine translation, due to its improvements on the parameter efficiency.\\footnote{Our implementation is publicly available at \\url{https://github.com/LZhengisme/CODA}.}","url_abs":"https://arxiv.org/abs/2105.14850v1","url_pdf":"https://arxiv.org/pdf/2105.14850v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"cascaded-head-colliding-attention","repo_url":"https://github.com/LZhengisme/CODA","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"machine-translation","task_name":"Machine Translation"},{"task_slug":"translation","task_name":"Translation"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2105.14850","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2105.14850"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/pytorch/fairseq","reach":null},{"provenance":"deterministic:regex_extraction","url":"https://github.com/LZhengisme/CODA","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_draft_wrong":3,"ran":3,"ran_violates":1,"ran_honours":1,"ran_fixture":1,"unverified":1},"by_repo_kind":{"official":{"samples":3,"ran":3,"repositories":1},"found_in_text":{"samples":5,"ran":4,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":5,"samples":[{"code_sha256_prefix":"96cbb5e9ca5b6be0","entry":"Embedding","repo":"LZhengisme/CODA","repo_kind":"official","path":"fairseq/models/coda_transformer.py","file_url":"https://github.com/LZhengisme/CODA/blob/HEAD/fairseq/models/coda_transformer.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"96cbb5e9ca5b6be0"}},{"code_sha256_prefix":"9f73b0c0fce2870d","entry":"Kmeans","repo":"pytorch/fairseq","repo_kind":"found_in_text","path":"fairseq/modules/kmeans_attention.py","file_url":"https://github.com/pytorch/fairseq/blob/HEAD/fairseq/modules/kmeans_attention.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9f73b0c0fce2870d"}},{"code_sha256_prefix":"70d8f18adccf84c1","entry":"KmeansAttention","repo":"pytorch/fairseq","repo_kind":"found_in_text","path":"fairseq/modules/kmeans_attention.py","file_url":"https://github.com/pytorch/fairseq/blob/HEAD/fairseq/modules/kmeans_attention.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"70d8f18adccf84c1"}},{"code_sha256_prefix":"8cd8cb0d1e9e63e4","entry":"Linear","repo":"LZhengisme/CODA","repo_kind":"official","path":"fairseq/models/coda_transformer.py","file_url":"https://github.com/LZhengisme/CODA/blob/HEAD/fairseq/models/coda_transformer.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"8cd8cb0d1e9e63e4"}},{"code_sha256_prefix":"27ab3e63c68fe18a","entry":"default","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"27ab3e63c68fe18a"}},{"code_sha256_prefix":"62b973828672478f","entry":"ema","repo":"pytorch/fairseq","repo_kind":"found_in_text","path":"fairseq/modules/kmeans_attention.py","file_url":"https://github.com/pytorch/fairseq/blob/HEAD/fairseq/modules/kmeans_attention.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"62b973828672478f"}},{"code_sha256_prefix":"a91aa4d3b29e189e","entry":"is_empty","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"a91aa4d3b29e189e"}},{"code_sha256_prefix":"dfbee029313fac6a","entry":"kmeans_iter","repo":"pytorch/fairseq","repo_kind":"found_in_text","path":"fairseq/modules/kmeans_attention.py","file_url":"https://github.com/pytorch/fairseq/blob/HEAD/fairseq/modules/kmeans_attention.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"dfbee029313fac6a"}},{"code_sha256_prefix":"82bdf940665aeeb4","entry":"safe_readline","repo":"LZhengisme/CODA","repo_kind":"official","path":"fairseq/binarizer.py","file_url":"https://github.com/LZhengisme/CODA/blob/HEAD/fairseq/binarizer.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"82bdf940665aeeb4"}},{"code_sha256_prefix":"b46ee69b75929ac8","entry":"ema_inplace","repo":"pytorch/fairseq","repo_kind":"found_in_text","path":"fairseq/modules/kmeans_attention.py","file_url":"https://github.com/pytorch/fairseq/blob/HEAD/fairseq/modules/kmeans_attention.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b46ee69b75929ac8"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}