Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 5 min read Research hardMaster

DeepMath: A lightweight math reasoning Agent with smolagents

DeepMath fine-tunes Qwen3-4B Thinking with GRPO so it emits short Python snippets for intermediate math steps, runs them in a sandbox (module allow-list, no file I/O or network, per-snippet timeouts), and feeds results back into its reasoning. The agent is built on smolagents with vLLM inference, and TRL's vLLM client/server was modified so GRPO candidates are generated by the agent. Rewards cover correctness and code use, completions are capped at 5k tokens, temperature is scheduled linearly from 1.2 to 0.7, and training uses the OpenMathReasoning TIR subset. On MATH500, AIME, HMMT and HLE, agentic inference alone cuts output length by up to 66% with mixed accuracy, and combining it with GRPO training gives the best accuracy with shorter traces.

Related posts

  • Open R1: Update #2

    Hugging Face hardMaster

    OpenR1-Math-220k is a math reasoning dataset built by generating 800k DeepSeek R1 traces for 400k NuminaMath 1.5 problems on 512 local H100s. Switching inference from vLLM to SGLang nearly doubled throughput, from 15 to 25 generations per hour per H100. Traces were filtered with Math-Verify plus a Llama-3.3-70B-Instruct judge, which recovered 28k rejected problems, while reward-model selection among correct answers gave no gain over random choice. Fine-tuning Qwen2.5-Math-Instruct on the 94k default split nearly matches DeepSeek-Distill-Qwen-7B, and the update also covers community GRPO results, small curated datasets (s1K, LIMO) and controlling chain-of-thought length with budget forcing and cosine rewards.

  • Jupyter Agents: training LLMs to reason with notebooks

    Hugging Face hardMaster

    Fine-tuning Qwen3-4B on 51k synthetic Jupyter notebook traces, combined with a minimal ~200-line two-tool scaffold (code execution plus final_answer), raised its DABStep easy-split accuracy from 38.67% to 75%. The scaffold change alone accounted for roughly 14 points of that gain. The dataset pipeline starts from ~2TB of Kaggle notebooks and runs deduplication (~90% were duplicates), linked-dataset download, LLM educational scoring and relevance filtering, verified QA generation with Qwen3-32B, and trace generation with Qwen3-Coder-480B in E2B sandboxes. Training findings include using full-parameter SFT over PEFT, assistant-only loss, NEFTune noise, and about 5 epochs as the sweet spot.

  • Mini-R1: Reproduce Deepseek R1 „aha moment“ a RL tutorial

    Hugging Face hardMaster

    Recreates DeepSeek R1's "aha moment" by training Qwen2.5-3B-Instruct with GRPO on the Countdown numbers game, using rule-based format and accuracy rewards in TRL with DeepSpeed ZeRO-3 and vLLM generation on 4x H100s. GRPO drops PPO's value model and instead normalizes rewards within a group of sampled outputs to compute advantages. The DeepSeekMath hyperparameters became unstable after about 150 steps, so the learning rate was lowered to 5e-7 and the KL beta to 0.001. The model learned the output format by step 50 and reached about 50% success by step 450 (roughly 6 hours), shifting around step 200 from verbal reasoning to programmatic trial-and-check search.

  • How NuminaMath Won the 1st AIMO Progress Prize

    Hugging Face hardMaster

    NuminaMath 7B TIR won the first AIMO Progress Prize by solving 29 of 50 private test problems, using a DeepSeekMath-Base 7B model fine-tuned in two stages: first on several hundred thousand chain-of-thought math solutions, then on about 60k GPT-4-generated tool-integrated reasoning traces that interleave rationales, Python code and execution output. At inference, a self-consistency plus tool-integrated reasoning (SC-TIR) decoder samples 48 candidates, executes generated code for up to 4 rounds so the model can self-correct from tracebacks, then majority-votes the answer, which cut variance under Kaggle's random problem order. Models were 8-bit GPTQ-quantized to fit 2xT4 GPUs without bfloat16 support, and internal AMC/AIME validation sets were used to avoid overfitting the 50-problem public leaderboard. Training details include full fine-tuning with TRL packing, DeepSpeed ZeRO-3 and 10 hours on 8xH100.

  • Beat GPT-4o at Python by searching with 100 dumb LLaMAs

    Modal mediumAdept

    Sampling LLaMA 3.1 8B Instruct many times and checking each candidate against HumanEval's unit tests raises pass@k from 66.4% at k=1 to 90.5% at k=100, matching GPT-4o's reported 90.2% pass@1, and to 95.1% at k=1000. This replicates the core claim of the Large Language Monkeys paper on a new model and dataset, with fail@k following a smooth log-log scaling law across three orders of magnitude. The setup used vLLM with prefix caching on ten A100s, reaching about 40k output tokens/s, plus Modal Sandboxes running about 3,000 isolated test executions in parallel, all for under $50. The larger argument is that search trades memory for compute and depends on fast, objective evaluation, so domains with verifiable outcomes like code and formal math benefit most.

The quest for software engineering knowledge.

Look:
Layout: