Self and Cross-Model Distillation for LLMs: Effective Methods for Refusal Pattern Alignment

Weisong SunarXiv 2024 · DOI

TL;DR

This paper tackles the critical security issue of Large Language Models (LLMs) generating harmful content when prompted with toxic inputs. The authors propose novel self-distillation and cross-model distillation techniques to align LLM refusal patterns, significantly improving their ability to reject harmful requests and reduce unsafe outputs.

What Problem Does This Paper Address?

Large Language Models (LLMs) like GPT, Claude, and LLaMa have become incredibly powerful, but their susceptibility to "toxic prompts" poses a significant security risk. These prompts are designed to elicit harmful, biased, or inappropriate content, potentially leading to misuse and societal harm. While techniques like Supervised Fine-Tuning (SFT) and Reinforcement Learning from Human Feedback (RLHF) aim to mitigate these risks, there's a need for a deeper understanding of how LLMs refuse toxic prompts and how to improve this refusal mechanism. Specifically, the paper investigates the characteristics of refusal patterns across different LLMs and explores methods to leverage these patterns for enhanced security.

Methods

The core of this paper lies in its proposed distillation-based alignment methods:

  • Self-Distillation: This technique involves fine-tuning an LLM using its own safe refusal responses. The process filters for safe responses (labeled 1 or 2), randomly selects a subset, and then modifies these responses by adding or replacing refusal prefixes to align with a target pattern. This aims to standardize the LLM's own refusal behavior.
  • Cross-Model Distillation: This method leverages a "teacher" LLM (in this case, Claude-3-opus, known for its strong refusal capabilities) to guide a "student" LLM. The student model is fine-tuned using input-response pairs where both models have provided safe responses. This allows the student model to learn the more effective refusal patterns of the teacher model.

Both methods utilize LoRA (Low-Rank Adaptation) for efficient fine-tuning.

Datasets

The authors constructed a benchmark of 510 toxic prompts categorized into six types: invalid prompts, unhealthy contents, unauthorized consultations, sensitive topics, confidential information, and illegal activities. This dataset was used to evaluate nine different LLMs.

Key Insights and Ideas

  • Uniformity is Security: The study reveals a strong correlation between uniform refusal patterns and higher LLM security. Claude-3, with its highly consistent refusal style, demonstrated superior security.
  • Refusal Patterns Matter: The specific phrases and structures LLMs use to refuse toxic prompts are not arbitrary; they can be standardized and improved.
  • Distillation as a Solution: Both self-distillation and cross-model distillation proved effective in enhancing LLM security by standardizing refusal patterns.
  • Open-Source vs. Closed-Source: Open-source models showed a higher tendency for hallucinations and less uniform refusal patterns compared to closed-source models.

Key Results

  • The study analyzed refusal patterns across nine LLMs, including GPT-3.5, GPT-4, GPT-40, Claude-3-opus, Vicuna-7B, Vicuna-13B, LLaMa-3-8B, LLaMa-3-8B-Instruct, and LLaMa-3-70B.
  • Claude-3-opus achieved the highest refusal rate at 94.51%.
  • Self-distillation and cross-model distillation significantly improved refusal rates for Vicuna-7B, Vicuna-13B, and LLaMa-3-8B-Instruct by approximately 5-8%.
  • Cross-model distillation, using Claude-3 as a teacher, brought the refusal rates of student models close to Claude-3's performance.
  • These methods also reduced unsafe content output.
  • The distillation methods did not significantly degrade the quality of LLM responses, with response lengths often maintained or even increased.

Limitations and Future Work

  • Dataset Size: The collected dataset of toxic prompts, while carefully curated, is relatively small due to strict filtering. The authors plan to expand this dataset in the future.
  • Automated Evaluation: While automated evaluation with GPT-40 was used, manual verification revealed some inaccuracies, though within an acceptable error range. Future work could explore more accurate and economical evaluation methods.
  • Multilingualism: The current research is primarily English-centric. The authors suggest expanding the work to multilingual LLMs, acknowledging the challenges in handling different languages and potential translation errors.
  • Bias: The authors acknowledge that the data may contain biased elements, which are used solely for safety evaluation. They emphasize rigorous review to ensure no significant harm is caused.

Summary updated

BibTeX
@misc{sun2024self,
  author = {Weisong Sun},
  title = {{Self and Cross-Model Distillation for LLMs: Effective Methods for Refusal Pattern Alignment}},
  year = {2024},
  eprint = {2406.11285},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.11285},
}
Figure