arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2503.23798cs.CLcs.AI
收藏

预训练大语言模型中的自适应层跳过

Adaptive Layer-skipping in Pre-trained LLMs

Department of Computer Science, UC Santa Barbara(计算机科学系,UC Santa Barbara)

Xuan Luo, Weizhi Wang, Xifeng Yan

AI总结:

本文提出FlexiDepth方法,通过即插即用的路由器与适配器动态调整Transformer层数,在Llama-3-8B上跳过8/32层保持性能,揭示不同令牌计算需求差异,并开源代码与数据集以推动实用加速。

摘要:

已有多种层跳过方法被提出以加速大语言模型(LLMs)中的令牌生成。然而,一个基本问题却很少受到关注:不同令牌的生成过程中,计算需求是如何变化的?在本工作中,我们引入了FlexiDepth,一种在文本生成中动态调整所使用的Transformer层数的方法。通过集成一个即插即用的路由器(router)和适配器(adapter),FlexiDepth能够在不修改原始参数的情况下实现LLMs中的自适应计算。应用于Llama-3-8B时,它跳过了32层中的8层,同时保持了完整的基准性能。我们的实验揭示,LLMs中的计算需求因令牌类型不同而有显著差异。具体而言,生成重复性令牌或固定短语所需的层数较少,而生成涉及计算或高不确定性的令牌则需要更多层数。尽管节省了计算量,但由于跳过模式多变和I/O开销,FlexiDepth尚未实现墙钟时间上的加速。为了启发未来工作并推动实用加速研究,我们开源了FlexiDepth及其层分配模式数据集。

英文摘要:

Various layer-skipping methods have been proposed to accelerate token generation in large language models (LLMs). However, limited attention has been paid to a fundamental question: How do computational demands vary across the generation of different tokens? In this work, we introduce FlexiDepth, a method that dynamically adjusts the number of Transformer layers used in text generation. By incorporating a plug-in router and adapter, FlexiDepth enables adaptive computation in LLMs without modifying their original parameters. Applied to Llama-3-8B, it skips 8 out of 32 layers while maintaining full benchmark performance. Our experiments reveal that computational demands in LLMs significantly vary based on token type. Specifically, generating repetitive tokens or fixed phrases requires fewer layers, whereas producing tokens involving computation or high uncertainty requires more layers. Despite the computational savings, FlexiDepth does not yet achieve wall-clock speedup due to varied skipping patterns and I/O overhead. To inspire future work and advance research on practical speedup, we open-sourced FlexiDepth and a dataset documenting its layer allocation patterns.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑