{"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/arxiv-2508-15868","title":"CARFT: Boosting LLM Reasoning via Contrastive Learning with Annotated Chain-of-Thought-based Reinforced Fine-Tuning","arxiv_id":"2508.15868","date":"2025-08-21","proceeding":"EMNLP","authors":["Wenqiao Zhu","Ji Liu","Rongjuncheng Zhang","Haipang Wu","Yulun Zhang"],"abstract":"Reasoning capability plays a significantly critical role in the the broad applications of Large Language Models (LLMs). To enhance the reasoning performance of LLMs, diverse Reinforcement Learning (RL)-based fine-tuning approaches have been proposed to address the limited generalization capability of LLMs trained solely via Supervised Fine-Tuning (SFT). Despite their effectiveness, two major limitations hinder the advancement of LLMs. First, vanilla RL-based approaches ignore annotated Chain-of-Thought (CoT) and incorporate unstable reasoning path sampling, which typically results in model collapse, unstable training process, and suboptimal performance. Second, existing SFT approaches generally overemphasize the annotated CoT, potentially leading to performance degradation due to insufficient exploitation of potential CoT. In this paper, we propose a Contrastive learning with annotated CoT-based Reinforced Fine-Tuning approach, i.e., \\TheName{}, to enhance the reasoning performance of LLMs while addressing the aforementioned limitations. Specifically, we propose learning a representation for each CoT. Based on this representation, we design novel contrastive signals to guide the fine-tuning process. Our approach not only fully exploits the available annotated CoT but also stabilizes the fine-tuning procedure by incorporating an additional unsupervised learning signal. We conduct comprehensive experiments and in-depth analysis with three baseline approaches, two foundation models, and two datasets to demonstrate significant advantages of \\TheName{} in terms of robustness, performance (up to 10.15\\%), and efficiency (up to 30.62\\%). Code is available at https://github.com/WNQzhu/CARFT.","url_abs":"https://arxiv.org/abs/2508.15868","url_pdf":"https://arxiv.org/pdf/2508.15868","source":{"archive":null,"snapshot":"2025-07-28","note":"not in the Papers with Code archive (frozen at the snapshot)","row_kind":"graph","title_abstract_authors_date":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)"},"code_links":[],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2508.15868","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2508.15868"}},"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":[{"mentioned_in_github":null,"is_official":null,"provenance":"deterministic:regex_extraction","mentioned_in_paper":null,"url":"https://github.com/WNQzhu/CARFT","reach":{"status":"ok"}}],"summary":{"unverified":21},"by_repo_kind":{"found_in_text":{"samples":21,"ran":0,"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":21,"samples":[{"code_sha256_prefix":"2bb5bd3526f55ecb","entry":"collate_fn","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/sampling.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/sampling.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":"2bb5bd3526f55ecb"}},{"code_sha256_prefix":"32851be78f5ecd4c","entry":"do_gather","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/src/utils.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/src/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":"32851be78f5ecd4c"}},{"code_sha256_prefix":"7fcae9f5e120bafe","entry":"eval_code","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/src/python_engine.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/src/python_engine.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":"7fcae9f5e120bafe"}},{"code_sha256_prefix":"c8164df09b7d7a68","entry":"evaluate_rerank","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/train_reward_model.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/train_reward_model.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":"c8164df09b7d7a68"}},{"code_sha256_prefix":"d19fa71dac29272a","entry":"extract","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/parse/parse_qr.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/parse/parse_qr.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":"d19fa71dac29272a"}},{"code_sha256_prefix":"f21a5f0d5bae0c14","entry":"floatify","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/src/utils.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/src/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":"f21a5f0d5bae0c14"}},{"code_sha256_prefix":"38b19bc8cb4f088b","entry":"hotmap_tex","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/parse/gen_hotmap_tex.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/parse/gen_hotmap_tex.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":"38b19bc8cb4f088b"}},{"code_sha256_prefix":"c3b86a3bceec86cd","entry":"is_numeric","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/src/utils.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/src/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":"c3b86a3bceec86cd"}},{"code_sha256_prefix":"0e659750d9f0ed7c","entry":"parse_gen_log","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/parse/parse_qr.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/parse/parse_qr.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":"0e659750d9f0ed7c"}},{"code_sha256_prefix":"847bf603df6fa258","entry":"parse_myacc_log","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/eval/parse_log.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/eval/parse_log.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":"847bf603df6fa258"}},{"code_sha256_prefix":"da9bd1e1dc9932a9","entry":"parse_reft_loss","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/eval/parse_log.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/eval/parse_log.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":"da9bd1e1dc9932a9"}},{"code_sha256_prefix":"a44a508945459d5c","entry":"parse_train_log","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/eval/parse_log.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/eval/parse_log.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":"a44a508945459d5c"}},{"code_sha256_prefix":"4d434f6e5fd591b5","entry":"prepare_datasets_and_data_loaders","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/train_reward_model.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/train_reward_model.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":"4d434f6e5fd591b5"}},{"code_sha256_prefix":"2df5a69f894bc2b7","entry":"prepare_datasets_and_data_loaders","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/train_sft_model.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/train_sft_model.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":"2df5a69f894bc2b7"}},{"code_sha256_prefix":"9f0489fe01df9539","entry":"prepare_datasets_and_data_loaders","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/train_sl_model.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/train_sl_model.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":"9f0489fe01df9539"}},{"code_sha256_prefix":"449e6a4081f8d019","entry":"prepare_datasets_and_data_loaders","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/train_rl_reft.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/train_rl_reft.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":"449e6a4081f8d019"}},{"code_sha256_prefix":"01e9a5c8f882c073","entry":"prepare_datasets_and_data_loaders","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/train_rl_sl.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/train_rl_sl.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":"01e9a5c8f882c073"}},{"code_sha256_prefix":"8b9f60df8d2c8a82","entry":"process_code","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/src/python_engine.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/src/python_engine.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":"8b9f60df8d2c8a82"}},{"code_sha256_prefix":"ac6a453c49c69110","entry":"rgb_and_word","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/parse/gen_hotmap_tex.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/parse/gen_hotmap_tex.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":"ac6a453c49c69110"}},{"code_sha256_prefix":"951fe709737c50b9","entry":"tokenize_fn","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/sampling.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/sampling.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":"951fe709737c50b9"}},{"code_sha256_prefix":"d3b8681876990bfa","entry":"train_one_epoch","repo":"WNQzhu/CARFT","repo_kind":"found_in_text","path":"code/mwp_ReFT/train_reward_model.py","file_url":"https://github.com/WNQzhu/CARFT/blob/HEAD/code/mwp_ReFT/train_reward_model.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":"d3b8681876990bfa"}}]},"arxiv_metadata":{"licence":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)","fields":["title","abstract","authors","date"],"primary_category":"cs.CL","source":"arxiv_api"},"syntology_extracted_results":null}