YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

🧠 Math Reasoning LLM β€” SFT + GRPO Fine-Tuning

Taught a small LLM to reason step-by-step using Reinforcement Learning (GRPO)

πŸ”¬ What This Project Does

Fine-tunes Qwen2.5-1.5B-Instruct (1.5B parameters) to solve math problems with chain-of-thought reasoning using a two-phase training approach:

  1. Phase 1 β€” SFT (Supervised Fine-Tuning): Train on 50K math problems with worked solutions from NuminaMath-CoT to teach the model how to show its work
  2. Phase 2 β€” GRPO (Group Relative Policy Optimization): Reinforce correct reasoning using reward functions β€” the same RL technique behind DeepSeek-R1

πŸ“Š Results

Benchmark Base Model After SFT After GRPO Improvement
MATH-500 ~XX% ~XX% ~XX% +XXpp

(Fill in after running evaluation)

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Training Pipeline                      β”‚
β”‚                                                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  NuminaMath  │───▢│  SFT Phase   │───▢│  SFT Model  β”‚ β”‚
β”‚  β”‚  CoT (50K)   β”‚    β”‚  (QLoRA)     β”‚    β”‚  Adapter    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                 β”‚        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  DeepMath   │───▢│  GRPO Phase  │───▢│  GRPO Model β”‚ β”‚
β”‚  β”‚  103K       β”‚    β”‚  (RL + QLoRA)β”‚    β”‚  Adapter    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                 β”‚        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  MATH-500   │───▢│  Evaluation  │───▢│  Benchmark  β”‚ β”‚
β”‚  β”‚  Benchmark  β”‚    β”‚  Script      β”‚    β”‚  Results    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Component Tool
Base Model Qwen/Qwen2.5-1.5B-Instruct
SFT Training TRL SFTTrainer + PEFT QLoRA
RL Training TRL GRPOTrainer + custom rewards
Speed Optimization Unsloth (2x faster, 80% less VRAM)
SFT Dataset AI-MO/NuminaMath-CoT (859K math problems)
GRPO Dataset trl-lib/DeepMath-103K (103K prompts)
Evaluation MATH-500 benchmark
Hardware Kaggle T4 GPU (16GB VRAM, free tier)

πŸ“ Project Structure

project1_math_reasoning_llm/
β”œβ”€β”€ README.md                  # This file
β”œβ”€β”€ 01_sft_training.py         # Phase 1: Supervised Fine-Tuning
β”œβ”€β”€ 02_grpo_training.py        # Phase 2: GRPO Reinforcement Learning
β”œβ”€β”€ 03_evaluation.py           # Evaluate on MATH-500 benchmark
β”œβ”€β”€ kaggle_notebook_sft.py     # Ready-to-paste Kaggle notebook code
β”œβ”€β”€ kaggle_notebook_grpo.py    # Ready-to-paste Kaggle notebook code
└── requirements.txt           # Dependencies

πŸš€ How to Run (Kaggle)

Step 1: SFT Training (~1-2 hours on T4)

  1. Create a new Kaggle notebook with GPU T4 x2 accelerator
  2. Copy contents of kaggle_notebook_sft.py into the notebook
  3. Run all cells
  4. Download the saved adapter from /kaggle/working/sft_adapter/

Step 2: GRPO Training (~2-3 hours on T4)

  1. Upload the SFT adapter to a new Kaggle dataset
  2. Create a new notebook with GPU T4 x2
  3. Copy contents of kaggle_notebook_grpo.py
  4. Update the adapter path
  5. Run all cells

Step 3: Evaluation

  1. Load the GRPO adapter
  2. Run 03_evaluation.py to get MATH-500 scores
  3. Update the results table in this README

πŸ“š Key Concepts You'll Learn

  • QLoRA: 4-bit quantized LoRA β€” fits large models on small GPUs
  • SFT: Teaching a model to mimic expert responses
  • GRPO: Group Relative Policy Optimization β€” RL without a separate reward model
  • Reward Engineering: Designing rewards for accuracy + format + length
  • Chain-of-Thought: <think>...</think> structured reasoning

πŸ“„ Based On

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Papers for Neha12210/project1-math-reasoning-llm