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

Georgy Tyukin,Gbetondji J-S Dovonon,Jean Kaddour,Pasquale Minervini
2024-07-22
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.
Machine Learning,Computation and Language
What problem does this paper attempt to address?
The paper primarily focuses on addressing the efficiency issues of large language models (LLMs) during the inference process. Specifically: 1. **Inference Demand Growth and Latency Challenges**: Recently, the inference demand for large language models has increased sharply. However, due to the quadratic time complexity of the self-attention mechanism, providing low-latency service models remains challenging. 2. **Exploring the Effects of Layer Skipping**: Researchers investigated the impact of removing multi-layer perceptron (MLP) layers and attention layers on the performance of the Llama-v2 model during inference. 3. **Experimental Findings**: Removing deep attention layers only slightly affects performance but significantly improves inference speed. For example, removing 33% of the attention layers in the 13B Llama2 model results in an average performance drop of 1.8%, while bringing an 18% speed improvement. Through these studies, the paper aims to provide new ideas and technical solutions to improve the inference efficiency of large language models.