title: What Matters in Transformers? Not All Attention is Needed
summary: 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.
paper_authors._id: 670f43065651052491a76639
paper_authors.name: Shwai He
paper_authors._id: 670f43065651052491a7663a
paper_authors.name: Guoheng Sun
paper_authors._id: 670f43065651052491a7663b
paper_authors.name: Zheyu Shen
paper_authors._id: 670f43065651052491a7663c
paper_authors.name: Ang Li
paper_authors.status: claimed_verified
paper_authors.statusLastChangedAt: 2024-10-16T09:43:27.779Z
paper_authors._id: 64a842b1221e6292c9fa7a45
paper_authors.avatarUrl: /avatars/7f67f357c830ed6dade7ed7548ac1f05.svg
paper_authors.fullname: Ang Li
paper_authors.type: user
paper_authors.user: charleslipku
paper_title: What Matters in Transformers? Not All Attention is Needed
paper_summary: 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.
paper_ai_summary: Investigation reveals significant redundancy in Transformer layers, including Attention and MLP, which can be pruned to enhance speed without substantial performance loss.
paper_ai_keywords: Transformer-based large language models LLMs redundancy efficiency challenges similarity-based metric Blocks Attention layers MLP pruning model checkpoints MMLU task