mlsanityData to 7 Oct 2026

Case-Based or Rule-Based: How Do Transformers Do the Math?

arXiv 2402.17709 ↗First posted 27 Feb 2024cs.AI cs.CLcited by 26

Not on the map. Why?

Abstract (arXiv)

Despite the impressive performance in a variety of complex tasks, modern large language models (LLMs) still have trouble dealing with some math problems that are simple and intuitive for humans, such as addition. While we can easily learn basic rules of addition and apply them to new problems of any length, LLMs struggle to do the same. Instead, they may rely on similar cases seen in the training corpus for help. We define these two different reasoning mechanisms as "rule-based reasoning" and "case-based reasoning". Since rule-based reasoning is essential for acquiring systematic generalization ability, we aim to explore exactly whether transformers use rule-based or case-based reasoning for math problems. Through carefully designed intervention experiments on five math tasks, we confirm that transformers are performing case-based reasoning, no matter whether scratchpad is used, which aligns with the previous observations that transformers use subgraph matching/shortcut learning to reason. To mitigate such problems, we propose a Rule-Following Fine-Tuning (RFFT) technique to teach transformers to perform rule-based reasoning. Specifically, we provide explicit rules in the input and then instruct transformers to recite and follow the rules step by step. Through RFFT, we successfully enable LLMs fine-tuned on 1-5 digit addition to generalize to up to 12-digit addition with over 95% accuracy, which is over 40% higher than scratchpad. The significant improvement demonstrates that teaching LLMs to use rules explicitly helps them learn rule-based reasoning and generalize better in length.

Key facts. Cited by 26 papers in the map (data through 7 Oct 2026). Builds on 20 of its 32 references that are in the map. First posted on arXiv 27 Feb 2024.

Builds on

20 of 32 references.

References · 20

  1. 2020Language Models are Few-Shot Learnerscited by 32,199
  2. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
  3. 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
  4. 2022Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language modelscited by 1,970
  5. 2022Least-to-Most Prompting Enables Complex Reasoning in Large Language Modelscited by 1,397
  6. 2023FActScore: Fine-grained Atomic Evaluation of Factual Precision in Long Form Text Generationcited by 1,259
  7. 2022LaMDA: Language Models for Dialog Applicationscited by 1,218
  8. 2022Transformers learn in-context by gradient descentcited by 714
  9. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
  10. 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
  11. 2022Decomposed Prompting: A Modular Approach for Solving Complex Taskscited by 554
  12. 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 404
8 more
  1. 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 319
  2. 2023Reasoning or Reciting? Exploring the Capabilities and Limitations of Language Models Through Counterfactual Taskscited by 243
  3. 2022Exploring Length Generalization in Large Language Modelscited by 204
  4. 2022Why Can GPT Learn In-Context? Language Models Implicitly Perform Gradient Descent as Meta-Optimizerscited by 204
  5. 2023LooGLE: Can Long-Context Language Models Understand Long Contexts?cited by 200
  6. 2023ChatGPT is a Knowledgeable but Inexperienced Solver: An Investigation of Commonsense Problem in Large Language Modelscited by 63
  7. 2023Towards a Mechanistic Interpretation of Multi-Step Reasoning Capabilities of Language Modelscited by 50
  8. 2023Parrot Mind: Towards Explaining the Complex Task Reasoning of Pretrained Large Language Models with Template-Content Structurecited by 3

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 11; 2025: 9; 2026: 6.

26 papers.

Sort:

By area:

  1. 2024How Far is Video Generation from World Model: A Physical Law Perspectivecited by 204
  2. 2024Number Cookbook: Number Understanding of Language Models and How to Improve Itcited by 41
  3. 2024Do Vision-Language Models Really Understand Visual Language?cited by 29
  4. 2024Universal Length Generalization with Turing Programscited by 25
  5. 2024Beyond Instruction Following: Evaluating Inferential Rule Following of Large Language Modelscited by 23
  6. 2025The Reasoning-Memorization Interplay in Language Models Is Mediated by a Single Directioncited by 21
  7. 2024Embedding Trajectory for Out-of-Distribution Detection in Mathematical Reasoningcited by 18
  8. 2024Initialization is Critical to Whether Transformers Fit Composite Functions by Reasoning or Memorizingcited by 15
  9. 2024RuleRAG: Rule-Guided Retrieval-Augmented Generation with Language Models for Question Answeringcited by 13
  10. 2024MathGAP: Out-of-Distribution Evaluation on Problems with Arbitrarily Complex Proofscited by 12
  11. 2025The Role of Sparsity for Length Generalization in Transformerscited by 8
  12. 2025Beyond Single-Task: Robust Multi-Task Length Generalization for LLMscited by 7
14 more
  1. 2025Mixture-of-Experts Can Surpass Dense LLMs Under Strictly Equal Resourcecited by 7
  2. 2024Smart Vision-Language Reasonerscited by 5
  3. 2025Physically Ground Commonsense Knowledge for Articulated Object Manipulation with Analytic Conceptscited by 5
  4. 2024Executing Arithmetic: Fine-Tuning Large Language Models as Turing Machinescited by 3
  5. 2026Barriers to Discrete Reasoning with Transformers: A Survey Across Depth, Exactness, and Bandwidthcited by 3
  6. 2026Input Pathways Shape Few-Shot, Not Zero-Shot, Binding in Tiny Transformers: A Fully-Enumerable Studycited by 2
  7. 2025Reasoning is Periodicity? Improving Large Language Models Through Effective Periodicity Modelingcited by 1
  8. 2025Two Causally Related Needles in a Video Haystackcited by 1
  9. 2025Unveiling the Learning Mind of Language Models: A Cognitive Framework and Empirical Studycited by 1
  10. 2026BAPS: A Fine-Grained Low-Precision Scheme for Softmax in Attention via Block-Aware Precision reScalingcited by 1
  11. 2026Diagnosing CFG Interpretation in LLMscited by 1
  12. 2025When Do Symbolic Solvers Enhance Reasoning in Large Language Models?cited by 0
  13. 2026SubTokenTest: A Practical Benchmark for Real-World Sub-token Understandingcited by 0
  14. 2026Do Transformers Have the Ability for Periodicity Generalization?cited by 0