[論文レビュー] Agent Attention: On the Integration of Softmax and Linear Attention
Agent Attentionを紹介する新しい注意機構で、エージェントトークンを用いてグローバル情報を集約・伝播し、Softmaxと線形注意を効果的に統合して線形計算量で高い表現力を実現します。
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.
研究の動機と目的
- 従来のSoftmax注意を超える効率的で表現力のある視覚変換器の注意機構を動機づける。
- Softmaxと線形注意をグローバルな文脈モデリングを犠牲にせず統合する機構を開発する。
- 画像分類・物体検出・セマンティックセグメンテーション・画像生成の広範な適用性を示す。
- 既存アーキテクチャへのプラグイン設計を提供し、効率と性能を分析する。
提案手法
- エージェントトークンAを導入し、Q, A, K, Vの四元を定義してK,Vから集約しQにブロードキャストする。
- 2つのSoftmax注意を介して一般化線形注意形式に理論的に同値であることを示す:O^A = Attn^S(Q, A, Attn^S(A, K, V))。
- エージェントトークンAをプーリングまたは学習可能なパラメータで取得し、エージェントトークンの数nで線形計算量O(Nnd)を用いる。
- 位置情報を注入するエージェントバイアスと特徴の多様性を保持するための多様性回復モジュール(深さ方向畳み込み)を強化する。
- 純粋なエージェント注意、エージェントバイアス、DWCを組み合わせたAgent Attention Moduleを提示:O = σ(QA^T + B2) σ(AK^T + B1) V + DWC(V)。
- DeiT、PVT、Swin、CSwin、Stable Diffusionへのプラグアンドプレイ統合を実証し、アブレーションと高解像度実験を行う。
実験結果
リサーチクエスチョン
- RQ1エージェントトークンは線形の計算量でグローバルな文脈モデリングを可能にするのか?
- RQ2エージェントトークンを介してSoftmaxと線形注意を統合すると、視覚タスク(分類、検出、セグメンテーション、生成)の性能にどのような影響を与えるのか?
- RQ3設計選択(エージェントバイアス、エージェントトークンの数/種類、エージェント注意を適用する場所)は精度と効率を最適化する上でどうなるのか?
- RQ4高解像度および大受容野設定、 Stable Diffusion のような拡散モデルを含むエージェント注意は有益か?
- RQ5既存の線形注意法と比較して、さまざまなアーキテクチャでエージェント注意はどのような利点を持つのか?
主な発見
- Agent Attentionは複数のアーキテクチャ(例: Agent-PVT, Swin)においてSoftmax注意ベースラインより高い精度を達成し、FLOPsを削減または同等に抑える。
- Agent-PVTの派生は同等のPVTモデルよりパラメータとFLOPsを少なくして上回る(例:Agent-PVT-S vs PVT-S、+2. ? 出典参照)で、Agent-Swin-T/SはSwin-T/Sと同等のFLOPsで上回る。
- 物体検出とセグメンテーションで、AgentバリエーションはベースラインよりAPとmIoUを一貫して改善(例:Agent-PVTとAgent-SwinはCOCOとADE20Kで顕著な向上を示す)。
- エージェント注意は高解像度での性能を大幅に向上させる。エージェント注意による受容野の拡大は計算を増やさず精度を高める。
- Stable Diffusionへの適用では、Agent Attentionは生成を1.7x–2.1x高速化し、追加のトレーニングなしで画像品質を向上させる。初期の拡散ステップでエージェントトークンを使用すると顕著な効果が得られる。
この論文を読む
Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。
Nubintでこの論文を読むこのレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。