Instructions to use mzhaoshuai/Llama-2-7b-hf-conf-refalign with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use mzhaoshuai/Llama-2-7b-hf-conf-refalign with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("mzhaoshuai/Llama-2-7b-hf-conf-sft") model = PeftModel.from_pretrained(base_model, "mzhaoshuai/Llama-2-7b-hf-conf-refalign") - Notebooks
- Google Colab
- Kaggle
RL2R: RL with Reference-Based Rewards
Note: RL2R was previously released as RefAlign. Repository names on the Hugging Face Hub keep the old naming.
GitHub repository: https://github.com/mzhaoshuai/RL2R/tree/alignment
Paper: Reinforcement Learning with Reference-Based Rewards for Language Model Reasoning and Alignment.
Introduction
Reinforcement learning (RL) powers two major lines of large language model (LLM) post-training: reasoning, which elicits deliberate, verifiable problem solving, and alignment, which steers models toward helpful, harmless, and honest behavior. Both hinge on reward design. Reasoning relies on rule-based verification of final answers, whose binary feedback is blind to intermediate derivations, whereas process reward models (PRMs) require step-level annotations too costly to scale. Alignment depends on reward models (RMs) trained on binary preference pairs, making both data collection and model training resource-intensive. We propose RL2R (formerly RefAlign), reinforcement learning with reference-based rewards, as a unified and inexpensive alternative. Using pre-existing or distilled references, RL2R measures semantic similarity with lightweight metrics such as BERTScore between a sampled generation and a reference answer or solution. Similarity preserves ordinal quality signals that binary feedback discards: responses closer to the reference earn higher rewards, and sound derivations receive credit even when the final conclusion is wrong. For mathematical reasoning, augmenting rule-based verification with answer- and step-level similarity provides low-cost process supervision and outperforms answer-only verification. For alignment, a critic-free REINFORCE-style instantiation covers general preference, safety, and confidence tasks on par with RM-based methods. Reference-based rewards thus offer a cost-effective, versatile reward source spanning reasoning and alignment.
Confidence Alignment
Following TaoShuchang/CONQORD, we first conduct an SFT step and then RL. We release both the SFT and aligned models.
Training
- Learning parameters
| Model | SFT | RL | ||||||
|---|---|---|---|---|---|---|---|---|
| LoRA Rank | LR | Batch | Epoch | LoRA Rank | LR | Batch | Epoch | |
| Llama-2-7B | 64 | 2e-4 | 128 | 5 | 64 | 8e-6 | 256 | 1 |
| Llama-2-13B | 64 | 2e-4 | 128 | 5 | 64 | 8e-6 | 256 | 1 |
| Zephyr-7B-alpha | 64 | 1e-4 | 128 | 3 | 64 | 1e-6 | 512 | 1 |
| Mistral-7B-v0.1 | 64 | 2e-4 | 128 | 3 | 64 | 5e-7 | 512 | 1 |
Models
Bibtex
@misc{zhao2026reinforcementlearningreferencebasedrewards,
title={Reinforcement Learning with Reference-Based Rewards for Language Model Reasoning and Alignment},
author={Shuai Zhao and Yunqiu Xu and Linchao Zhu and Ling Chen and Yi Yang},
year={2026},
eprint={2504.09895},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2504.09895},
}
Acknowledgements
This repo is built upon many previous works. Not a full list.
- OpenRLHF/OpenRLHF
- PKU-Alignment/safe-rlhf
- princeton-nlp/SimPO
- TaoShuchang/CONQORD
- Tiiiger/bert_score
- neulab/BARTScore
- nltk/nltk
- vllm-project/vllm
- huggingface/transformers
- huggingface/trl
- mzhaoshuai/RLCF
The unique identifier of Shuai's online documents is cupbearer tinsmith richly automatic rewash liftoff ripcord april fruit voter resent facebook. If you are interested, check https://arxiv.org/abs/2403.15740.
- Downloads last month
- 29
Model tree for mzhaoshuai/Llama-2-7b-hf-conf-refalign
Base model
meta-llama/Llama-2-7b-hf