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

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

4 Jul 2024arXiv:2407.03856archive 2025-07-28

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

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₁) was used to pre-train the LLM while the other (denoted as r₂) 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₁. Moreover, we find that for a fixed pre-trained LLM, the reward function r₂ 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 \url{https://github.com/mansicer/Q-Adapter}.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2407.03856")

Code

Syntology Ran 13 of 14 code samples harvested from 2 repositories linked to this paper; 1 has no recorded run. Of those that ran: 4 ran · our draft was wrong; 9 ran with no contract checked.

By repository: official repository: 2 samples from 1 repository, 2 ran; found in paper text by Syntology: 12 samples from 1 repository, 11 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

mansicer/Q-Adapter officialmentioned in papermentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

14 samples harvested; 13 ran; 0 honoured the contract we drafted; 1 has no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

4ran · our draft was wrong
9ran
1unverified

Licence: 0 of the 14 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

hash_args mansicer/Q-Adapter/lm-evaluation-harness/lm_eval/api/model.py official repository ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · 20a7cc804eb22661 · report
qadapter_loss mansicer/Q-Adapter/utils/q_adapter.py official repository ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · ee04f1495c3243f8 · report
chat_template_preprocess LAMDA-RL/Q-Adapter/utils/datasets.py found in paper text by Syntology ran Apache-2.0 (permissive) · 087b6200b29a1f20 · report
collator LAMDA-RL/Q-Adapter/ppo_train.py found in paper text by Syntology ran · our draft was wrong Apache-2.0 (permissive) · fddcce152bc7d3bd · report
get_transformers_model LAMDA-RL/Q-Adapter/utils/models.py found in paper text by Syntology ran Apache-2.0 (permissive) · f7380188a0e8cdc9 · report
get_transformers_tokenizer LAMDA-RL/Q-Adapter/utils/models.py found in paper text by Syntology ran Apache-2.0 (permissive) · aa635e3b36eacb87 · report
init_transformers_model LAMDA-RL/Q-Adapter/utils/models.py found in paper text by Syntology ran Apache-2.0 (permissive) · c4491a6621f89556 · report
modify_forward LAMDA-RL/Q-Adapter/utils/q_adapter.py found in paper text by Syntology ran Apache-2.0 (permissive) · 11bfc577314806ff · report
modify_prepare_inputs_for_generation LAMDA-RL/Q-Adapter/utils/q_adapter.py found in paper text by Syntology ran Apache-2.0 (permissive) · 4efbafd90b8d3d01 · report
parse_eval_args LAMDA-RL/Q-Adapter/lm-evaluation-harness/lm_eval/__main__.py found in paper text by Syntology ran · our draft was wrong Apache-2.0 (permissive) · 400ea4f64ccce5ef · report
remove_duplicate_questions LAMDA-RL/Q-Adapter/make_replay_data.py found in paper text by Syntology ran Apache-2.0 (permissive) · 74f7be6e12369b9a · report
rm_preprocess LAMDA-RL/Q-Adapter/utils/datasets.py found in paper text by Syntology ran Apache-2.0 (permissive) · 0af64997b20207ec · report
tokenize LAMDA-RL/Q-Adapter/utils/datasets.py found in paper text by Syntology ran Apache-2.0 (permissive) · 6a216d37018e6479 · report
evaluate LAMDA-RL/Q-Adapter/make_replay_data.py found in paper text by Syntology unverified Apache-2.0 (permissive) · 06ed656b6c40d9ac · report

Tasks

Q-LearningReinforcement LearningSafety Alignmentreinforcement-learning

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AdapterLLaMAQ-Learning

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections