Papers › Agent Attention: On the Integration of Softmax and Linear Attention

Agent Attention: On the Integration of Softmax and Linear Attention

14 Dec 2023arXiv:2312.08874archive 2025-07-28

Dongchen Han, Tianzhu Ye, Yizeng Han, Zhuofan Xia, Siyuan Pan, Pengfei Wan, Shiji Song, Gao Huang

The attention module is the key component in Transformers. While the global attention mechanism offers high expressiveness, its excessive computational cost restricts its applicability in various scenarios. In this paper, we propose a novel attention paradigm, Agent Attention, to strike a favorable balance between computational efficiency and representation power. Specifically, the Agent Attention, denoted as a quadruple (Q, A, K, V), introduces an additional set of agent tokens A into the conventional attention module. The agent tokens first act as the agent for the query tokens Q to aggregate information from K and V, and then broadcast the information back to Q. Given the number of agent tokens can be designed to be much smaller than the number of query tokens, the agent attention is significantly more efficient than the widely adopted Softmax attention, while preserving global context modelling capability. Interestingly, we show that the proposed agent attention is equivalent to a generalized form of linear attention. Therefore, agent attention seamlessly integrates the powerful Softmax attention and the highly efficient linear attention. Extensive experiments demonstrate the effectiveness of agent attention with various vision Transformers and across diverse vision tasks, including image classification, object detection, semantic segmentation and image generation. Notably, agent attention has shown remarkable performance in high-resolution scenarios, owning to its linear attention nature. For instance, when applied to Stable Diffusion, our agent attention accelerates generation and substantially enhances image generation quality without any additional training. Code is available at https://github.com/LeapLabTHU/Agent-Attention.

PaperPDFCodeCode Syntology ran

In Syntology 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="2312.08874")

Code

Syntology Ran 6 of 19 code samples harvested from 1 repository linked to this paper; 13 have no recorded run. Of those that ran: 1 ran · honoured contract; 1 ran · violated contract; 2 ran · our draft was wrong; 2 ran · fixture could not drive it.

By repository: official repository: 18 samples from 1 repository, 5 ran; 1 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.

leaplabthu/agent-attention officialmentioned in papermentioned on GitHubpytorch report
lucidrains/agent-attention-pytorch 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

19 samples harvested; 6 ran; 1 honoured the contract we drafted; 13 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
1ran · violated contract
2ran · our draft was wrong
2ran · fixture could not drive it
13unverified

Licence: 19 of the 19 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 leaplabthu/agent-attention. 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.

window_partition leaplabthu/agent-attention/agent_transformer/models/agent_swin.py official repository ran · fixture could not drive it fingerprinted no licence file found · pointer only · 144d10b49baeb8a6 · report
count_parameters leaplabthu/agent-attention/agent_transformer/temp.py official repository ran · honoured contract no licence file found · pointer only · f6b944f50d3f15ae · report
img2windows leaplabthu/agent-attention/agent_transformer/models/agent_cswin.py official repository ran · fixture could not drive it no licence file found · pointer only · 39b18f062e0cc6d9 · report
window_reverse leaplabthu/agent-attention/agent_transformer/models/agent_swin.py official repository ran · our draft was wrong no licence file found · pointer only · 61bf152e6a42a184 · report
windows2img leaplabthu/agent-attention/agent_transformer/models/agent_cswin.py official repository ran · our draft was wrong no licence file found · pointer only · ab01fbfe58c75b08 · report
Agent_CSWin_64_24181_tiny_224 leaplabthu/agent-attention/agent_transformer/models/agent_cswin.py official repository unverified no licence file found · pointer only · 9ea67e130f91790b · report
agent_pvt_medium leaplabthu/agent-attention/agent_transformer/models/agent_pvt.py official repository unverified no licence file found · pointer only · cde1668e5b186869 · report
agent_pvt_small leaplabthu/agent-attention/agent_transformer/models/agent_pvt.py official repository unverified no licence file found · pointer only · 941e08e41b939a56 · report
agent_pvt_tiny leaplabthu/agent-attention/agent_transformer/models/agent_pvt.py official repository unverified no licence file found · pointer only · 18fe6a56092254c6 · report
build_model leaplabthu/agent-attention/agent_transformer/models/build.py official repository unverified no licence file found · pointer only · 11b1272f108e216a · report
build_optimizer leaplabthu/agent-attention/agent_transformer/optimizer.py official repository unverified no licence file found · pointer only · fcf2d41dd445a70b · report
build_scheduler leaplabthu/agent-attention/agent_transformer/lr_scheduler.py official repository unverified no licence file found · pointer only · 07e8b4b487c0abb6 · report
check_keywords_in_name leaplabthu/agent-attention/agent_transformer/optimizer.py official repository unverified no licence file found · pointer only · b0a5beb34716d5a6 · report
checkpoint_filter_fn leaplabthu/agent-attention/agent_transformer/models/agent_deit.py official repository unverified no licence file found · pointer only · 5dac11fdc41c896b · report
create_logger leaplabthu/agent-attention/agent_transformer/logger.py official repository unverified no licence file found · pointer only · 82e52feafbf040bb · report
get_config leaplabthu/agent-attention/agent_transformer/config.py official repository unverified no licence file found · pointer only · 20681a9065c0a731 · report
resize_pos_embed leaplabthu/agent-attention/agent_transformer/models/agent_deit.py official repository unverified no licence file found · pointer only · 1dbef2d4da4ee10f · report
set_weight_decay_and_lr leaplabthu/agent-attention/agent_transformer/optimizer.py official repository unverified no licence file found · pointer only · 104af48a94364f24 · report
exists identical code first harvested elsewhere ran · violated contract fingerprinted licence of this copy not recorded · b7c3487f192e31b7 · report

Tasks

Computational EfficiencyImage ClassificationImage GenerationObject DetectionSemantic Segmentationimage-classificationobject-detection

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

DiffusionSETSoftmax

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