Q-Adapter: Customizing Pre-trained LLMs to New Preferences with Forgetting Mitigation

📄 arXiv: 2407.03856v4 📥 PDF

作者: Yi-Chen Li, Fuxiang Zhang, Wenjie Qiu, Lei Yuan, Chengxing Jia, Zongzhang Zhang, Yang Yu, Bo An

分类: cs.LG

发布日期: 2024-07-04 (更新: 2025-03-03)

备注: Camera ready version of ICLR 2025

🔗 代码/项目: GITHUB


💡 一句话要点

提出Q-Adapter以解决LLM定制化与遗忘问题

🎯 匹配领域: 支柱二:RL算法与架构 (RL & Architecture) 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大型语言模型 定制化 强化学习 Q学习 人类偏好 适配器模块 知识保留

📋 核心要点

  1. 现有的开源大型语言模型在特定场景下应用时,往往无法满足用户的个性化需求,且缺乏有效的定制方法。
  2. 本文提出Q-Adapter,通过引入适配器模块,优化预训练LLM以适应新的人工偏好,同时保留其原有能力。
  3. 基于Llama-3.1模型的实验结果显示,Q-Adapter在保留知识和学习新偏好方面均表现出显著的效果提升。

📝 摘要(中文)

大型语言模型(LLMs)在大量语料库上训练后展现出卓越的能力。然而,直接应用开源LLMs(如Llama)于特定现实场景时,往往无法满足需求。因此,定制公开可用的LLMs的需求应运而生,但相关研究仍显不足。本文考虑在保留原有能力的同时,定制预训练LLMs以适应新的人工偏好。我们提出将LLM定制视为优化两个奖励函数的和,其中一个用于预训练,另一个则表征新的人工偏好。由于这两个奖励函数均未知,现代强化学习方法难以应用。借助残差Q学习框架,我们能够在不依赖于奖励函数的情况下,恢复定制后的LLM。实验结果表明,Q-Adapter在保留现有知识的同时,能够有效学习新的偏好。

🔬 方法详解

问题定义:本文旨在解决如何在不丢失原有能力的情况下,定制预训练的LLM以适应新的人工偏好。现有方法面临的主要挑战是奖励函数未知,使得强化学习方法难以应用。

核心思路:我们提出将LLM定制视为优化两个奖励函数的和,其中一个奖励函数用于预训练,另一个用于表征新的人工偏好。通过残差Q学习框架,我们能够在不依赖于第一个奖励函数的情况下,进行定制。

技术框架:整体架构包括预训练LLM、残差Q函数和适配器模块。适配器模块用于近似残差Q函数,从而实现对新偏好的学习。

关键创新:Q-Adapter的核心创新在于引入适配器模块来近似残差Q函数,使得定制过程不再依赖于已知的奖励函数,突破了传统方法的限制。

关键设计:在技术细节上,Q-Adapter通过Bradley-Terry模型从新的人类偏好数据中直接学习残差Q函数,确保了定制过程的有效性和灵活性。具体的损失函数和网络结构设计也经过精心调整,以优化学习效果。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果表明,Q-Adapter在Llama-3.1模型上相较于基线方法在保留知识和学习新偏好方面均有显著提升,具体性能数据未详细列出,但实验表明其有效性和优越性。

🎯 应用场景

该研究的潜在应用领域包括个性化对话系统、推荐系统以及其他需要根据用户偏好进行动态调整的自然语言处理任务。通过有效地定制LLM,能够提升用户体验,满足多样化的需求,具有重要的实际价值和未来影响。

📄 摘要(原文)

Large Language Models (LLMs), trained on a large amount of corpus, have demonstrated remarkable abilities. However, it may not be sufficient to directly apply open-source LLMs like Llama to certain real-world scenarios, since most of them are trained for \emph{general} purposes. Thus, the demands for customizing publicly available LLMs emerge, but are currently under-studied. In this work, we consider customizing pre-trained LLMs with new human preferences. Specifically, the LLM should not only meet the new preference but also preserve its original capabilities after customization. Drawing inspiration from the observation that human preference can be expressed as a reward model, we propose to cast LLM customization as optimizing the sum of two reward functions, one of which (denoted as $r_1$) was used to pre-train the LLM while the other (denoted as $r_2$) characterizes the new human preference. The obstacle here is that both reward functions are unknown, making the application of modern reinforcement learning methods infeasible. Thanks to the residual Q-learning framework, we can restore the customized LLM with the pre-trained LLM and the \emph{residual Q-function} without the reward function $r_1$. Moreover, we find that for a fixed pre-trained LLM, the reward function $r_2$ can be derived from the residual Q-function, enabling us to directly learn the residual Q-function from the new human preference data upon the Bradley-Terry model. We name our method Q-Adapter as it introduces an adapter module to approximate the residual Q-function for customizing the pre-trained LLM towards the new preference. Experiments based on the Llama-3.1 model on the DSP dataset and HH-RLHF dataset illustrate the superior effectiveness of Q-Adapter on both retaining existing knowledge and learning new preferences. Code is available at https://github.com/mansicer/Q-Adapter.