Skip to main content
QUICK REVIEW

[Paper Review] MoGU: A Framework for Enhancing Safety of Open-Sourced LLMs While Preserving Their Usability

Yanrui Du, Sendong Zhao|arXiv (Cornell University)|May 23, 2024
Digital Rights Management and SecurityComputer Science3 citations
TL;DR

MoGU is a novel framework that enhances the safety of open-sourced LLMs without sacrificing usability by dynamically routing between two specialized LLM variants: a 'Glad Responder' for helpful, usable responses and an 'Unwilling Responder' for rejecting harmful instructions. The dynamic router assigns higher weights to the safe responder under malicious prompts and to the usable responder under benign prompts, achieving 0% jailbreak success on Llama2 and Vicuna while preserving low rejection rates on benign inputs.

ABSTRACT

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.

Motivation & Objective

  • To address the trade-off between safety and usability in open-sourced LLMs, where existing defense strategies often lead to rejection-oriented responses that degrade usability.
  • To develop a framework that maintains high-quality, helpful responses to benign instructions while robustly rejecting harmful or malicious queries.
  • To design a dynamic routing mechanism that adaptively balances contributions from two specialized LLM variants based on input type.
  • To evaluate the framework across multiple open-sourced LLMs (Llama2, Vicuna, Falcon, etc.) under red-team and jailbreak attack scenarios.
  • To quantitatively verify that the router effectively assigns appropriate weights to each variant, ensuring safety without compromising usability.

Proposed method

  • Transform the base LLM into two distinct variants using LoRA: the 'Glad Responder' (Glad resp) trained for helpful, non-rejecting responses, and the 'Unwilling Responder' (Unwill resp) trained to reject all inputs.
  • Introduce a dynamic router at each LoRA layer that learns to assign attention weights to the outputs of Glad resp and Unwill resp based on the input instruction.
  • Train the router using a loss function combining Contrastive Learning Loss (Loss CL) and L1 Norm constraint (L1 Norm) to encourage proper routing behavior and sparsity.
  • Use the router's weighted output as the final response, where high weight on Unwill resp ensures rejection for malicious inputs, and high weight on Glad resp ensures helpfulness for benign inputs.
  • Apply the framework to multiple open-sourced LLMs including Llama2 7B, Vicuna 7B, Falcon 7B, Dolphin 7B, and Baichuan2 7B, with fine-tuning on safety and usability objectives.
  • Evaluate performance using red-team attacks, jailbreak benchmarks (e.g., AdvBench, AutoDAN, GCG), and benign instruction benchmarks (e.g., Just-Eval).

Experimental results

Research questions

  • RQ1Can a dynamic routing mechanism effectively balance safety and usability in open-sourced LLMs without degrading response quality on benign instructions?
  • RQ2How does MoGU compare to existing defense strategies in resisting red-team and jailbreak attacks while maintaining high usability?
  • RQ3To what extent does the router’s weight assignment align with the intended behavior—favoring the safe responder for malicious inputs and the usable responder for benign inputs?
  • RQ4What is the impact of key components like Contrastive Learning Loss and L1 Norm constraint on the router’s performance?
  • RQ5How does the parameter overhead of MoGU scale across different LLM architectures, and can it be reduced without sacrificing defense performance?

Key findings

  • MoGU achieved 0.00% jailbreak success rate on Llama2 7B across all tested attack types, including AutoDAN and GCG, demonstrating robust defense performance.
  • On Vicuna 7B, MoGU maintained a 0.00% success rate on AdvBench and AutoDAN, with only 0.50% on Malicious and 4.00% on GCG, significantly outperforming baselines.
  • The framework preserved usability: rejection rates for benign instructions remained nearly identical to the base LLM, with no significant increase in rejection expressions.
  • Ablation studies showed that removing the L1 Norm constraint led to a 33.36% average jailbreak success rate on Vicuna, highlighting its critical role in maintaining routing stability.
  • The router effectively assigned higher weights to Unwill resp (mean w_unwill ≈ 0.8) during jailbreak attacks and to Glad resp (mean w_glad ≈ 0.8) during benign instructions, confirming correct routing behavior.
  • The total parameter increase was only 3.91% for Llama2 7B (32 layers), and reducing d_router still maintained comparable defense performance, indicating efficiency and scalability.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.