{"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/fastformer-additive-attention-is-all-you-need","title":"Fastformer: Additive Attention Can Be All You Need","arxiv_id":"2108.09084","date":"2021-08-20","proceeding":null,"authors":["Chuhan Wu","Fangzhao Wu","Tao Qi","Yongfeng Huang","Xing Xie"],"abstract":"Transformer is a powerful model for text understanding. However, it is inefficient due to its quadratic complexity to input sequence length. Although there are many methods on Transformer acceleration, they are still either inefficient on long sequences or not effective enough. In this paper, we propose Fastformer, which is an efficient Transformer model based on additive attention. In Fastformer, instead of modeling the pair-wise interactions between tokens, we first use additive attention mechanism to model global contexts, and then further transform each token representation based on its interaction with global context representations. In this way, Fastformer can achieve effective context modeling with linear complexity. Extensive experiments on five datasets show that Fastformer is much more efficient than many existing Transformer models and can meanwhile achieve comparable or even better long text modeling performance.","url_abs":"https://arxiv.org/abs/2108.09084v6","url_pdf":"https://arxiv.org/pdf/2108.09084v6.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":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/wuch15/Fastformer","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/04RR/SOTA-Vision","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/Rishit-dagli/Fast-Transformer","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/keonlee9420/Comprehensive-Transformer-TTS","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/lucidrains/fast-transformer-pytorch","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/mtanghu/LEAP","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"CC0-1.0"}},{"paper_slug":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/rainyBJ/Fastformer-Paddle","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"paddle","reach":{"status":"ok"}},{"paper_slug":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/wilile26811249/Fastformer-PyTorch","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/ypeleg/Fastformer-Keras","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":{"status":"ok"}},{"paper_slug":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/MindCode-4/code-11/tree/main/fastformer-additive","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/MindCode-4/code-7/tree/main/fastformer-additive","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/MindSpore-scientific-2/code-12/tree/main/fastformer-additive","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"fastformer-additive-attention-is-all-you-need","repo_url":"https://github.com/nanzhaogang/contrib/tree/master/application/fastformer-additive-attention-can-b-all-you-need","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null}],"tasks":[{"task_slug":"all","task_name":"All"},{"task_slug":"news-recommendation","task_name":"News Recommendation"},{"task_slug":"text-classification","task_name":"Text Classification"},{"task_slug":"text-summarization","task_name":"Text Summarization"}],"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":"fastformer","method_name":"Fastformer"},{"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":"tanh-activation","method_name":"Tanh Activation"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[{"slug":"fastformer","name":"Fastformer","full_name":"Fastformer"}],"results":[{"leaderboard":"/sota/text-summarization-on-cnn-daily-mail-2","task":"Text Summarization","dataset":"CNN / Daily Mail (Anonymized)","model":"Fastformer","rank_in_archive_order":11,"of":13,"metrics":{"ROUGE-1":"38.54","ROUGE-2":"16.22","ROUGE-L":"36.21"},"uses_additional_data":false},{"leaderboard":"/sota/text-summarization-on-pubmed-1","task":"Text Summarization","dataset":"Pubmed","model":"Fastformer","rank_in_archive_order":28,"of":29,"metrics":{"ROUGE-1":"38.09","ROUGE-2":"15.44","ROUGE-L":"34.81"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2108.09084","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2108.09084"}},"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":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/MindCode-4/code-7/tree/main/fastformer-additive","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/MindSpore-scientific-2/code-12/tree/main/fastformer-additive","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/nanzhaogang/contrib/tree/master/application/fastformer-additive-attention-can-b-all-you-need","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/04RR/SOTA-Vision","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/lucidrains/fast-transformer-pytorch","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/MindCode-4/code-11/tree/main/fastformer-additive","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/mtanghu/LEAP","reach":{"status":"ok","spdx":"CC0-1.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/keonlee9420/Comprehensive-Transformer-TTS","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/wuch15/Fastformer","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/ypeleg/Fastformer-Keras","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/wilile26811249/Fastformer-PyTorch","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/Rishit-dagli/Fast-Transformer","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/rainyBJ/Fastformer-Paddle","reach":{"status":"ok"}}],"summary":{"ran_draft_wrong":2,"ran_violates":2},"by_repo_kind":{"listed":{"samples":1,"ran":1,"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":3,"samples":[{"code_sha256_prefix":"a7b572de5bd1ac1d","entry":"FeedForward","repo":"lucidrains/fast-transformer-pytorch","repo_kind":"listed","path":"fast_transformer_pytorch/fast_transformer_pytorch.py","file_url":"https://github.com/lucidrains/fast-transformer-pytorch/blob/HEAD/fast_transformer_pytorch/fast_transformer_pytorch.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a7b572de5bd1ac1d"}},{"code_sha256_prefix":"60fff7c3c400d7ff","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":"60fff7c3c400d7ff"}},{"code_sha256_prefix":"aa5486a3650902d8","entry":"exists","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":"deterministic","behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"aa5486a3650902d8"}},{"code_sha256_prefix":"2b5c06c1ba593c3c","entry":"read_lexicon","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":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"2b5c06c1ba593c3c"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}