Token-Level Knowledge Unlearning for Large Language Model Security
摘要
In recent years, large-scale language models have sparked a new wave of research in the field of natural language processing. By pre-training on massive amounts of data, these models can now be seen as rich knowledge repositories, demonstrating remarkable capabilities in tasks such as question answering, reasoning, and complex text processing. Due to being trained on vast corpora like the internet, large language models can memorize extensive knowledge, which may include harmful information related to personal lives, identity privacy, and illegal activities. Although this harmful knowledge in the training data has been parameterized, it can often be triggered in specific contexts. The malicious exploitation of this triggered harmful content poses ethical and legal risks to developers and users of these models. Previous efforts to address toxicity issues in large language models have primarily focused on data preprocessing and differential privacy methods, which are constrained by the models' enormous parameter sizes and can incur significant costs. To mitigate this issue, this paper proposes a novel safety technique for enhancing the security of large language models based on machine unlearning. This approach involves editing sequences of tokens specific to toxic content to erase toxic information, thereby addressing toxicity in the output of large language models and transforming them into safer assistants. Experimental results indicate that our proposed method significantly reduces the adverse impact on inherent abilities while ensuring the effectiveness of erasing toxicity. Compared with previous methods that employ gradient ascent (GA) to remove toxicity, our approach is more targeted towards securing the output content of large language models. It effectively sidesteps non-toxic information, focusing solely on toxic information, aiming to preserve their inherent capabilities while efficiently protecting their security.