Skip to main content
QUICK REVIEW

[논문 리뷰] Agent Attention: On the Integration of Softmax and Linear Attention

Dongchen Han, Tianzhu Ye|arXiv (Cornell University)|2023. 12. 14.
Advanced Neural Network ApplicationsComputer Science인용 수 20
한 줄 요약

에이전트 어텐션(Agent Attention)을 도입하는 새로운 어텐션 패러다임으로, 에이전트 토큰을 사용해 글로벌 정보를 집계·전 방송하고 Softmax와 선형 어텐션을 효과적으로 통합하여 선형 복잡도에서 높은 표현력을 달성한다.

ABSTRACT

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와 선형 어텐션을 글로벌 컨텍스트 모델링의 손실 없이 통합하는 메커니즘을 개발한다.
  • 이미지 분류, 물체 검출, 의미 분할, 이미지 생성을 넘어 광범위한 적용 가능성을 입증한다.
  • 기존 아키텍처를 위한 플러그인 디자인을 제공하고 효율성과 성능의 trade-off를 분석한다.

제안 방법

  • 에이전트 토큰 A를 도입하여 Q, A, K, V의 사중으로 정의하고 K,V로부터 집계하여 Q로 방송하는 에이전트 어텐션을 정의한다.
  • 두 Softmax 어텐션을 통한 일반화된 선형 어텐션 형태에 대한 이론적 등가성: O^A = Attn^S(Q, A, Attn^S(A, K, V)).
  • 에이전트 토큰 A를 풀링 또는 학습 가능한 매개변수로 얻고, 에이전트 토큰 수 n으로 선형 복잡도 O(Nnd)을 사용한다.
  • 위치 정보를 주입하기 위한 에이전트 바이어스와 특징 다양성을 보존하기 위한 다양성 회복 모듈(Diversity Restoration Module, 깊이별 합성곱)로 보강한다.
  • 순수 에이전트 어텐션, 에이전트 바이어스, DWC를 결합한 에이전트 어텐션 모듈: 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-PVT, Swin)에서 Softmax 어텐션 베이스라인 대비 FLOPs를 줄이거나 비슷한 수준으로 유지하면서 상당한 정확도 향상을 달성한다.
  • 에이전트-PVT 변형은 대응하는 PVT 모델보다 매개변수 및 FLOPs가 적은 상태에서 더 나은 성능을 보이며(예: Agent-PVT-S 대 PVT-S, +2. ? 원본 참조 필요), Agent-Swin-T/S는 Swin-T/S와 유사한 FLOPs에서 더 나은 성능을 보인다.
  • 물체 검출 및 분할에서 에이전트 변형은 기저선보다 AP 및 mIoU를 지속적으로 향상시키며(예: COCO 및 ADE20K에서 주목할 만한 증가), 안정적인 성능 향상을 보인다.
  • 에이전트 어텐션은 고해상도에서 성능을 급격히 향상시키고, 에이전트 어텐션으로 수용 영역을 확장해도 계산은 증가하지 않는 경우가 많다.
  • Stable Diffusion에 적용 시 에이전트 어텐션은 생성 속도를 1.7배~2.1배 빠르게 하고 훈련 없이도 이미지 품질을 개선하며, 초기 확산 단계에서 에이전트 토큰을 사용하면 주목할 만한 이득이 나타난다.

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.