Skip to main content
QUICK REVIEW

[Paper Review] Attention Is All You Need But You Don't Need All Of It For Inference of Large Language Models

Georgy Tyukin, Gbètondji J-S Dovonon|arXiv (Cornell University)|Jul 22, 2024
Topic ModelingComputer Science3 citations
TL;DR

This paper investigates pruning deeper layers in Llama-v2 models during inference to reduce latency, finding that skipping attention sublayers yields superior speedups with minimal performance loss—e.g., removing 33% of attention layers in a 13B model achieves 18% faster inference at just a 1.8% drop in average benchmark performance across ARC, HellaSwag, TruthfulQA, and MMLU.

ABSTRACT

The inference demand for LLMs has skyrocketed in recent months, and serving models with low latencies remains challenging due to the quadratic input length complexity of the attention layers. In this work, we investigate the effect of dropping MLP and attention layers at inference time on the performance of Llama-v2 models. We find that dropping dreeper attention layers only marginally decreases performance but leads to the best speedups alongside dropping entire layers. For example, removing 33\% of attention layers in a 13B Llama2 model results in a 1.8\% drop in average performance over the OpenLLM benchmark. We also observe that skipping layers except the latter layers reduces performances for more layers skipped, except for skipping the attention layers.

Motivation & Objective

  • To reduce inference latency in large language models (LLMs) by skipping layers during inference without significant performance degradation.
  • To investigate whether deeper layers in Llama-v2 models are redundant and can be safely removed during inference.
  • To compare the impact of skipping attention sublayers, MLP sublayers, or entire transformer blocks on model performance and inference speed.
  • To evaluate the trade-off between computational efficiency and accuracy when pruning deeper layers in 7B and 13B Llama-v2 models.

Proposed method

  • The authors create modified Llama-v2 models by skipping attention sublayers, MLP sublayers, or entire transformer blocks in the last k layers.
  • They evaluate these variants on the OpenLLM benchmark, measuring accuracy across ARC, HellaSwag, TruthfulQA, and MMLU.
  • Inference speed is measured by recording time to generate one token over 1000 sequences of length 50 and 100.
  • Cosine similarity between layer features and the previous layer is computed to assess redundancy in deeper layers.
  • The study compares models with and without the last layer preserved to evaluate its role in performance stability.
  • Experiments are conducted on both 7B and 13B Llama-v2 models across 66%, 75%, 90%, and 100% of layers retained.
Figure 1: Cosine similarity of Llama-v2 layers with the previous layer: We observe that the deeper the layer, the more its features are similar to the previous layer except for the very last layer.
Figure 1: Cosine similarity of Llama-v2 layers with the previous layer: We observe that the deeper the layer, the more its features are similar to the previous layer except for the very last layer.

Experimental results

Research questions

  • RQ1Does skipping deeper attention sublayers in Llama-v2 models lead to significant performance degradation?
  • RQ2How does skipping MLP sublayers compare to skipping attention sublayers in terms of performance and speedup?
  • RQ3What is the impact of preserving the last layer when skipping deeper layers?
  • RQ4Are deeper layers in Llama-v2 models more redundant than earlier layers, as indicated by feature similarity?
  • RQ5Can pruning attention layers achieve substantial speedups with minimal accuracy loss in large LLMs?

Key findings

  • Skipping 33% of attention layers in a 13B Llama-v2 model results in an 18% speedup with only a 1.8% drop in average performance across the OpenLLM benchmark.
  • Removing 33% of MLP sublayers leads to a 14% speedup but causes a 4.2% drop in average performance, indicating higher sensitivity to MLP pruning.
  • The last layer consistently shows the lowest cosine similarity to the previous layer, suggesting it is less redundant and should be preserved.
  • Skipping attention layers yields better speedups than skipping MLP layers, with attention sublayer skipping achieving 21.47% time reduction at 66% layer retention for 7B models.
  • Models that skip attention layers maintain strong performance on all benchmarks, with only marginal drops on MMLU and TruthfulQA.
  • The speedup is consistent across input lengths, with 100-length sequences showing similar relative improvements as 50-length sequences.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.