Enhancing Learned Knowledge in LoRA Adapters Through Efficient Contrastive Decoding on Ascend NPUs

📄 arXiv: 2505.14620v1 📥 PDF

作者: Morgan Lindsay Heisler, Linzi Xing, Ge Shi, Hanieh Sadri, Gursimran Singh, Weiwei Zhang, Tao Ye, Ying Xiong, Yong Zhang, Zhenan Fan

分类: cs.LG, cs.CL

发布日期: 2025-05-20

备注: Accepted at ACM KDD 2025

DOI: 10.1145/3711896.3737215


💡 一句话要点

提出CoLD对比解码框架,提升LoRA适配模型在Ascend NPU上的推理性能。

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: LoRA 对比解码 大型语言模型 Ascend NPU 模型微调

📋 核心要点

  1. 现有解码方法在LoRA微调的LLM中,易受基础模型偏差影响,导致任务性能下降。
  2. CoLD通过对比LoRA适配模型和基础模型的概率分布,选择更符合LoRA学习表示的token。
  3. CoLD在Ascend NPU上优化实现,任务准确率提升高达5.54%,端到端延迟降低28%。

📝 摘要(中文)

华为云用户利用LoRA(低秩适应)作为一种高效且可扩展的方法,来微调和定制大型语言模型(LLM),以满足特定应用的需求。然而,当使用贪婪搜索或束搜索等典型解码方法时,需要复杂推理或深度上下文理解的任务常常受到基础模型的偏差或干扰的阻碍。这些偏差可能导致来自基础模型的通用或与任务无关的响应,而不是利用LoRA特定的适配。在本文中,我们介绍了一种新颖的解码框架——对比LoRA解码(CoLD),旨在最大限度地利用LoRA适配模型中的特定任务知识,从而获得更好的下游性能。CoLD通过基于LoRA适配的专家模型和相应的基础模型之间的概率分布差异来对候选token进行评分,从而使用对比解码。这种方法优先考虑更符合LoRA学习表示的token,从而提高专门任务的性能。虽然有效,但CoLD的简单实现计算成本很高,因为每个解码步骤都需要评估两个模型中的多个token候选。为了解决这个问题,我们为华为的Ascend NPU开发了一个优化的内核。与贪婪解码相比,CoLD实现了高达5.54%的任务准确率提升,同时将端到端延迟降低了28%。这项工作为资源受限环境中微调的LLM提供了实用且高效的解码策略,并且对云和本地环境中的应用数据科学具有广泛的影响。

🔬 方法详解

问题定义:论文旨在解决LoRA适配的大型语言模型在解码过程中,由于受到基础模型偏差的影响,无法充分利用LoRA学习到的特定任务知识,导致下游任务性能不佳的问题。现有方法,如贪婪搜索和束搜索,无法有效区分来自LoRA适配模型和基础模型的知识,容易产生泛化或与任务无关的响应。

核心思路:论文的核心思路是利用对比解码,通过比较LoRA适配模型和基础模型的概率分布,选择那些更符合LoRA学习表示的token。这种方法旨在放大LoRA适配模型中的特定任务知识,抑制基础模型的偏差,从而提高下游任务的性能。

技术框架:CoLD框架主要包含以下几个步骤:1) 使用LoRA适配模型和基础模型分别生成候选token的概率分布;2) 计算两个概率分布之间的差异,例如使用KL散度;3) 基于差异对候选token进行评分,选择评分最高的token;4) 将选定的token添加到已生成的序列中,并重复上述步骤直到生成完整的序列。

关键创新:CoLD的关键创新在于将对比解码应用于LoRA适配模型,并利用基础模型作为负样本,从而有效地提取和利用LoRA学习到的特定任务知识。此外,针对华为Ascend NPU的优化内核也是一个重要的创新,它显著提高了CoLD的计算效率。

关键设计:CoLD的关键设计包括:1) 选择合适的概率分布差异度量方法,例如KL散度或JS散度;2) 设计有效的评分函数,以平衡LoRA适配模型和基础模型的贡献;3) 针对Ascend NPU的硬件特性,优化计算内核,例如利用张量加速和并行计算。

🖼️ 关键图片

fig_0
fig_1

📊 实验亮点

实验结果表明,CoLD在任务准确率方面取得了显著提升,最高可达5.54%。同时,通过在华为Ascend NPU上进行优化,CoLD的端到端延迟降低了28%,与贪婪解码相比,在保证性能提升的同时,显著提高了推理效率。这些结果验证了CoLD在实际应用中的有效性和可行性。

🎯 应用场景

该研究成果可广泛应用于各种需要对大型语言模型进行高效定制和微调的场景,例如智能客服、文本摘要、代码生成等。通过CoLD,用户可以更好地利用LoRA适配模型中的特定任务知识,提高模型在特定领域的性能,并降低部署成本。该方法在云端和本地环境中均具有应用潜力,有助于推动人工智能技术在各行业的落地。

📄 摘要(原文)

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.