{"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/understanding-the-reasoning-ability-of","title":"Understanding Reasoning Ability of Language Models From the Perspective of Reasoning Paths Aggregation","arxiv_id":"2402.03268","date":"2024-02-05","proceeding":null,"authors":["Xinyi Wang","Alfonso Amayuelas","Kexun Zhang","Liangming Pan","Wenhu Chen","William Yang Wang"],"abstract":"Pre-trained language models (LMs) are able to perform complex reasoning without explicit fine-tuning. To understand how pre-training with a next-token prediction objective contributes to the emergence of such reasoning capability, we propose that we can view an LM as deriving new conclusions by aggregating indirect reasoning paths seen at pre-training time. We found this perspective effective in two important cases of reasoning: logic reasoning with knowledge graphs (KGs) and chain-of-thought (CoT) reasoning. More specifically, we formalize the reasoning paths as random walk paths on the knowledge/reasoning graphs. Analyses of learned LM distributions suggest that a weighted sum of relevant random walk path probabilities is a reasonable way to explain how LMs reason. Experiments and analysis on multiple KG and CoT datasets reveal the effect of training on random walk paths and suggest that augmenting unlabeled random walk reasoning paths can improve real-world multi-step reasoning performance. code: https://github.com/WANGXinyiLinda/LM_random_walk","url_abs":"https://arxiv.org/abs/2402.03268v3","url_pdf":"https://arxiv.org/pdf/2402.03268v3.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":"understanding-the-reasoning-ability-of","repo_url":"https://github.com/wangxinyilinda/lm_random_walk","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"knowledge-graphs","task_name":"Knowledge Graphs"},{"task_slug":"math","task_name":"Math"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2402.03268","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.03268"}},"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/wangxinyilinda/lm_random_walk","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":6,"unverified":4},"by_repo_kind":{"official":{"samples":10,"ran":6,"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":"bd677ad1a63e9ad4","entry":"KL","repo":"wangxinyilinda/lm_random_walk","repo_kind":"official","path":"kg_reasoning/analysis.py","file_url":"https://github.com/wangxinyilinda/lm_random_walk/blob/HEAD/kg_reasoning/analysis.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"bd677ad1a63e9ad4"}},{"code_sha256_prefix":"0b845d4db5d929b1","entry":"aggragate","repo":"wangxinyilinda/lm_random_walk","repo_kind":"official","path":"kg_reasoning/analysis.py","file_url":"https://github.com/wangxinyilinda/lm_random_walk/blob/HEAD/kg_reasoning/analysis.py","link_basis":"first_harvest_node","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":"0b845d4db5d929b1"}},{"code_sha256_prefix":"25d344d4b993934e","entry":"eval_with_timeout","repo":"wangxinyilinda/lm_random_walk","repo_kind":"official","path":"cot_reasoning/calculator.py","file_url":"https://github.com/wangxinyilinda/lm_random_walk/blob/HEAD/cot_reasoning/calculator.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"25d344d4b993934e"}},{"code_sha256_prefix":"7965884ea488bbf9","entry":"make_random_walk_data_module","repo":"wangxinyilinda/lm_random_walk","repo_kind":"official","path":"cot_reasoning/load_data/random_walk_dataset.py","file_url":"https://github.com/wangxinyilinda/lm_random_walk/blob/HEAD/cot_reasoning/load_data/random_walk_dataset.py","link_basis":"first_harvest_node","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":"7965884ea488bbf9"}},{"code_sha256_prefix":"47f22a2c40d83dba","entry":"model_name_mapping","repo":"wangxinyilinda/lm_random_walk","repo_kind":"official","path":"cot_reasoning/model/utils.py","file_url":"https://github.com/wangxinyilinda/lm_random_walk/blob/HEAD/cot_reasoning/model/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"47f22a2c40d83dba"}},{"code_sha256_prefix":"9c493833053fbfe2","entry":"parse_outputs","repo":"wangxinyilinda/lm_random_walk","repo_kind":"official","path":"kg_reasoning/analysis.py","file_url":"https://github.com/wangxinyilinda/lm_random_walk/blob/HEAD/kg_reasoning/analysis.py","link_basis":"first_harvest_node","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":"9c493833053fbfe2"}},{"code_sha256_prefix":"d6fb9c5bed407a12","entry":"make_sparse_mask","repo":"wangxinyilinda/lm_random_walk","repo_kind":"official","path":"cot_reasoning/model/generation_utils.py","file_url":"https://github.com/wangxinyilinda/lm_random_walk/blob/HEAD/cot_reasoning/model/generation_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":"d6fb9c5bed407a12"}},{"code_sha256_prefix":"f7c8ecc9fe3dc748","entry":"safe_str","repo":"wangxinyilinda/lm_random_walk","repo_kind":"official","path":"cot_reasoning/model/my_trainer.py","file_url":"https://github.com/wangxinyilinda/lm_random_walk/blob/HEAD/cot_reasoning/model/my_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":"f7c8ecc9fe3dc748"}},{"code_sha256_prefix":"9fffb425547e2bb7","entry":"sample","repo":"wangxinyilinda/lm_random_walk","repo_kind":"official","path":"cot_reasoning/calculator.py","file_url":"https://github.com/wangxinyilinda/lm_random_walk/blob/HEAD/cot_reasoning/calculator.py","link_basis":"first_harvest_node","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":"9fffb425547e2bb7"}},{"code_sha256_prefix":"aa8243de687a96f5","entry":"use_calculator","repo":"wangxinyilinda/lm_random_walk","repo_kind":"official","path":"cot_reasoning/calculator.py","file_url":"https://github.com/wangxinyilinda/lm_random_walk/blob/HEAD/cot_reasoning/calculator.py","link_basis":"first_harvest_node","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":"aa8243de687a96f5"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}