Skip to main content
QUICK REVIEW

[論文レビュー] SwiftFormer: Efficient Additive Attention for Transformer-based Real-time Mobile Vision Applications

Abdelrahman Shaker, Muhammad Maaz|arXiv (Cornell University)|Mar 27, 2023
Advanced Neural Network Applications被引用数 5
ひとこと要約

SwiftFormerは、自己注意機構における2次行列乗算を線形要素演算に置き換える効率的な加法的注意メカニズムを提案し、モバイルデバイス上で高精度・低遅延のビジョントランスフォーマを実現する。この手法は、iPhone 14で0.8 msの推論遅延でImageNet-1Kのトップ1精度78.5%を達成し、MobileViT-v2 や EfficientFormer を上回るスピードと精度を実現する。

ABSTRACT

Self-attention has become a defacto choice for capturing global context in various vision applications. However, its quadratic computational complexity with respect to image resolution limits its use in real-time applications, especially for deployment on resource-constrained mobile devices. Although hybrid approaches have been proposed to combine the advantages of convolutions and self-attention for a better speed-accuracy trade-off, the expensive matrix multiplication operations in self-attention remain a bottleneck. In this work, we introduce a novel efficient additive attention mechanism that effectively replaces the quadratic matrix multiplication operations with linear element-wise multiplications. Our design shows that the key-value interaction can be replaced with a linear layer without sacrificing any accuracy. Unlike previous state-of-the-art methods, our efficient formulation of self-attention enables its usage at all stages of the network. Using our proposed efficient additive attention, we build a series of models called "SwiftFormer" which achieves state-of-the-art performance in terms of both accuracy and mobile inference speed. Our small variant achieves 78.5% top-1 ImageNet-1K accuracy with only 0.8 ms latency on iPhone 14, which is more accurate and 2x faster compared to MobileViT-v2. Code: https://github.com/Amshaker/SwiftFormer

研究の動機と目的

  • ビジョントランスフォーマにおける自己注意の高い計算コスト、特にモバイルデバイス上での課題に対処すること。
  • 自己注意における高価な行列乗算を削除しながら、精度を維持または向上させること。
  • 自己注意を、後段の低解像度ステージに限定せず、ビジョントランスフォーマのバックボーンのすべての段階に適用できること。
  • リアルタイムモバイルビジョンアプリケーションにおける優れたスピード-精度トレードオフを達成すること。
  • リソース制約のあるデバイス向けに多様なビジョンタスクに適した汎用的で効率的なバックボーンモデルを開発すること。

提案手法

  • クエリ-キー-バリューの行列乗算を線形要素演算に置き換える効率的な加法的注意メカニズムを導入すること。
  • 自己注意をクエリ-キー相互作用と学習可能な線形投影に分解し、明示的なキー-バリュー相互作用を排除すること。
  • 要素演算による乗算のみを用いてクエリとキーの特徴からコンテキストベクトルを計算することで、計算複雑度を線形時間に低減すること。
  • 軽量で、トランスフォーマのすべての段階と互換性がある注意ブロックを設計し、ネットワーク全体にわたりグローバルコンテキストモデリングを可能にすること。
  • 提案された効率的注意ブロックをスタックして構築する、SwiftFormerと呼ばれるモデルファミリーを構築し、モバイル推論を最適化すること。
  • 分類、検出、セグメンテーションタスクのパフォーマンスを検証するため、ImageNet-1K、COCO、ADE20Kベンチマークでモデルを訓練および評価すること。
Figure 1 : Latency vs Accuracy Comparison . Compared to the recent EfficientFormer-L1 [ 20 ] , our SwiftFormer-L1 achieves an absolute gain of 1.7% in terms of top-1 accuracy with the same latency and without requiring any neural architecture search.
Figure 1 : Latency vs Accuracy Comparison . Compared to the recent EfficientFormer-L1 [ 20 ] , our SwiftFormer-L1 achieves an absolute gain of 1.7% in terms of top-1 accuracy with the same latency and without requiring any neural architecture search.

実験結果

リサーチクエスチョン

  • RQ1自己注意を、精度を損なわずにモバイルデバイス上でリアルタイムにデプロイできるほど効率化できるか?
  • RQ2自己注意の2次計算量を、グローバルコンテキストモデリングを維持したまま線形に低減できるか?
  • RQ3効率的注意を、後段の低解像度ステージに限定せず、ビジョントランスフォーマのすべての段階に適用できるか?
  • RQ4自己注意において行列乗算を要素演算に置き換えることで、モバイルハードウェア上でより優れたスピード-精度トレードオフが達成できるか?
  • RQ5最適化されたモバイル用トランスフォーマバックボーンは、MobileViT-v2 や EfficientFormer といった既存のSOTAモデルを、精度と遅延の両面で上回れるか?

主な発見

  • SwiftFormer-L1は、iPhone 14で0.8 msの遅延でImageNet-1Kで78.5%のトップ1精度を達成し、スピードと精度の両面でMobileViT-v2を上回った。
  • 小さなSwiftFormerモデルは、MobileViT-v2より2倍速く、0.5%高い精度を達成しており、MobileViT-v2 ×2.0 よりも3倍速く、1.8%の精度向上を達成した。
  • SwiftFormer-L3は、iPhone 14で1.9 msの遅延で83.0%のトップ1精度を達成し、モバイルビジョンモデルにおける新しいSOTAを樹立した。
  • COCOオブジェクト検出では、SwiftFormer-L1が41.2 APボックスを達成し、EfficientFormer-L1 より3.3ポイント高く、ResNet18 より7.2ポイント高い。
  • インスタンスセグメンテーションでは、SwiftFormer-L1が38.1 APマスクを達成し、前回SOTAより2.7ポイント高い。
  • ADE20Kセマンティックセグメンテーションでは、SwiftFormer-L1が41.4%のmIoUを達成し、EfficientFormer-L1 より2.5ポイント高く、ResNet18 より8.5ポイント高い。
Figure 2 : Comparison with different self-attention modules . (a) is a typical self-attention used in ViTs [ 9 ] . (b) is the transpose self-attention used in EdgeNeXt [ 29 ] , where the self-attention operation is applied across channel feature dimensions (d $\times$ d) instead of the spatial dimen
Figure 2 : Comparison with different self-attention modules . (a) is a typical self-attention used in ViTs [ 9 ] . (b) is the transpose self-attention used in EdgeNeXt [ 29 ] , where the self-attention operation is applied across channel feature dimensions (d $\times$ d) instead of the spatial dimen

より良い研究を、今すぐ始めましょう

論文の読解から最終レビューまで、研究時間を劇的に削減しましょう。

クレジットカード登録不要

このレビューはAIが作成し、人間の編集者が確認しました。