Skip to main content
QUICK REVIEW

[論文レビュー] The Hedgehog & the Porcupine: Expressive Linear Attentions with Softmax Mimicry

M Zhang, K. Bhatia|arXiv (Cornell University)|Feb 6, 2024
Cognitive and developmental aspects of mathematical skillsMathematics被引用数 3
ひとこと要約

Hedgehogは、標準的なソフトマックス注意機構の低エントロピー性・スパイク状の注意重みおよびドット積の単調性を模倣する、学習可能な線形注意機構を提案する。トレーニング可能なMLPを用いて表現力豊かで効率的な注意パターンを生成する。訓練から再学習する設定および微調整設定において、標準Transformer性能の99%以上を達成し、125MパラメータのモデルでWikiText-103で16.7のパープレキシティというSOTAを樹立した。また、Llama-2 7Bモデルの高精度な線形変換を可能にし、標準的な注意機構と比較してROUGE-1スコアで28.1ポイント向上した。

ABSTRACT

Linear attentions have shown potential for improving Transformer efficiency, reducing attention's quadratic complexity to linear in sequence length. This holds exciting promise for (1) training linear Transformers from scratch, (2) "finetuned-conversion" of task-specific Transformers into linear versions that recover task performance, and (3) "pretrained-conversion" of Transformers such as large language models into linear versions finetunable on downstream tasks. However, linear attentions often underperform standard softmax attention in quality. To close this performance gap, we find prior linear attentions lack key properties of softmax attention tied to good performance: low-entropy (or "spiky") weights and dot-product monotonicity. We further observe surprisingly simple feature maps that retain these properties and match softmax performance, but are inefficient to compute in linear attention. We thus propose Hedgehog, a learnable linear attention that retains the spiky and monotonic properties of softmax attention while maintaining linear complexity. Hedgehog uses simple trainable MLPs to produce attention weights mimicking softmax attention. Experiments show Hedgehog recovers over 99% of standard Transformer quality in train-from-scratch and finetuned-conversion settings, outperforming prior linear attentions up to 6 perplexity points on WikiText-103 with causal GPTs, and up to 8.7 GLUE score points on finetuned bidirectional BERTs. Hedgehog also enables pretrained-conversion. Converting a pretrained GPT-2 into a linear attention variant achieves state-of-the-art 16.7 perplexity on WikiText-103 for 125M subquadratic decoder models. We finally turn a pretrained Llama-2 7B into a viable linear attention Llama. With low-rank adaptation, Hedgehog-Llama2 7B achieves 28.1 higher ROUGE-1 points over the base standard attention model, where prior linear attentions lead to 16.5 point drops.

研究の動機と目的

  • Transformerにおける線形注意機構と標準的なソフトマックス注意機構の間のパフォーマンスギャップを埋める。
  • ソフトマックス注意機構の成功の背後にある重要な性質(低エントロピー性・スパイク状の分布、ドット積の単調性)を同定し、それらが従来の線形手法に欠落している理由を特定する。
  • これらの性質を保持しつつ、線形計算量を維持する線形注意機構を設計する。
  • GPT-2 や Llama-2 などの事前学習モデルを、パフォーマンスの低下を伴わずに効率的な線形バージョンに高品質に変換できるようにする。
  • 訓練から再学習、微調整、事前学習モデル変換の各レジームで、最先端の結果を示す。

提案手法

  • Hedgehogは、クエリとキーのドット積を入力として、それを注意重みにマップする学習可能な多層パーセプトロン(MLP)を用いる。これにより、ソフトマックス注意機構の挙動を模倣する。
  • MLPは、低エントロピー(スパイク状の分布)の注意重みと、ドット積の値に単調に増加する重みを生成するように学習される。
  • このアプローチは、時間的・空間的計算量がO(ndd')の線形複雑度を維持しつつ、ソフトマックス注意機構のインダクティブバイアスを捉える。
  • 本手法は、3つのレジームに適用される:訓練から再学習、微調整による変換、大規模モデルの事前学習モデル変換。
  • 大規模モデルの変換には、効率的な微調整のための低ランク適応(LoRA)が用いられる。
  • 標準ベンチマーク(WikiText-103、GLUE、SAMSum)で評価され、注意重みのパターンに関するアブレーションおよび可視化研究も実施された。

実験結果

リサーチクエスチョン

  • RQ1なぜ、線形計算量を有するにもかかわらず、従来の線形注意機構は標準的なソフトマックス注意機構に劣るのか?
  • RQ2既存の線形手法に欠落している、ソフトマックス注意機構のどのインダクティブバイアスがパフォーマンスの低下に寄与しているのか?
  • RQ3学習可能な線形時間注意機構は、ソフトマックス注意機構のスパイク状・単調な注意パターンを回復できるか?
  • RQ4このような機構は、訓練・微調整・事前学習モデル変換の各レジームで、標準Transformerのパフォーマンスにどれほど近づくか、あるいはそれを上回れるか?
  • RQ5GPT-2 や Llama-2 などの大規模言語モデルにおいて、効率的な適応によって高品質な線形注意機構を達成できるか?

主な発見

  • Hedgehogは、訓練から再学習および微調整済みの変換設定の両方で、標準Transformer性能の99%以上を回復した。
  • WikiText-103では、125Mパラメータの因果的GPTモデルで16.7のパープレキシティを達成し、サブ2次関数的モデルの中でSOTAを樹立した。
  • 微調整済みのBERTモデルでは、Hedgehogは従来の線形注意手法と比較してGLUEスコアを最大8.7ポイント向上させた。
  • Llama-2 7Bでは、LoRAを用いたHedgehogは、標準的な注意機構モデルと比較してROUGE-1スコアで28.1ポイント向上した。一方、従来の線形手法では16.5ポイントのスコア低下が生じた。
  • 注意重みの可視化により、Hedgehogが低エントロピーでスパイク状の注意重みを生成し、ドット積の単調性を維持していることが確認された。これは、ソフトマックスの挙動を密接に模倣している。
  • 本手法により、顕著な精度損失を伴わず、大規模な事前学習モデルを効率的かつ高性能な線形バージョンに変換できるようになった。

この論文を読む

Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。

Nubintでこの論文を読む

このレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。