Large Language Models (LLMs) are increasingly deployed in various applications. As their usage grows, concerns regarding their safety are rising, especially in maintaining harmless responses when faced with malicious instructions. Many defense strategies have been developed to enhance the safety of LLMs. However, our research finds that existing defense strategies lead LLMs to predominantly adopt a rejection-oriented stance, thereby diminishing the usability of their responses to benign instructions. To solve this problem, we introduce the MoGU framework, designed to enhance LLMs' safety while preserving their usability. Our MoGU framework transforms the base LLM into two variants: the usable LLM and the safe LLM, and further employs dynamic routing to balance their contribution. When encountering malicious instructions, the router will assign a higher weight to the safe LLM to ensure that responses are harmless. Conversely, for benign instructions, the router prioritizes the usable LLM, facilitating usable and helpful responses. On various open-sourced LLMs, we compare multiple defense strategies to verify the superiority of our MoGU framework. Besides, our analysis provides key insights into the effectiveness of MoGU and verifies that our designed routing mechanism can effectively balance the contribution of each variant by assigning weights. Our work released the safer Llama2, Vicuna, Falcon, Dolphin, and Baichuan2.
翻译:大语言模型(LLMs)正日益广泛地部署于各类应用中。随着其使用量的增长,对其安全性的担忧也在加剧,尤其是在面对恶意指令时保持无害响应的能力。目前已有多种防御策略被开发出来以增强LLMs的安全性。然而,我们的研究发现,现有的防御策略导致LLMs主要采取一种拒绝导向的立场,从而削弱了其对良性指令响应的可用性。为解决此问题,我们提出了MoGU框架,旨在增强LLMs安全性的同时保持其可用性。我们的MoGU框架将基础LLM转化为两个变体:可用LLM与安全LLM,并进一步采用动态路由来平衡二者的贡献。当遇到恶意指令时,路由器将赋予安全LLM更高的权重,以确保响应无害。反之,对于良性指令,路由器则优先考虑可用LLM,以促成可用且有益的响应。我们在多种开源LLMs上比较了多种防御策略,以验证MoGU框架的优越性。此外,我们的分析为MoGU的有效性提供了关键见解,并验证了我们设计的路由机制能够通过分配权重有效平衡各变体的贡献。我们的工作发布了更安全的Llama2、Vicuna、Falcon、Dolphin和Baichuan2模型。