MCPcopy Index your code
hub / github.com/Unakar/Logic-RL

github.com/Unakar/Logic-RL @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
1,001 symbols 4,131 edges 167 files 245 documented · 24%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Logic-RL

 

Logic-RL: Unleashing LLM Reasoning with Rule-Based Reinforcement Learning

News

[2025/03/20] We release the ADORA: A Scalable Paradigm for Steering Learning Trajectories .

[2025/03/19] For stable length control, refer to https://github.com/lblankl/Short-RL

Teaser Image
Main results

Benchmark

Model 2ppl 3ppl 4ppl 5ppl 6ppl 7ppl 8ppl
o3-mini-high 0.99 0.98 0.97 0.95 0.94 0.89 0.83
o1-2024-12-17 0.83 0.51 0.38 0.38 0.35 0.30 0.20
GPT-4o 0.68 0.57 0.49 0.32 0.23 0.21 0.11
Deepseek-Math-7b 0.35 0.21 0.08 0.06 0.02 0.00 0.00
Qwen2.5-7B-Instruct-1M 0.49 0.40 0.25 0.11 0.02 0.06 0.01
Qwen2.5-7B-Logic-RL (ours) 0.99 0.99 0.94 0.92 0.91 0.80 0.67

Installation

conda create -n logic python=3.9
pip install torch==2.4.0 --index-url https://download.pytorch.org/whl/cu121
pip3 install vllm==0.6.3 ray
pip3 install flash-attn --no-build-isolation
pip install -e .  # For verl integration
pip install wandb IPython matplotlib

Data Preparation

You can directly use /data.

For your own data generation, here's a demo:

Base Model

python ./examples/data_preprocess/kk.py \
    --local_dir {processed_data_path} \
    --data_path {raw_data_path}

Instruct Model

python ./examples/data_preprocess/kk.py \
    --template_type=qwen-instruct \
    --local_dir {processed_data_path} \
    --data_path {raw_data_path}

Training Execution

conda activate logic
bash main_grpo.sh  # 4×A100 80G

⚙️ Implementation Details

Component Location
Reward Modeling verl/utils/reward_score/kk.py
Data Preprocessing examples/data_preprocess/kk.py

Citation

@misc{xie2025logicrlunleashingllmreasoning,
      title={Logic-RL: Unleashing LLM Reasoning with Rule-Based Reinforcement Learning}, 
      author={Tian Xie and Zitian Gao and Qingnan Ren and Haoming Luo and Yuqian Hong and Bryan Dai and Joey Zhou and Kai Qiu and Zhirong Wu and Chong Luo},
      year={2025},
      eprint={2502.14768},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2502.14768}, 
}

Acknowledgements


Star History

Star History Chart

Core symbols most depended-on inside this repo

get
called by 144
verl/utils/memory_buffer.py
to
called by 95
verl/protocol.py
log_gpu_memory_usage
called by 45
verl/utils/debug/performance.py
update
called by 34
verl/trainer/ppo/core_algos.py
from_dict
called by 28
verl/protocol.py
from_pretrained
called by 23
tests/e2e/envs/digit_completion/tokenizer.py
copy_local_path_from_hdfs
called by 22
verl/utils/fs.py
hf_tokenizer
called by 19
verl/utils/tokenizer.py

Shape

Method 457
Function 401
Class 113
Route 30

Languages

Python100%

Modules by API surface

verl/workers/megatron_workers.py38 symbols
verl/single_controller/ray/base.py38 symbols
verl/protocol.py38 symbols
verl/models/llama/megatron/modeling_llama_megatron.py35 symbols
verl/workers/fsdp_workers.py32 symbols
verl/workers/sharding_manager/megatron_vllm.py31 symbols
verl/utils/torch_functional.py30 symbols
verl/single_controller/base/decorator.py29 symbols
verl/single_controller/base/worker.py24 symbols
verl/models/llama/megatron/layers/parallel_attention.py22 symbols
verl/utils/ulysses.py20 symbols
verl/utils/seqlen_balancing.py20 symbols

For agents

$ claude mcp add Logic-RL \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact