{"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/arithmetic-without-algorithms-language-models","title":"Arithmetic Without Algorithms: Language Models Solve Math With a Bag of Heuristics","arxiv_id":"2410.21272","date":"2024-10-28","proceeding":null,"authors":["Yaniv Nikankin","Anja Reusch","Aaron Mueller","Yonatan Belinkov"],"abstract":"Do large language models (LLMs) solve reasoning tasks by learning robust generalizable algorithms, or do they memorize training data? To investigate this question, we use arithmetic reasoning as a representative task. Using causal analysis, we identify a subset of the model (a circuit) that explains most of the model's behavior for basic arithmetic logic and examine its functionality. By zooming in on the level of individual circuit neurons, we discover a sparse set of important neurons that implement simple heuristics. Each heuristic identifies a numerical input pattern and outputs corresponding answers. We hypothesize that the combination of these heuristic neurons is the mechanism used to produce correct arithmetic answers. To test this, we categorize each neuron into several heuristic types-such as neurons that activate when an operand falls within a certain range-and find that the unordered combination of these heuristic types is the mechanism that explains most of the model's accuracy on arithmetic prompts. Finally, we demonstrate that this mechanism appears as the main source of arithmetic accuracy early in training. Overall, our experimental results across several LLMs show that LLMs perform arithmetic using neither robust algorithms nor memorization; rather, they rely on a \"bag of heuristics\".","url_abs":"https://arxiv.org/abs/2410.21272v2","url_pdf":"https://arxiv.org/pdf/2410.21272v2.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":"arithmetic-without-algorithms-language-models","repo_url":"https://github.com/technion-cs-nlp/llm-arithmetic-heuristics","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"jax","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"arithmetic-reasoning","task_name":"Arithmetic Reasoning"},{"task_slug":"math","task_name":"Math"},{"task_slug":"memorization","task_name":"Memorization"}],"methods":[{"method_slug":"set","method_name":"SET"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2410.21272","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.21272"}},"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/technion-cs-nlp/llm-arithmetic-heuristics","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":6},"by_repo_kind":{"official":{"samples":6,"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":0,"samples":[{"code_sha256_prefix":"9fe2ffb255572164","entry":"analyzed_operand_pairs_factor","repo":"technion-cs-nlp/llm-arithmetic-heuristics","repo_kind":"official","path":"heuristics_classification.py","file_url":"https://github.com/technion-cs-nlp/llm-arithmetic-heuristics/blob/HEAD/heuristics_classification.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":"9fe2ffb255572164"}},{"code_sha256_prefix":"94fe006567da0e7b","entry":"get_neurons_associated_with_prompt","repo":"technion-cs-nlp/llm-arithmetic-heuristics","repo_kind":"official","path":"heuristics_analysis.py","file_url":"https://github.com/technion-cs-nlp/llm-arithmetic-heuristics/blob/HEAD/heuristics_analysis.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":"94fe006567da0e7b"}},{"code_sha256_prefix":"a58cf7d7df7ace19","entry":"is_associated_heuristic","repo":"technion-cs-nlp/llm-arithmetic-heuristics","repo_kind":"official","path":"heuristics_analysis.py","file_url":"https://github.com/technion-cs-nlp/llm-arithmetic-heuristics/blob/HEAD/heuristics_analysis.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":"a58cf7d7df7ace19"}},{"code_sha256_prefix":"7a48cc020e8d747c","entry":"is_both_operands_m_mod_n_neuron","repo":"technion-cs-nlp/llm-arithmetic-heuristics","repo_kind":"official","path":"heuristics_classification.py","file_url":"https://github.com/technion-cs-nlp/llm-arithmetic-heuristics/blob/HEAD/heuristics_classification.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":"7a48cc020e8d747c"}},{"code_sha256_prefix":"601f73c93e0a718d","entry":"is_operand_m_mod_n_neuron","repo":"technion-cs-nlp/llm-arithmetic-heuristics","repo_kind":"official","path":"heuristics_classification.py","file_url":"https://github.com/technion-cs-nlp/llm-arithmetic-heuristics/blob/HEAD/heuristics_classification.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":"601f73c93e0a718d"}},{"code_sha256_prefix":"d8cdff520621918b","entry":"predict_answer","repo":"technion-cs-nlp/llm-arithmetic-heuristics","repo_kind":"official","path":"general_utils.py","file_url":"https://github.com/technion-cs-nlp/llm-arithmetic-heuristics/blob/HEAD/general_utils.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":"d8cdff520621918b"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}