ChatPaper.aiChatPaper

Chirurgia del Modello: Modulazione del Comportamento dei LLM Tramite Semplice Modifica dei Parametri

Model Surgery: Modulating LLM's Behavior Via Simple Parameter Editing

July 11, 2024
Autori: Huanqian Wang, Yang Yue, Rui Lu, Jingxin Shi, Andrew Zhao, Shenzhi Wang, Shiji Song, Gao Huang
cs.AI

Abstract

I Large Language Model (LLM) hanno dimostrato un grande potenziale come assistenti generalisti, mostrando una potente comprensione dei compiti e capacità di problem solving. Per implementare gli LLM come assistenti AI, è cruciale che questi modelli mostrino tratti comportamentali desiderabili, come la non tossicità e la resilienza contro tentativi di jailbreak. I metodi attuali per la detossificazione o la prevenzione del jailbreaking di solito coinvolgono il Supervised Fine-Tuning (SFT) o il Reinforcement Learning from Human Feedback (RLHF), che richiedono il fine-tuning di miliardi di parametri attraverso la discesa del gradiente con un costo computazionale sostanziale. Inoltre, i modelli modificati tramite SFT e RLHF possono deviare dai modelli pre-addestrati, potenzialmente portando a un degrado delle capacità fondamentali degli LLM. In questo articolo, osserviamo che, sorprendentemente, modificare direttamente un piccolo sottoinsieme di parametri può modulare efficacemente comportamenti specifici degli LLM, come la detossificazione e la resistenza al jailbreaking. Nello specifico, per un comportamento che intendiamo evitare, utilizziamo un classificatore lineare, che chiamiamo sonda comportamentale, per classificare etichette comportamentali binarie all'interno dello spazio degli stati nascosti dell'LLM. Utilizzando questa sonda, introduciamo un algoritmo per identificare un sottoinsieme critico di parametri dell'LLM che influenzano significativamente questo comportamento mirato. Quindi modifichiamo direttamente questi parametri selezionati spostandoli verso la sonda comportamentale. Tale metodo di modifica diretta dei parametri richiede solo risorse computazionali a livello di inferenza. Gli esperimenti dimostrano che nel compito rappresentativo di detossificazione, il nostro approccio ottiene riduzioni fino al 90,0% della tossicità sul dataset RealToxicityPrompts e del 49,2% su ToxiGen, mantenendo le capacità generali dell'LLM in aree come il senso comune, il question answering e la matematica. Il nostro codice è disponibile all'indirizzo https://github.com/lucywang720/model-surgery.
English
Large Language Models (LLMs) have demonstrated great potential as generalist assistants, showcasing powerful task understanding and problem-solving capabilities. To deploy LLMs as AI assistants, it is crucial that these models exhibit desirable behavioral traits, such as non-toxicity and resilience against jailbreak attempts. Current methods for detoxification or preventing jailbreaking usually involve Supervised Fine-Tuning (SFT) or Reinforcement Learning from Human Feedback (RLHF), which requires finetuning billions of parameters through gradient descent with substantial computation cost. Furthermore, models modified through SFT and RLHF may deviate from the pretrained models, potentially leading to a degradation in foundational LLM capabilities. In this paper, we observe that surprisingly, directly editing a small subset of parameters can effectively modulate specific behaviors of LLMs, such as detoxification and resistance to jailbreaking. Specifically, for a behavior that we aim to avoid, we employ a linear classifier, which we term the behavior probe, to classify binary behavior labels within the hidden state space of the LLM. Using this probe, we introduce an algorithm to identify a critical subset of LLM parameters that significantly influence this targeted behavior. Then we directly edit these selected parameters by shifting them towards the behavior probe. Such a direct parameter editing method necessitates only inference-level computational resources. Experiments demonstrate that in the representative detoxification task, our approach achieves reductions of up to 90.0\% in toxicity on the RealToxicityPrompts dataset and 49.2\% on ToxiGen, while maintaining the LLM's general capabilities in areas such as common sense, question answering, and mathematics. Our code is available at https://github.com/lucywang720/model-surgery.
PDF214November 28, 2024