{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/training-large-language-models-for-reasoning","title":"Training Large Language Models for Reasoning through Reverse Curriculum Reinforcement Learning","arxiv_id":"2402.05808","date":"2024-02-08","proceeding":null,"authors":["Zhiheng Xi","Wenxiang Chen","Boyang Hong","Senjie Jin","Rui Zheng","wei he","Yiwen Ding","Shichun Liu","Xin Guo","Junzhe Wang","Honglin Guo","Wei Shen","Xiaoran Fan","Yuhao Zhou","Shihan Dou","Xiao Wang","Xinbo Zhang","Peng Sun","Tao Gui","Qi Zhang","Xuanjing Huang"],"abstract":"In this paper, we propose R$^3$: Learning Reasoning through Reverse Curriculum Reinforcement Learning (RL), a novel method that employs only outcome supervision to achieve the benefits of process supervision for large language models. The core challenge in applying RL to complex reasoning is to identify a sequence of actions that result in positive rewards and provide appropriate supervision for optimization. Outcome supervision provides sparse rewards for final results without identifying error locations, whereas process supervision offers step-wise rewards but requires extensive manual annotation. R$^3$ overcomes these limitations by learning from correct demonstrations. Specifically, R$^3$ progressively slides the start state of reasoning from a demonstration's end to its beginning, facilitating easier model exploration at all stages. Thus, R$^3$ establishes a step-wise curriculum, allowing outcome supervision to offer step-level signals and precisely pinpoint errors. Using Llama2-7B, our method surpasses RL baseline on eight reasoning tasks by $4.1$ points on average. Notebaly, in program-based reasoning on GSM8K, it exceeds the baseline by $4.2$ points across three backbone models, and without any extra data, Codellama-7B + R$^3$ performs comparable to larger models or closed-source models.","url_abs":"https://arxiv.org/abs/2402.05808v2","url_pdf":"https://arxiv.org/pdf/2402.05808v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"training-large-language-models-for-reasoning","repo_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"gsm8k","task_name":"GSM8K"},{"task_slug":"reinforcement-learning-1","task_name":"Reinforcement Learning (RL)"},{"task_slug":"reinforcement-learning-2","task_name":"reinforcement-learning"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2402.05808","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.05808"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/woooodyy/llm-reverse-curriculum-rl","reach":{"status":"ok"}}],"summary":{"ran":6,"ran_fixture":1,"unverified":12},"by_repo_kind":{"official":{"samples":19,"ran":7,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":19,"samples":[{"code_sha256_prefix":"7ffa253a733f9bfc","entry":"discount_cumsum","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_math/src/utils.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_math/src/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7ffa253a733f9bfc"}},{"code_sha256_prefix":"b425aefc590684dc","entry":"format_code","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_math/src/python_stdout_engine.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_math/src/python_stdout_engine.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b425aefc590684dc"}},{"code_sha256_prefix":"2f0a690c70d11c23","entry":"gather_log_probs","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_others/dschat/rlhf/ppo_trainer.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_others/dschat/rlhf/ppo_trainer.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"2f0a690c70d11c23"}},{"code_sha256_prefix":"1af181bffd7c0355","entry":"number_it","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_math/src/python_stdout_engine.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_math/src/python_stdout_engine.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1af181bffd7c0355"}},{"code_sha256_prefix":"2221a9c4d6aaccc3","entry":"process_code","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_math/src/python_engine.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_math/src/python_engine.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"2221a9c4d6aaccc3"}},{"code_sha256_prefix":"23907c9b2306bf66","entry":"run_python_code","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_math/src/python_engine.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_math/src/python_engine.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"23907c9b2306bf66"}},{"code_sha256_prefix":"add7bb376d093e6a","entry":"test_answer_for_reward","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_others/dschat/rlhf/ppo_trainer.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_others/dschat/rlhf/ppo_trainer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"add7bb376d093e6a"}},{"code_sha256_prefix":"069f56cb00324e10","entry":"calculate_flops","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_others/dschat/utils/perf.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_others/dschat/utils/perf.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"069f56cb00324e10"}},{"code_sha256_prefix":"b6934717c02ba140","entry":"causal_lm_model_to_fp32_loss","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_others/dschat/utils/model/model_utils.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_others/dschat/utils/model/model_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b6934717c02ba140"}},{"code_sha256_prefix":"32851be78f5ecd4c","entry":"do_gather","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_math/src/utils.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_math/src/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"32851be78f5ecd4c"}},{"code_sha256_prefix":"f8cd262700389f42","entry":"floatify","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_math/src/python_stdout_engine.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_math/src/python_stdout_engine.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f8cd262700389f42"}},{"code_sha256_prefix":"792e87a1badc5642","entry":"get_eval_ds_config","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_others/dschat/utils/ds_utils.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_others/dschat/utils/ds_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"792e87a1badc5642"}},{"code_sha256_prefix":"df20c2f4083d17af","entry":"get_hf_configs","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_others/dschat/utils/perf.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_others/dschat/utils/perf.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"df20c2f4083d17af"}},{"code_sha256_prefix":"60da16ae2ccbd130","entry":"get_tokenizer","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_others/dschat/utils/utils.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_others/dschat/utils/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"60da16ae2ccbd130"}},{"code_sha256_prefix":"c3b86a3bceec86cd","entry":"is_numeric","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_math/src/utils.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_math/src/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c3b86a3bceec86cd"}},{"code_sha256_prefix":"51909067f349309c","entry":"load_hf_tokenizer","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_others/dschat/utils/utils.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_others/dschat/utils/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"51909067f349309c"}},{"code_sha256_prefix":"429d42a3bf925da5","entry":"log_init","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_others/dschat/rlhf/rlhf_engine.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_others/dschat/rlhf/rlhf_engine.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"429d42a3bf925da5"}},{"code_sha256_prefix":"7d082cd1b7edc2aa","entry":"only_optimize_lora_parameters","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_others/dschat/utils/module/lora.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_others/dschat/utils/module/lora.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7d082cd1b7edc2aa"}},{"code_sha256_prefix":"387b9e6c4f21dd62","entry":"to_device","repo":"woooodyy/llm-reverse-curriculum-rl","repo_kind":"official","path":"R3_others/dschat/utils/utils.py","file_url":"https://github.com/woooodyy/llm-reverse-curriculum-rl/blob/HEAD/R3_others/dschat/utils/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"387b9e6c4f21dd62"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}