Math Neurosurgery: Isolating Language Models' Math Reasoning Abilities Using Only Forward Passes

Bryan R. Christ, Zack Gottesman, Jonathan Kropko, Thomas Hartvigsen
10/22/2024
15 citations
cs.CLcs.AI

Official code: bryanchrist/MathNeuro (25 stars, Python, GPL-3.0, last commit 2025-06-15).

Abstract

Math reasoning is an active area of Large Language Model (LLM) research because it is a hallmark of artificial intelligence and has implications in several domains, including math education. However, few works have explored how math reasoning is encoded within LLM parameters and if it is a skill that can be isolated within models.

Show full abstract

Doing so could allow targeted intervention to improve math performance without altering non-math behavior and foster understanding of how models encode math reasoning. We introduce Math Neurosurgery (MathNeuro), a computationally efficient method we use to isolate math-specific parameters in LLMs using only forward passes. MathNeuro builds on existing work by using weights and activations to calculate parameter importance, but isolates math-specific parameters by filtering out those important for general language tasks. Through pruning parameters MathNeuro identifies, we delete a LLM's math reasoning ability without significantly impacting its general language ability. Scaling the identified parameters by a small constant improves a pretrained or instruction-tuned LLM's performance by 4-17% on GSM8K and 5-35% on MATH while leaving non-math behavior unaltered. MathNeuro is also data efficient: most of its effectiveness holds when identifying math-specific parameters using a single sample. MathNeuro highlights the potential for future work to intervene on math-specific parameters.

View on arXivView PDF

Code Implementations(1)

GPL-3.0

Codebase for Math Neurosurgery: Isolating LLMs' Math Reasoning Abilities Using Only Forward Passes

255Python, C++Oct 10, 20241 years agoGPL-3.0

Similar Papers

Cite this paper

@article{christ2024math,
  title  = {Math Neurosurgery: Isolating Language Models' Math Reasoning Abilities Using Only Forward Passes},
  author = {Bryan R. Christ and Zack Gottesman and Jonathan Kropko and Thomas Hartvigsen},
  year   = {2024},
  eprint = {2410.16930},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.16930v4}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.16930.svg)](https://codeofpaper.com/paper/2410.16930)

Discussion