English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

Logic-RL: Rule-Based Reinforcement Learning Unlocks Reasoning in Large Language Models

Forum topic · QianXun · 2025-11-17

Summary

Logic-RL is a rule-based reinforcement learning framework that trains large language models to develop generalizable reasoning abilities instead of memorizing patterns. Inspired by DeepSeek-R1, it fine-tunes a 7B-parameter model on only about 5,000 programmatically generated Knights & Knaves logic puzzles, where answers can be verified automatically, providing stable, noise-free reward signals. The framework combines a structured system prompt requiring explicit reasoning inside think tags, a stringent format reward function that penalizes shortcut behavior, and a stable training recipe based on REINFORCE++ with PPO/GRPO-style optimization and KL-divergence penalties. Despite training solely on synthetic logic puzzles, the model achieves dramatic gains on out-of-distribution math competitions: accuracy improves by 125% on AIME (2021-2024) and 38% on AMC (2022-2023). Notably, the model spontaneously learns to lengthen its reasoning chains (from ~500 to ~2,000 tokens) and exhibits emergent behaviors such as reflection, verification, and summarization. Compared with traditional RLHF approaches that rely on model-based reward models and large-scale human-annotated data, Logic-RL offers a cheaper, more stable, and highly data-efficient path to unlocking LLM reasoning, with open-source code available on GitHub.

Logic-RL is a framework that uses rule-based reinforcement learning (RL) to guide large language models (LLMs) toward advanced, generalizable reasoning rather than memorizing training data. Inspired by the success of DeepSeek-R1, it enables a relatively small model to make breakthroughs on complex logic and math tasks using only about 5,000 training examples.

Key points

  • Rule-based RL core: Instead of large-scale human annotation or learned reward models, Logic-RL uses clear, verifiable rules to define "good" behavior. This yields precise, stable reward signals and avoids reward hacking.
  • Training data: ~5,000 programmatically generated Knights & Knaves (K&K) logic puzzles. Difficulty is controllable (number of characters, nesting depth), and answers are unique and automatically verifiable—ideal for stable RL rewards.
  • Structured system prompt: The model must place its reasoning inside <think>...</think> tags and the final answer inside <answer>...</answer> tags, mechanically preventing shortcut answers and forcing "thinking out loud."
  • Stringent format reward: A composite reward combines an answer reward (exact match against the ground truth) with a format reward (correct use of tags and a non-trivial reasoning chain). Outputs that skip reasoning are penalized even if the answer is correct.
  • Training recipe: Primarily based on REINFORCE++, with PPO/GRPO-style optimization and likely KL-divergence penalties (L(θ) = E[log π_θ(a|s) * A(s,a)] - β * KL(π_θ || π_ref)) to prevent policy collapse and ensure stable convergence.
  • Emergent reasoning behavior: Response length grows spontaneously from ~500 tokens to nearly 2,000 tokens during training, and tokens associated with reflection and verification increase in frequency alongside performance—without any explicit length reward.
  • Cross-domain generalization: The K&K-trained 7B model, applied directly to "super out-of-distribution" math competitions, improves accuracy by +125% on AIME (2021-2024) and +38% on AMC (2022-2023) relative to baselines:
  • | Benchmark | Performance Improvement | | :--- | :--- | | AIME (2021-2024) | +125% | | AMC (2022-2023) | +38% |

  • Data efficiency: Success on just 5K synthetic examples challenges the notion that capability gains require massive data and parameter scaling, showing that well-designed RL on core cognitive skills can unlock transferable reasoning at low cost.
  • Comparison with DeepSeek-R1: Logic-RL borrows the rule-based reward and GRPO-style RL ideas from DeepSeek-R1 but distinguishes itself with a mandatory structured output format and stringent format rewards that enforce complete reasoning chains.
  • Comparison with traditional RLHF: Rule-based rewards are stable, unbiased, and cheap, unlike model-based reward models prone to inaccuracy, bias, and reward hacking. Training relies on cheap, reproducible synthetic data instead of expensive large-scale human annotation.
  • Open source: The team has released code and data, including an official "Logic-RL" repository and a lightweight reproduction project ("Logic-RL-Lite") on GitHub, supporting reproducibility and community extension.

Why it matters

Logic-RL demonstrates that models can learn *how to think* rather than merely memorize answers. By combining controllable synthetic tasks, verifiable rewards, and strict process constraints, a 7B model achieves competitive reasoning performance, opening a path to high-capability, resource-efficient reasoning systems.

Tags

#reinforcement-learning#llm-reasoning#logic-rl#deepseek-r1#rule-based-reward#knights-and-knaves#aime-amc#data-efficiency

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/176313323