← All projects

RL Post-Training

01.2026 to present

Fine-tuning Qwen2.5 on math with PPO and a programmatic verifier.

PythonPyTorchTransformersPPOLoRARunPod
Notes

Post-training Qwen2.5-0.5B-Instruct on math, where the reward comes from a program that checks the answer rather than from a preference model. I built it to understand post-training by implementing it instead of reading about it.

Setup

  • 201-question math benchmark with a deterministic 159 train / 42 eval split across three difficulty levels.
  • LoRA at r=8, alpha=16, targeting q_proj and v_proj, plus a custom value head for actor-critic training.
  • PPO with token-level log-probabilities, GAE advantage estimation, clipped policy updates, and KL regularization against a frozen reference model.
  • 50 epochs, 4 PPO update passes per batch, minibatches of 16, on RunPod GPUs.

Designing the verifier

I used Hugging Face Transformers to load Qwen and PyTorch to implement the PPO loop. I spent more time on the verifier than on the first PPO implementation. It had to distinguish a wrong answer from a correct answer written in an unexpected form, and score formatting without letting it dominate correctness.

What it ended up as: a full score only for a correct answer in the exact tagged format, a small deduction for a correct answer written loosely, and graded penalties for wrong answers scaled by relative error, so being off by one costs far less than being off by an order of magnitude. There is partial credit for correct intermediate results appearing in the reasoning, and a length penalty past 128 tokens.

The real verifier scoring seven candidate outputs for one question. Output captured from the repo.
The real verifier scoring seven candidate outputs for one question. Output captured from the repo.
← All projects