Not All Layers of LLMs Are Necessary During Inference
Proceedings of the Thirty-Fourth International Joint Conference on Artificial Intelligence. Main Track. Pages 5083-5091.
https://doi.org/10.24963/ijcai.2025/566
Keywords
- Natural Language Processing: NLP: Applications
- Natural Language Processing: NLP: Question answering
- Machine Learning: ML: Applications
Abstract
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.
@inproceedings{ijcai2025p566,
title = {Not All Layers of LLMs Are Necessary During Inference},
author = {Fan, Siqi and Jiang, Xin and Li, Xiang and Meng, Xuying and Han, Peng and Shang, Shuo and Sun, Aixin and Wang, Yequan},
booktitle = {Proceedings of the Thirty-Fourth International Joint Conference on
Artificial Intelligence, {IJCAI-25}},
publisher = {International Joint Conferences on Artificial Intelligence Organization},
editor = {James Kwok},
pages = {5083--5091},
year = {2025},
month = {8},
note = {Main Track},
doi = {10.24963/ijcai.2025/566},
url = {https://doi.org/10.24963/ijcai.2025/566},
}
TY - CPAPER TI - Not All Layers of LLMs Are Necessary During Inference AU - Fan, Siqi AU - Jiang, Xin AU - Li, Xiang AU - Meng, Xuying AU - Han, Peng AU - Shang, Shuo AU - Sun, Aixin AU - Wang, Yequan T2 - Proceedings of the Thirty-Fourth International Joint Conference on Artificial Intelligence, IJCAI-25 PB - International Joint Conferences on Artificial Intelligence Organization PY - 2025 SP - 5083 EP - 5091 DO - 10.24963/ijcai.2025/566 UR - https://doi.org/10.24963/ijcai.2025/566 ER -Copied
Machine-readable versions of this paper, for tools and AI agents: