用对比解码让LoRA模型更懂专业任务,提速近三成。
Enhancing Learned Knowledge in LoRA Adapters Through Efficient Contrastive Decoding on Ascend NPUs
- 通过对比基模型与LoRA适配后模型的输出分布,筛选更契合任务的词元。
- 在多项任务上提升5.54%准确率,端到端延迟降低28%。
- 专为昇腾NPU优化,适合资源受限场景下的高效微调应用。
华为云用户使用低秩适配(LoRA)高效微调大语言模型以满足特定应用需求。然而,复杂推理或深层上下文理解任务常因基模型偏差或干扰,导致典型解码方法(如贪心或束搜索)产生通用化、任务无关的响应,未能有效利用LoRA所学知识。本文提出对比解码框架CoLD,通过比较LoRA适配专家模型与对应基模型的概率分布差异,评分候选词元,优先选择更符合LoRA学习表征的输出,从而提升专用任务性能。尽管有效,原始实现计算开销大,需在两模型中评估多个候选词元。为此,我们为华为昇腾NPU开发了优化内核。实验表明,CoLD相较贪心解码在任务准确率上最高提升5.54%,端到端延迟降低28%。该工作为资源受限环境中的微调大模型提供了实用高效的解码策略,对云与本地部署的数据科学应用具有广泛意义。
原文摘要 · Abstract (English)
Huawei Cloud users leverage LoRA (Low-Rank Adaptation) as an efficient and scalable method to fine-tune and customize large language models (LLMs) for application-specific needs. However, tasks that require complex reasoning or deep contextual understanding are often hindered by biases or interference from the base model when using typical decoding methods like greedy or beam search. These biases can lead to generic or task-agnostic responses from the base model instead of leveraging the LoRA-specific adaptations. In this paper, we introduce Contrastive LoRA Decoding (CoLD), a novel decoding framework designed to maximize the use of task-specific knowledge in LoRA-adapted models, resulting in better downstream performance. CoLD uses contrastive decoding by scoring candidate tokens based on the divergence between the probability distributions of a LoRA-adapted expert model and the corresponding base model. This approach prioritizes tokens that better align with the LoRA's learned representations, enhancing performance for specialized tasks. While effective, a naive implementation of CoLD is computationally expensive because each decoding step requires evaluating multiple token candidates across both models. To address this, we developed an optimized kernel for Huawei's Ascend NPU. CoLD achieves up to a 5.54% increase in task accuracy while reducing end-to-end latency by 28% compared to greedy decoding. This work provides practical and efficient decoding strategies for fine-tuned LLMs in resource-constrained environments and has broad implications for applied data science in both cloud and on-premises settings.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。