{"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/s-2-r-teaching-llms-to-self-verify-and-self","title":"S$^2$R: Teaching LLMs to Self-verify and Self-correct via Reinforcement Learning","arxiv_id":"2502.12853","date":"2025-02-18","proceeding":null,"authors":["Ruotian Ma","Peisong Wang","Cheng Liu","Xingyan Liu","Jiaqi Chen","Bang Zhang","Xin Zhou","Nan Du","Jia Li"],"abstract":"Recent studies have demonstrated the effectiveness of LLM test-time scaling. However, existing approaches to incentivize LLMs' deep thinking abilities generally require large-scale data or significant training efforts. Meanwhile, it remains unclear how to improve the thinking abilities of less powerful base models. In this work, we introduce S$^2$R, an efficient framework that enhances LLM reasoning by teaching models to self-verify and self-correct during inference. Specifically, we first initialize LLMs with iterative self-verification and self-correction behaviors through supervised fine-tuning on carefully curated data. The self-verification and self-correction skills are then further strengthened by both outcome-level and process-level reinforcement learning, with minimized resource requirements, enabling the model to adaptively refine its reasoning process during inference. Our results demonstrate that, with only 3.1k self-verifying and self-correcting behavior initialization samples, Qwen2.5-math-7B achieves an accuracy improvement from 51.0\\% to 81.6\\%, outperforming models trained on an equivalent amount of long-CoT distilled data. Extensive experiments and analysis based on three base models across both in-domain and out-of-domain benchmarks validate the effectiveness of S$^2$R. Our code and data are available at https://github.com/NineAbyss/S2R.","url_abs":"https://arxiv.org/abs/2502.12853v1","url_pdf":"https://arxiv.org/pdf/2502.12853v1.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":"s-2-r-teaching-llms-to-self-verify-and-self","repo_url":"https://github.com/nineabyss/s2r","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"math","task_name":"Math"}],"methods":[{"method_slug":"base","method_name":"BASE"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2502.12853","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2502.12853"}},"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/nineabyss/s2r","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":1,"unverified":11},"by_repo_kind":{"official":{"samples":12,"ran":1,"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":0,"samples":[{"code_sha256_prefix":"1525d8bc0fc8d5a0","entry":"generate_completions","repo":"nineabyss/s2r","repo_kind":"official","path":"sample/model_utils.py","file_url":"https://github.com/nineabyss/s2r/blob/HEAD/sample/model_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1525d8bc0fc8d5a0"}},{"code_sha256_prefix":"12f058fedbfebe48","entry":"compute_baseline","repo":"nineabyss/s2r","repo_kind":"official","path":"code/data_process_offline_rl.py","file_url":"https://github.com/nineabyss/s2r/blob/HEAD/code/data_process_offline_rl.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"12f058fedbfebe48"}},{"code_sha256_prefix":"d5d26fac128716bc","entry":"exact_div","repo":"nineabyss/s2r","repo_kind":"official","path":"code/src/rloo_trainer.py","file_url":"https://github.com/nineabyss/s2r/blob/HEAD/code/src/rloo_trainer.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d5d26fac128716bc"}},{"code_sha256_prefix":"2f5119732e8dbd63","entry":"get_all_parameters","repo":"nineabyss/s2r","repo_kind":"official","path":"code/src/offline_trainer.py","file_url":"https://github.com/nineabyss/s2r/blob/HEAD/code/src/offline_trainer.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2f5119732e8dbd63"}},{"code_sha256_prefix":"90b37672a94f87c5","entry":"get_instance_reward_from_reward_dist","repo":"nineabyss/s2r","repo_kind":"official","path":"code/data_process_offline_rl.py","file_url":"https://github.com/nineabyss/s2r/blob/HEAD/code/data_process_offline_rl.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"90b37672a94f87c5"}},{"code_sha256_prefix":"a989572880b87850","entry":"hooks_exist","repo":"nineabyss/s2r","repo_kind":"official","path":"code/src/offline_trainer.py","file_url":"https://github.com/nineabyss/s2r/blob/HEAD/code/src/offline_trainer.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a989572880b87850"}},{"code_sha256_prefix":"48685a350888e505","entry":"iter_params","repo":"nineabyss/s2r","repo_kind":"official","path":"code/src/offline_trainer.py","file_url":"https://github.com/nineabyss/s2r/blob/HEAD/code/src/offline_trainer.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"48685a350888e505"}},{"code_sha256_prefix":"bb274361403163d9","entry":"iter_params","repo":"nineabyss/s2r","repo_kind":"official","path":"code/src/rloo_utils.py","file_url":"https://github.com/nineabyss/s2r/blob/HEAD/code/src/rloo_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"bb274361403163d9"}},{"code_sha256_prefix":"17c4e4f3635d3ee1","entry":"jload","repo":"nineabyss/s2r","repo_kind":"official","path":"code/utils.py","file_url":"https://github.com/nineabyss/s2r/blob/HEAD/code/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"17c4e4f3635d3ee1"}},{"code_sha256_prefix":"ee71a94d9dd1b8e9","entry":"load_hf_lm_and_tokenizer","repo":"nineabyss/s2r","repo_kind":"official","path":"sample/model_utils.py","file_url":"https://github.com/nineabyss/s2r/blob/HEAD/sample/model_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ee71a94d9dd1b8e9"}},{"code_sha256_prefix":"79fec8bb0e1104b4","entry":"preprocess","repo":"nineabyss/s2r","repo_kind":"official","path":"code/data_process_offline_rl.py","file_url":"https://github.com/nineabyss/s2r/blob/HEAD/code/data_process_offline_rl.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"79fec8bb0e1104b4"}},{"code_sha256_prefix":"ec228a2a8084ed7e","entry":"setup_chat_format","repo":"nineabyss/s2r","repo_kind":"official","path":"code/src/rloo_utils.py","file_url":"https://github.com/nineabyss/s2r/blob/HEAD/code/src/rloo_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ec228a2a8084ed7e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}