Skip to content
lyzk907-devPublic

About

Math reasoning post-training lab with SFT, GRPO, evaluation, and ReAct agent

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Math Reasoning Post-Training Lab

This project is a small end-to-end learning lab for improving and evaluating mathematical reasoning with a 0.5B open model.

It covers:

  • baseline evaluation on GSM8K
  • supervised fine-tuning (SFT) with LoRA
  • GRPO training with verifiable rewards
  • a simple ReAct calculator agent
  • result comparison and error analysis

Model And Data

  • Model: Qwen/Qwen2.5-0.5B-Instruct
  • Dataset: openai/gsm8k
  • Main metric: exact match on extracted final numeric answer
  • Hardware used: RTX 5060 Laptop GPU, 8GB VRAM

Current Results

Run Accuracy File
Baseline learn 20 5/20 = 25.00% artifacts/baseline_learn_predictions.jsonl
SFT learn 500 8/20 = 40.00% artifacts/sft_learn_500_predictions.jsonl
GRPO learn 8/20 = 40.00% artifacts/grpo_learn_predictions.jsonl
ReAct learn 2/5 = 40.00% artifacts/react_learn_predictions.jsonl

The strongest clear improvement is SFT learn 500 over the 20-question baseline:

Baseline: 5/20 = 25.00%
SFT 500:  8/20 = 40.00%

GRPO successfully receives positive rewards during training, but in this small run it matches SFT accuracy rather than exceeding it. ReAct demonstrates tool-use behavior and fixes some baseline arithmetic failures, but it is not yet robust overall.

Important Commands

Prepare SFT data:

python scripts\03_prepare_sft_data.py --num-examples 500 --output-path artifacts\sft_train_learn_500.jsonl

Train SFT:

python scripts\04_train_sft.py --train-path artifacts\sft_train_learn_500.jsonl --output-dir artifacts\sft_lora_learn_500_lr5e5 --epochs 1 --max-length 1024 --lora-r 8 --lora-alpha 16 --grad-accum 4 --learning-rate 5e-5

Evaluate SFT:

python scripts\05_evaluate_sft.py --adapter-path artifacts\sft_lora_learn_500_lr5e5 --output-path artifacts\sft_learn_500_predictions.jsonl --num-examples 20

Train GRPO:

python scripts\06_train_grpo.py --sft-adapter-path artifacts\sft_lora_learn_500_lr5e5 --output-dir artifacts\grpo_lora_learn_from_sft500 --num-examples 16 --max-steps 8 --num-generations 2 --max-completion-length 256 --learning-rate 2e-6

Evaluate ReAct:

python scripts\09_evaluate_react.py --num-examples 5 --output-path artifacts\react_learn_predictions.jsonl

Compare results:

python scripts\10_compare_results.py
python scripts\11_analyze_improvements.py

Notes

This is intentionally a small educational project. The smoke runs prove the pipeline. The learn runs are large enough to show an SFT improvement, but still too small to be treated as a rigorous benchmark.

About

Math reasoning post-training lab with SFT, GRPO, evaluation, and ReAct agent

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages