Run this model with HF Jobs

Run ma-xu/Harmony-lambda-Alpaca-7B-SafeRLHF on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/ma-xu/Harmony-lambda-Alpaca-7B-SafeRLHF. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/ma-xu/Harmony-lambda-Alpaca-7B-SafeRLHF on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/ma-xu/Harmony-lambda-Alpaca-7B-SafeRLHF. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/ma-xu/Harmony-lambda-Alpaca-7B-SafeRLHF. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

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-reward and harmlessness (minus the cost) from PKU-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}
}
Downloads last month
256
Safetensors
Model size
7B params
Tensor type
F16
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for ma-xu/Harmony-lambda-Alpaca-7B-SafeRLHF

Finetuned
(10)
this model

Dataset used to train ma-xu/Harmony-lambda-Alpaca-7B-SafeRLHF