发现语言模型推理时存在未激活层,可跳过它们提升性能
Void in Language Models
- 用L2范数监测激活变化,无须训练识别未激活层
- 跳过30%层后Qwen模型在MMLU上准确率提升至71.29
- 适合追求高效推理或模型优化的研究者
尽管基于Transformer的语言模型取得进展,但一个基本问题仍悬而未决:推理时是否所有层都激活?我们通过一种无需训练、无参数的自适应计算方法L2 Adaptive Computation(LAC)检测未激活层(称为Voids)。将LAC从原有效率目标转向追踪推理过程中的激活层。该方法监测激活的L2范数变化以识别空洞。我们在两个阶段分析指令微调模型的层激活情况:提示处理(PP),追踪输入提示中每个词元的激活层;响应生成(RG),追踪生成词元的激活层。结果表明,两阶段激活的层不同。在三个基准测试(MMLU、GPQA Diamond、BoolQ)上评估了来自Llama、Mistral和Qwen系列的三类指令微调模型。例如,在零样本设置下,跳过Qwen2.5-7B-Instruct的空洞层后,MMLU得分从69.24提升至71.29,仅使用30%层。同样,Mistral-7B-Instruct-v0.3在GPQA Diamond上,使用70%层时得分从13.88提升至18.36。结果表明,推理中并非所有层都同等贡献,选择性跳过大部分层可提升特定任务性能。
原文摘要 · Abstract (English)
Despite advances in transformer-based language models (LMs), a fundamental question remains largely unanswered: Are all layers activated during inference? We investigate this question by detecting unactivated layers (which we refer to as Voids) using a non-trainable and parameter-free adaptive computation method called L2 Adaptive Computation (LAC). We adapt LAC from its original efficiency-focused application to trace activated layers during inference. This method monitors changes in the L2-norm of activations to identify voids. We analyze layer activation in instruction-tuned LMs across two phases: Prompt Processing (PP), where we trace activated layers for each token in the input prompts, and Response Generation (RG), where we trace activated layers for each generated token. We further demonstrate that distinct layers are activated during these two phases. To show the effectiveness of our method, we evaluated three distinct instruction-tuned LMs from the Llama, Mistral, and Qwen families on three benchmarks: MMLU, GPQA Diamond, and BoolQ. For example, on MMLU with a zero-shot setting, skipping voids in Qwen2.5-7B-Instruct resulted in an improvement from 69.24 to 71.29 while the model uses only 30% of the layers. Similarly, Mistral-7B-Instruct-v0.3 on GPQA Diamond improved from 13.88 to 18.36 when using 70% of the layers during both the PP and RG phases. These results show that not all layers contribute equally during inference, and that selectively skipping most of them can improve the performance of models on certain tasks.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。