Harmony-λ: Alpaca-7B, Safe RLHF
PKU-Alignment/alpaca-7b-reproduced after 100 iterations
of Safe RLHF with Harmony-λ (Harmony with a safety target: at least 90% of the training rollouts have cost ≤ 0), from
Harmony without Uniformity: Towards Weight-Free Multi-Reward Reinforcement Learning
(project page, code).
- Training rewards: helpfulness from
PKU-Alignment/beaver-7b-v1.0-rewardand harmlessness (minus the cost) fromPKU-Alignment/beaver-7b-v1.0-cost, on PKU-SafeRLHF prompts; GRPO with 8 responses per prompt, full fine-tuning. - Full weights in fp16, training seed 42: the run of Tab. 4 in the paper.
- The chat template is Safe RLHF's prompt format,
BEGINNING OF CONVERSATION: USER: {prompt} ASSISTANT:.
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
name = "ma-xu/Harmony-lambda-Alpaca-7B-SafeRLHF"
tok = AutoTokenizer.from_pretrained(name)
model = AutoModelForCausalLM.from_pretrained(name, torch_dtype=torch.float16, device_map="cuda")
text = tok.apply_chat_template([{"role": "user", "content": "How can I stay safe when hiking alone?"}],
tokenize=False, add_generation_prompt=True)
ids = tok(text, return_tensors="pt", add_special_tokens=False).to("cuda")
out = model.generate(**ids, max_new_tokens=512, do_sample=False)
print(tok.decode(out[0, ids["input_ids"].shape[1]:], skip_special_tokens=True))
llm/eval_safe.py in the code repository reproduces the evaluation below.
Results (Tab. 4 of the paper, iteration 100, seed 42)
| Method | Reward ↑ | Cost ↓ | Safe (%) ↑ | Skywork ↑ | Guard (%) ↓ | GPT-4o win, helpful (%) ↑ | GPT-4o win, harmless (%) ↑ |
|---|---|---|---|---|---|---|---|
| SFT | −10.14 | 0.18 | 55.4 | −8.7 | 45.8 | 50.0 | 50.0 |
| Harmony | −0.16 | −4.88 | 73.5 | 3.3 | 35.4 | 75.3 | 74.1 |
| Harmony-λ (≥ 90% safe) | −1.56 | −11.28 | 96.6 | 15.9 | 18.3 | 74.2 | 91.0 |
Safe: share of test responses that Safe RLHF's unified cost model rates safe. Skywork:
Skywork-Reward-V2-Llama-3.1-8B. Guard: Granite Guardian's probability of harm. GPT-4o win: gpt-4o-2024-08-06
against the SFT model, in both orders.
License
For non-commercial use only: the model inherits the non-commercial license of
PKU-Alignment/alpaca-7b-reproduced (a LLaMA-7B derivative) and was trained on PKU-SafeRLHF (CC BY-NC 4.0).
Citation
@article{ma2026harmony,
title = {Harmony without Uniformity: Towards Weight-Free Multi-Reward Reinforcement Learning},
author = {Ma, Xu and Zhang, Yitian and Zhan, Xiaohang and Wang, Yilin and Liu, Ding and Zhou, Yuqian and
Liu, Difan and Mei, Yiqun and Wang, Zihan and Xu, Songtao and Fu, Yun},
year = {2026}
}