トランスフォーマーにおいて重要なのは何か?全ての注意が必要とは限らない
What Matters in Transformers? Not All Attention is Needed
June 22, 2024
著者: Shwai He, Guoheng Sun, Zheyu Shen, Ang Li
cs.AI
要旨
Transformerベースの大規模言語モデル(LLM)のスケーリングは、さまざまなタスクで有望なパフォーマンスを示していますが、冗長なアーキテクチャを導入し、実世界での展開に効率の課題をもたらすこともあります。LLMの冗長性について一部認識されているものの、MLPやAttentionレイヤーなどのTransformers内の異なるアーキテクチャにおける冗長性の変動は未だに十分に探求されていません。本研究では、Transformer内の異なるモジュール(ブロック、MLP、Attentionレイヤーを含む)間の冗長性を、類似性に基づくメトリクスを用いて調査しました。驚くべきことに、他のアーキテクチャとの違いを明確にするためのAttentionレイヤーの重要な役割にも関わらず、これらのレイヤーの多くが過剰に類似しており、パフォーマンスを低下させることなく削減できることがわかりました。例えば、Llama-2-70Bは、Attentionレイヤーの半分を削減することで、パフォーマンスの低下わずか2.4\%で48.4\%の高速化を達成しました。さらに、トレーニングプロセス全体でモデルのチェックポイントを追跡することで、Attentionレイヤーの冗長性が固有であり、トレーニング段階を通じて一貫していることを観察しました。さらに、AttentionとMLPレイヤーを同時に削除する方法を提案し、追加のレイヤーをより積極的に削減できるようにしました。例えば、31層(Attention + MLP)を削除した場合、Llama-2-13BはMMLUタスクでパフォーマンスの90\%を維持します。本研究は、将来のネットワークアーキテクチャ設計に対する貴重な示唆を提供します。コードは以下から入手可能:https://github.com/Shwai-He/LLM-Drop.
English
While scaling Transformer-based large language models (LLMs) has demonstrated
promising performance across various tasks, it also introduces redundant
architectures, posing efficiency challenges for real-world deployment. Despite
some recognition of redundancy in LLMs, the variability of redundancy across
different architectures in transformers, such as MLP and Attention layers, is
under-explored. In this work, we investigate redundancy across different
modules within Transformers, including Blocks, MLP, and Attention layers, using
a similarity-based metric. Surprisingly, despite the critical role of attention
layers in distinguishing transformers from other architectures, we found that a
large portion of these layers exhibit excessively high similarity and can be
pruned without degrading performance. For instance, Llama-2-70B achieved a
48.4\% speedup with only a 2.4\% performance drop by pruning half of the
attention layers. Furthermore, by tracing model checkpoints throughout the
training process, we observed that attention layer redundancy is inherent and
consistent across training stages. Additionally, we further propose a method
that jointly drops Attention and MLP layers, allowing us to more aggressively
drop additional layers. For instance, when dropping 31 layers (Attention +
MLP), Llama-2-13B still retains 90\% of the performance on the MMLU task. Our
work provides valuable insights for future network architecture design. The
code is released at: https://github.com/Shwai-He/LLM-Drop.Summary
AI-Generated Summary