Interpreting Arithmetic Mechanism in Large Language Models through Comparative Neuron Analysis

Zeping Yu, Sophia Ananiadou
9/21/2024
cs.CL

Official code: zepingyu0512/arithmetic-mechanism (12 stars, last commit 2024-11-17).

Abstract

We find arithmetic ability resides within a limited number of attention heads, with each head specializing in distinct operations. To delve into the reason, we introduce the Comparative Neuron Analysis (CNA) method, which identifies an internal logic chain consisting of four distinct stages from input to prediction: feature enhancing with shallow FFN neurons, feature transferring by shallow attention layers, feature predicting by arithmetic heads, and prediction enhancing among deep FFN neurons. Moreover, we identify the human-interpretable FFN neurons within both feature-enhancing and feature-predicting stages. These findings lead us to investigate the mechanism of LoRA, revealing that it enhances prediction probabilities by amplifying the coefficient scores of FFN neurons related to predictions. Finally, we apply our method in model pruning for arithmetic tasks and model editing for reducing gender bias. Code is on https://github.com/zepingyu0512/arithmetic-mechanism.

View on arXivView PDF

Code Implementations(1)

code for EMNLP 2024 paper: Interpreting Arithmetic Mechanism in Large Language Models through Comparative Neuron Analysis

122Python, Jupyter NotebookSep 21, 20241 years ago

Similar Papers

Cite this paper

@article{yu2024interpreting,
  title  = {Interpreting Arithmetic Mechanism in Large Language Models through Comparative Neuron Analysis},
  author = {Zeping Yu and Sophia Ananiadou},
  year   = {2024},
  eprint = {2409.14144},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2409.14144v1}
}

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/2409.14144.svg)](https://codeofpaper.com/paper/2409.14144)

Discussion