Cross-Task Defense: Instruction-Tuning LLMs for Content Safety

Yu Fu,Wen Xiao,Jia Chen,Jiachen Li,Evangelos Papalexakis,Aichi Chien,Yue Dong
2024-05-24
Abstract:Recent studies reveal that Large Language Models (LLMs) face challenges in balancing safety with utility, particularly when processing long texts for NLP tasks like summarization and translation. Despite defenses against malicious short questions, the ability of LLMs to safely handle dangerous long content, such as manuals teaching illicit activities, remains unclear. Our work aims to develop robust defenses for LLMs in processing malicious documents alongside benign NLP task queries. We introduce a defense dataset comprised of safety-related examples and propose single-task and mixed-task losses for instruction tuning. Our empirical results demonstrate that LLMs can significantly enhance their capacity to safely manage dangerous content with appropriate instruction tuning. Additionally, strengthening the defenses of tasks most susceptible to misuse is effective in protecting LLMs against processing harmful information. We also observe that trade-offs between utility and safety exist in defense strategies, where Llama2, utilizing our proposed approach, displays a significantly better balance compared to Llama1.
Computation and Language,Cryptography and Security
What problem does this paper attempt to address?
The paper primarily focuses on the security issues of large language models (LLMs) when handling malicious long texts. Specifically, the researchers found that while existing LLMs can defend against attacks from malicious short questions, they have security vulnerabilities when dealing with harmful long texts, such as illegal activity guides. For example, attackers might submit documents containing harmful information and request the model to perform natural language processing (NLP) tasks such as translation, summarization, or question answering. To address this issue, the paper makes the following contributions: 1. **Constructed a defense dataset**: This dataset includes examples related to security and refusals to answer, used to train LLMs to learn how to refuse to process malicious content. 2. **Proposed single-task and mixed-task loss functions**: By adjusting the loss functions, the model can identify and refuse to process harmful texts while performing NLP tasks. 3. **Conducted experimental validation**: Experiments were conducted to evaluate the impact of different numbers of defense examples on model performance and to compare the performance of two different LLMs (Llama1-7B and Llama2-7B). The research results indicate that appropriately tuning instructions can significantly improve the security of LLMs in handling dangerous content. Additionally, the study observed a trade-off between practicality and security, noting that Llama2-7B performs better than Llama1-7B in balancing these two aspects.