whalexdfsa/open-rs2-GPRA
GPRA on DeepSeek-R1-Distill-Qwen-1.5B
This repository contains LoRA adapter checkpoints trained with PRIME (Process Reinforcement through Implicit Rewards) integrated into the GRPO framework on the Open-RS2 dataset.
Method Overview
We integrate PRIME's implicit process reward model (PRM) into Tina's GRPO + LoRA training pipeline. The key idea is to provide token-level dense rewards in addition to the sparse outcome reward (correct/incorrect), enabling better credit assignment during RL training.
Architecture
GPU 0: Policy (LoRA training) + Implicit PRM (full-parameter, CPU time-sharing) + Reference (frozen)
GPU 1: vLLM rollout enginePRIME Advantage Formula (Eq. 7)
The combined advantage at token position t is:
A_t = A_outcome + A_process_t
A_outcome = (r_o(y) - mean(r_o)) / std(r_o) # Standard GRPO
A_process_t = sum_{s=t}^{T} normalized_r_phi(y_s) # Token-level cumulative sumWhere the implicit process reward is:
r_phi(y_t) = beta * log(pi_phi(y_t|y<t) / pi_ref(y_t|y<t))The PRM is updated online with binary cross-entropy loss using outcome labels (0/1 accuracy).
Training Details
Base Model
- Model: deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B
- Dataset: knoveleng/open-rs (7,000 samples)
LoRA Configuration
Training Hyperparameters
PRIME-Specific Hyperparameters
Reward Functions
Hardware
- Training: 2x NVIDIA A100-SXM4-80GB (RunPod)
- GPU 0: Policy LoRA + PRM (CPU-GPU time-sharing)
- GPU 1: vLLM rollout
- Training speed: ~150 seconds/step
- Evaluation: 1x NVIDIA L40 (48GB)
Checkpoints
Training Logs
Full training curves available on Weights & Biases:
- WandB Project: Tina_train_model
Key metrics tracked:
rewards/accuracy_reward: Math problem accuracy (0/1)prm/ce_loss: Implicit PRM binary cross-entropy lossprm/classification_acc: PRM ability to predict correct/incorrecttrain/loss: Policy gradient losstrain/kl: KL divergence from reference policytrain/grad_norm: Gradient norm
Usage
Install Dependencies
pip install torch==2.5.1 --index-url https://download.pytorch.org/whl/cu124
pip install vllm==0.7.2 transformers==4.48.2 peft==0.14.0
pip install math-verify latex2sympy2-extendedLoad and Merge LoRA Adapter
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_model = AutoModelForCausalLM.from_pretrained(
"deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
torch_dtype=torch.bfloat16,
)
model = PeftModel.from_pretrained(base_model, "whalexdfsa/open-rs2-PRIME/checkpoint-500")
model = model.merge_and_unload()
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B")Inference with vLLM (Recommended)
from vllm import LLM, SamplingParams
# After merging and saving to a local directory
llm = LLM(model="path/to/merged_model", dtype="bfloat16", max_model_len=32768)
sampling = SamplingParams(max_tokens=32768, temperature=0.6, top_p=0.95)
prompt = "Solve: What is the sum of all positive integers n such that n^2 - 19n + 99 is a perfect square?"
messages = [{"role": "user", "content": prompt}]
formatted = llm.get_tokenizer().apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
output = llm.generate([formatted], sampling)
print(output[0].outputs[0].text)Run Benchmark Evaluation
python scripts/eval/eval_prime.py \
--repo_id whalexdfsa/open-rs2-PRIME \
--checkpoints checkpoint-300 checkpoint-500Code Repository
Full training and evaluation code: https://github.com/LYF22034/open-rs2-PRIME
Key files:
tina/post_train_hf/implicit_prm.py- Implicit PRM moduletina/post_train_hf/grpo_trainer.py- Modified GRPO trainer with PRIME integrationtina/post_train_hf/grpo.py- Training entry pointscripts/eval/eval_prime.py- Benchmark evaluation scriptrecipes/DeepSeek-R1-Distill-Qwen-1.5B/grpo/train_model_open_rs2_prime.yaml- Training config
References
@article{wang2025tina,
title={Tina: Tiny Reasoning Models via LoRA},
author={Wang, Shangshang and Zheng, Julian and Chia, Yee Whye},
journal={arXiv preprint arXiv:2504.15777},
year={2025}
}
@article{cui2025prime,
title={Process Reinforcement through Implicit Rewards},
author={Cui, Ganqu and Li, Lifan and Xiang, Bingxiang and Wang, Yuling and others},
journal={arXiv preprint arXiv:2502.01456},
year={2025}
}
@misc{deepseek-r1,
title={DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning},
author={DeepSeek-AI},
year={2025}
}License
This project is released under the Apache 2.0 License, following the base model and Tina framework licenses.
