通过插入轻量层实现大模型动态推理,兼顾速度与精度。
Balcony: A Lightweight Approach to Dynamic Inference of Generative Language Models
- 冻结预训练模型,在关键节点插入可训练层
- 仅用0.2%数据训练,性能损失极小且提速显著
- 适合资源受限场景下的实时大模型部署
在实际应用中,大语言模型(LLMs)的部署常受计算和延迟约束。动态推理虽能根据资源预算调整模型行为,但现有方法多存在硬件效率低或性能下降问题。本文提出Balcony,一种基于深度的轻量级动态推理框架。通过冻结预训练的LLM,并在选定出口点插入额外的Transformer层,保持全模型性能的同时实现实时适应不同计算预算。这些新增层采用简单的自蒸馏损失进行训练,使子模型输出与全模型对齐。该方法所需训练令牌和可调参数极少,相比以往方法大幅降低计算成本。应用于LLaMA3-8B模型时,仅使用原始预训练数据的0.2%,即可实现极小性能损耗并获得显著加速。实验表明,Balcony在多个模型、不同规模及多种基准测试中,优于Flextron、Layerskip等先进压缩技术。
原文摘要 · Abstract (English)
Deploying large language models (LLMs) in real-world applications is often hindered by strict computational and latency constraints. While dynamic inference offers the flexibility to adjust model behavior based on varying resource budgets, existing methods are frequently limited by hardware inefficiencies or performance degradation. In this paper, we introduce Balcony, a simple yet highly effective framework for depth-based dynamic inference. By freezing the pretrained LLM and inserting additional transformer layers at selected exit points, Balcony maintains the full model's performance while enabling real-time adaptation to different computational budgets. These additional layers are trained using a straightforward self-distillation loss, aligning the sub-model outputs with those of the full model. This approach requires significantly fewer training tokens and tunable parameters, drastically reducing computational costs compared to prior methods. When applied to the LLaMA3-8B model, using only 0.2% of the original pretraining data, Balcony achieves minimal performance degradation while enabling significant speedups. Remarkably, we show that Balcony outperforms state-of-the-art methods such as Flextron and Layerskip as well as other leading compression techniques on multiple models and at various scales, across a variety of benchmarks.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。