CLHA: A Simple Yet Effective Contrastive Learning Framework for Human Alignment

Feiteng Fang, Liang Zhu, Xi Feng, Jinchang Hou, Qixuan Zhao, Chengming Li, Xiping Hu, Ruifeng Xu, Min Yang

Abstract

Reinforcement learning from human feedback (RLHF) is a crucial technique in aligning large language models (LLMs) with human preferences, ensuring these LLMs behave in beneficial and comprehensible ways to users. However, a longstanding challenge in human alignment techniques based on reinforcement learning lies in their inherent complexity and difficulty in training. To address this challenge, we present a simple yet effective Contrastive Learning Framework for Human Alignment (CLHA) to align LLMs with human preferences directly. CLHA employs a novel rescoring strategy to evaluate the noise within the data by considering its inherent quality and dynamically adjusting the training process. Simultaneously, CLHA utilizes pairwise contrastive loss and adaptive supervised fine-tuning loss to adaptively modify the likelihood of generating responses, ensuring enhanced alignment with human preferences. Using advanced methods, CLHA surpasses other algorithms, showcasing superior performance in terms of reward model scores, automatic evaluations, and human assessments on the widely used “Helpful and Harmless” dataset.

Introduction

Aligning Large Language Models (LLMs) with human values is often considered the "last mile" of AI development. While Reinforcement Learning from Human Feedback (RLHF) via Proximal Policy Optimization (PPO) is the industry standard, it is notoriously difficult to implement, sensitive to hyperparameters, and computationally expensive. RLHF requires maintaining multiple models in memory (policy, value, reference, and reward models) and tuning the finicky PPO algorithm.

Recent alternatives have attempted to simplify this by treating alignment as a ranking task. However, these methods face two major hurdles:

  1. Noisy Data: Human annotators are imperfect. Sometimes the "chosen" response is actually worse than the "rejected" one. Standard methods blindly follow these labels, leading the model astray.
  2. Preference Overfitting: If a model tries too hard to maximize the "gap" between a good and bad answer, it can lose its ability to speak fluently or naturally—a phenomenon where the model prioritizes the "reward" over linguistic quality.

The CLHA Framework

CLHA (Contrastive Learning for Human Alignment) offers a streamlined alternative that replaces complex reinforcement learning with a contrastive learning approach.

The CLHA framework architecture, illustrating Reward Rescoring, Pairwise Contrastive Learning, and Adaptive SFT.

The framework consists of three core components:

  • Reward Rescoring: Instead of trusting binary "chosen vs. rejected" labels, CLHA uses an off-the-shelf Reward Model (RM) to assign a scalar score to every response. If a human-chosen answer has a lower RM score than the rejected one, it's identified as "noisy" and handled accordingly.
  • Pairwise Contrastive Loss ($L_{clha}$): CLHA introduces a dynamic margin ($\xi_{adjust}$) that scales based on the difference in quality between responses. This prevents the model from "over-optimizing" on pairs that are already well-separated or too similar. It also calculates contrastive loss between different negative samples to better utilize the information in the data.
  • Adaptive Supervised Fine-tuning (SFT): Standard SFT trains on all "chosen" data. CLHA uses a gate ($\lambda$) that only allows SFT training on chosen samples that have a positive reward score, ensuring the model only mimics truly high-quality behavior.

Experimental Results

The researchers evaluated CLHA on the HH-RLHF (Helpful and Harmless) dataset from Anthropic. To push the limits further, they created HH-RLHF3, an augmented version featuring high-quality responses generated by GPT-3.5-turbo.

Main experimental results comparing CLHA against various baselines across different subsets of the HH-RLHF dataset.

CLHA consistently outperformed baselines across multiple metrics:

  • Reward Scores: On the total HH-RLHF dataset, CLHA achieved a reward score of 68.30, surpassing PRO (67.97) and RLHF/PPO (58.65).
  • Fluency: CLHA maintained higher BLEU scores than many competitors, suggesting it aligns with human values without compromising the model's linguistic quality.
  • Human Evaluation: In head-to-head assessments, humans preferred CLHA responses over PRO responses significantly more often across all categories.
  • Ablation Study: Removing the "Rescoring" strategy caused the reward score to drop from 57.72 to 55.48, proving that filtering noisy data is critical.

Discussion and Limitations

CLHA demonstrates that human preference data is inherently messy and that using a Reward Model as a "sanity check" can significantly boost performance. By making the margin proportional to the quality difference, CLHA maintains better text fluency.

However, some limitations remain:

  • Reward Model Dependency: CLHA's effectiveness is tied to the quality of the "off-the-shelf" reward model used for rescoring.
  • Generation Overhead: During training, the framework requires generating multiple responses per prompt to form contrastive pairs.
  • Scaling: The study focused on 7B parameter models (LLaMA-7B); future work should explore how these contrastive margins behave at larger scales (70B+).

Paper Link: CLHA: A Simple yet Effective Contrastive Learning Framework for Human Alignment

Summary updated

BibTeX
@inproceedings{fang2024clha,
  author = {Feiteng Fang and Liang Zhu and Xi Feng and Jinchang Hou and Qixuan Zhao and Chengming Li and Xiping Hu and Ruifeng Xu and Min Yang},
  title = {{CLHA: A Simple Yet Effective Contrastive Learning Framework for Human Alignment}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2024},
  url = {https://openreview.net/forum?id=YvAeiAgcIc},
}
Figure