CLAILGMar 4, 2024

Not All Layers of LLMs Are Necessary During Inference

arXiv:2403.02181v397 citationsh-index: 62IJCAI
AI Analysis

This work addresses the resource-intensive inference phase of LLMs for users needing efficient deployment, but it is incremental as it builds on existing layer-skipping ideas with a new adaptive method.

The paper tackles the problem of high inference costs in Large Language Models (LLMs) by showing that not all layers are necessary for some tasks, and proposes AdaInfer, an algorithm that adaptively terminates inference early, achieving an average pruning ratio of 17.8% with less than 1% performance drop.

Due to the large number of parameters, the inference phase of Large Language Models (LLMs) is resource-intensive. However, not all requests posed to LLMs are equally difficult to handle. Through analysis, we show that for some tasks, LLMs can achieve results comparable to the final output at some intermediate layers. That is, not all layers of LLMs are necessary during inference. If we can predict at which layer the inferred results match the final results (produced by evaluating all layers), we could significantly reduce the inference cost. To this end, we propose a simple yet effective algorithm named AdaInfer to adaptively terminate the inference process for an input instance. AdaInfer relies on easily obtainable statistical features and classic classifiers like SVM. Experiments on well-known LLMs like the Llama2 series and OPT, show that AdaInfer can achieve an average of 17.8% pruning ratio, and up to 43% on sentiment tasks, with nearly no performance drop (<1%). Because AdaInfer does not alter LLM parameters, the LLMs incorporated with AdaInfer maintain generalizability across tasks.

Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes