TL;DR
TemplateRL introduces a structured, template-guided reinforcement learning framework for LLMs that replaces unstructured self-sampling with high-level strategic thought patterns. By leveraging a dynamic template library built via Monte Carlo Tree Search (MCTS), it significantly boosts sampling efficiency, prevents training collapse on weaker models, and dramatically improves reasoning performance across diverse domains and modalities.
What Problem Does This Paper Address?
Reinforcement learning (RL) methods like GRPO have successfully enhanced LLM reasoning capabilities (as seen in models like DeepSeek-R1). However, these methods typically rely on unstructured self-sampling to maximize scalar rewards. This creates three major bottlenecks:
- Inefficient trajectory sampling: Without guidance, models waste compute exploring low-quality paths, leading to low hit rates and training instability.
- Difficulty learning transferable strategies: Models tend to fit surface-level token steps rather than abstracting high-level problem-solving logic (e.g., divide-and-conquer).
- Lack of interpretability: Standard RL optimization produces reasoning trajectories without explicit strategic structure, making error diagnosis and expert intervention difficult.
These limitations are especially severe for smaller, weaker models, which frequently suffer from complete training collapse due to sparse positive reward signals.
Methods
The authors propose TemplateRL, a framework consisting of three core components:
- Template Construction: Using Monte Carlo Tree Search (MCTS) on a small seed dataset (500 instances), the system explores diverse solution paths. Successful paths are abstracted into structured templates using a predefined 5-action space: Divide and Conquer (a1), Self-Reflection (a2), System Analysis (a3), One-Step Thought (a4), and Chain-of-Thought (a5). These templates are aggregated based on Problem Condition Complexity (PCC)—a metric defining the number of prior conditions in a question.
- Template-Guided Training: During online RL training, the framework adaptively retrieves the top-$k$ most structurally similar templates based on the query's PCC. The policy model is then prompted to roll out iteratively following these high-level actions.
- Optional Template Updates: The template library supports continuous online updates during both training and inference by automatically abstracting new strategic patterns from successful rollouts.
The overall pipeline is illustrated in the flowchart below: TemplateRL Flowchart
Datasets
- Training: 5.5K problems from the MATH dataset (levels 3–5). 500 instances are randomly sampled to construct the initial template library seed, leaving 5K for actual RL training.
- Evaluation (Text): Standard math and reasoning benchmarks including MATH500, AIME 2024, AMC, Minerva, OlympiadBench, GSM8K, College Math, and Gaokao23.
- Out-of-Domain (OOD): BALROG (agentic reasoning in games), GPQA-D (graduate-level science), and MMLU-Pro (general knowledge).
- Multimodal Extension: MMTrain10K (augmented from Geometry3K using Gemini-2.5-Pro) for training, evaluated on MathVision, MathVerse, MathVista, MMMU, and BLINK.
Key Insights and Ideas
- The Teacher-Student Analogy: Standard RL acts like a teacher who only provides the final answer ("Correct" or "Incorrect"), leaving the student to guess the method. TemplateRL provides a structural blueprint of thought patterns, enabling the model to learn both concrete steps and underlying strategic logic. Teacher-Student Analogy
- Scaffolding Weaker Models: Smaller models (like Llama-3.2-3B) frequently fail to generate any correct answers during unstructured exploration, causing the RL process to collapse. Explicit template guidance acts as a scaffolding mechanism, ensuring a steady stream of high-quality trajectories and stabilizing training dynamics.
- Structure Over Semantics: Matching templates based on structural complexity (PCC) works significantly better than surface-level semantic similarity (sentence embeddings). Two math problems might look completely different textually but share the exact same underlying strategic decomposition requirements.
Key Results
- Massive Performance Gains: On a Qwen2.5-Math-7B-Base backbone, TemplateRL achieved an average score of 55.8 across five competition-level benchmarks, outperforming standard GRPO by 99.4% relative gain on AIME24 (33.3% vs 16.7%) and 40.9% on AMC (77.5% vs 55.0%).
- Training Stability: While standard GRPO completely collapses after 100 steps on Llama-3.2-3B-Base, TemplateRL maintains stable training rewards above 0.25. Training Stability Curves
- Cross-Domain & Multimodal Generalization: Templates learned purely from math problems successfully transferred to non-math domains, boosting performance on BALROG (+6.1%), GPQA-D (+6.6%), and MMLU-Pro (+7.4%). When extended to multimodal models (Qwen2.5-VL-3B-Instruct), it achieved an average +8.4% improvement over GRPO across visual reasoning tasks.
Limitations and Future Work
- Action Space Constraints: The current framework relies on a fixed 5-action space. While effective for math and science, highly open-ended agentic tasks may demand richer, more dynamic template structures.
- Domain Scope: The initial template library was constructed primarily from mathematical seeds. Although it generalizes well, real-world physical environments and open-ended dialogue generation remain largely unexplored.
- Future Directions: The authors plan to scale TemplateRL to complex agent environments using dynamic branching, integrate it with heterogeneous multi-model orchestration, and combine it with model compression and inference acceleration techniques to mitigate the ~1.8× computational overhead introduced by iterative action prompting during rollout generation.
Summary updated