How does GPT-2 compute greater-than?: Interpreting mathematical abilities in a pre-trained language model

Pre-trained language models can be surprisingly adept at tasks they were not explicitly trained on, but how they implement these capabilities is poorly understood. In this paper, we investigate the basic mathematical abilities often acquired by pre-trained language models. Concretely, we use mechanistic interpretability techniques to explain the (limited) mathematical abilities of GPT-2 small. As a case study, we examine its ability to take in sentences such as "The war lasted from the year 1732 to the year 17", and predict valid two-digit end years (years > 32). We first identify a circuit, a small subset of GPT-2 small's computational graph that computes this task's output. Then, we explain the role of each circuit component, showing that GPT-2 small's final multi-layer perceptrons boost the probability of end years greater than the start year. Finally, we find related tasks that activate our circuit. Our results suggest that GPT-2 small computes greater-than using a complex but general mechanism that activates across diverse contexts.

Paper

References (53)

Scroll for more · 38 remaining

Similar papers

Peer review

Reviewer WeSY6/10 · confidence 4/52023-07-08

Summary

The paper attempts to improve our understanding on the source of a certain ability (the use of "greater than" in mathematical tasks) in LMs. To this end, the authors outlined a circuit in GPT-2 with interpretable structure and semantics, adding to the evidence that circuits are a useful way of understanding pre-trained LMs. Compared to existing work, the use of circuits is more fine-grained, and reveals special insights of such ability. The experiments are not only conducted on math tasks, but also extended to adjacent tasks that are also involved with "greater than" relations. Although there might be some concerns on whether these findings can be generalized to ever larger models, the reviewer still thinks it is a good paper as it shows a unique way to understand deep neural networks.

Strengths

1. Novel approach on understanding the ability of LMs. 2. Extensive experiments and clear presentation.

Weaknesses

1. The conclusion might be limited to certain model type (auto-regressive LMs such as GPT series). 2. Relatively narrow choice of tasks (only studying the "greater than" relationship).

Questions

Have you ever conducted experiments on "smaller than"? I'm curious about whether the findings are the mirrored version of "greater than", or they are total different from each other. If we can find some "semantic relationship" among the circuits, that will make such pipeline easier to be generalized.

Rating

6: Weak Accept: Technically solid, moderate-to-high impact paper, with no major concerns with respect to evaluation, resources, reproducibility, ethical considerations.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

4 excellent

Presentation

3 good

Contribution

4 excellent

Limitations

As mentioned in the Weakness section.

Reviewer BwzU6/10 · confidence 4/52023-07-11

Summary

This work investigates in depth the mechanism of GPT-2 small to compute the "greater than" function. Specifically, the work isolates a portion of the computational units that are causally related to making plausible predictions for inputs similar to: "The war lasted from 1731 to 17__" The isolation of computational units is done via a recent previously proposed method called "path patching". The resulting isolated subnetwork is shown to be necessary and approximately sufficient for making plausible predictions for this task. The authors also show that this subnetwork generalizes to other types of templates that require prediction of a greater number.

Strengths

- In-depth mechanistic analysis of a language model that would be of interest to some of the NeurIPS audience - Strong scientific validity. I appreciate that the authors thought through possible confounders and did extra experiments to validate their findings

Weaknesses

1. In the current format, the contributions of the current work are difficult to disentangle from previous work. The impact can be strengthened by clearly stating what the current work contributes above previous work, and by a detailed explanation of how a researcher can build on the analysis framework to investigate other emergent skills/properties of language models. 2. The work investigates only one model - GPT-2 small. Investigating additional models can help understand how these mechanisms emerge, and how they are influenced by scale and amount of training data.

Questions

Major: Q1. Related to weakness 2: Which part of the interpretability techniques are borrowed from previous work, and what is newly proposed here? How would a researcher interested in investigating a different function or a different model do this using the proposed framework? Q2. For the sufficiency and necessity experiments in Section 3.2: if the identified circuit is sufficient and necessary, then does it matter what input is provided to nodes outside of the circuit? How would providing random input to the nodes outside the circuit change the results, while providing the original dataset to the nodes inside the circuit? Q3. Which of the results do you expect to hold in larger GPT-2 variants, and how can the proposed analysis framework be used to investigate the emergence of properties at different scales of models / training data? Minor: - Fig 3 is difficult to understand on its own. The change in the direct connection between MLP 10 and the logits is difficult to spot between A and B. I recommend leaving the direct connection where it is in A but coloring it in a different color, and writing a more descriptive caption. Also the caption in C says that MLP11 receives input 01 but there are no direct or indirect arrows between the 01 input and MLP11. - Also it’s not quite clear what it means to “patch” a path. How does one ensure that the perturbed input that is provided to the patched MLP 10 does not influence all downstream components of MLP 10? - The use of footnotes is standard for NLP venues but not so much for ML venues. I personally find footnotes distracting. - L178: typo: “and and”

Rating

6: Weak Accept: Technically solid, moderate-to-high impact paper, with no major concerns with respect to evaluation, resources, reproducibility, ethical considerations.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

4 excellent

Presentation

2 fair

Contribution

3 good

Limitations

See Weaknesses

Reviewer GMC84/10 · confidence 5/52023-07-17

Summary

This paper explores how GPT-2 performs the ``greater-than'' operation by analyzing its circuit. The authors construct a template of the operation and define two scores to evaluate the performance of GPT-2. They first evaluate that the found circuit is indeed important for performing the greater-than operation, and then find that top MLP layers in GPT-2 compute the operation. --- Rebuttal response: Thanks for the detailed explanations. Some of my concerns about the details are addressed. Thus, I would like to raise the soundness score. Regarding the contribution, I agree that the method part under the mechanistic interpretability scenario is sufficient. However, the findings are not attractive to me. Thus, I will raise the score to 2. Regardless of whether the paper is accepted or not, I would like to suggest that the presentation could be improved.

Strengths

This paper explores a very interesting question for LM understanding: how LMs perform tasks inside its architecture. The analysis method, i.e., looking at the circuit of LM, is suitable for this kind of interpretation.

Weaknesses

1. The key contribution is not clear. This paper uses the existing analysis method for interpretation. But, to research the question (how LM performs math calculation), only a simple template and a toy task (greater-than operation) are discussed for GPT-2. There is a limited contribution to the analysis. Besides, for findings, such as GPT-2 performs the operation on top MLP layers, many existing works (e.g., probing works) have also found that, and existing findings are even more comprehensive. Thus, the contribution of this work is not clear. I would suggest that the authors should focus on one side (e.g., analysis method, interpretation task/data/template design) and dig deeper. 2. The presentation needs to be improved. The essential information should be clearly introduced and technical details could be moved to the appendix. For example, in section 2, it says that only single-token numbers are considered in this work (lines 65-72). We know that it is because of GPT-2's BPE tokenizer. There is no need to give specific examples for that. But for the dataset introduction, what's the size of it, how did you construct it (and why in that way), these parts are not well introduced. Besides, it would be better to use some tables in section 3 to make it more readable. 3. Generalization. As mentioned above, generalizing the analysis method to large LMs with more complex math problems is not intuitive. With different tokenizers (e.g., LLaMA tokenizer), the analysis template in this paper would fail. Besides, recent instruction-tuned LLMs may have very different conclusions compared to GPT-2.

Questions

Why the curve in the right figure of Figure 2 are continuous? Some tokens (e.g., 00) are not considered as described in the paper. (Line 81): Why mention ``GPT-2's training data''? Do you finetune GPT-2 or just use it in the zero-shot setting? (Line 87): This should be average instead of sum, right? Otherwise, it would not range from -1 to 1. (Line 305): Typo: there are double ``from''.

Rating

4: Borderline reject: Technically solid paper where reasons to reject, e.g., limited evaluation, outweigh reasons to accept, e.g., good evaluation. Please use sparingly.

Confidence

5: You are absolutely certain about your assessment. You are very familiar with the related work and checked the math/other details carefully.

Soundness

3 good

Presentation

1 poor

Contribution

2 fair

Limitations

Yes

Authorsrebuttal2023-08-16

Thank you for your update!

Thanks for your response—we’re glad to hear that you’re more convinced about the contributions and soundness of our work. We will revise our paper to improve its presentation and clarity as you suggest.

Reviewer eiM27/10 · confidence 3/52023-07-19

Summary

This paper presents an analysis on how the greater-than operator is implemented in the weights of GPT-2 small. They do so by tasking the model with completing sentences of the form "[something, e.g., a war or time period] lasted from $y_1$ to $y_2$" where $y_1, y_2$ are years. The idea is that GPT often assigns values $>y_1$ much higher probability than values $\leq y_1$, when trying to predict $y_2$. This is likely learned due to statistical co-occurrence, but the authors ask _what mechanism_ encodes this behavior in the weights.

Strengths

* The paper is well-written, easy to follow, and well-motivated. The explanations are clear, with limitations stated clearly. * I enjoyed the exposition of how the circuit was discovered and the interpretation of its semantics. * It's generally hard to find simple, easy-to-evaluate tasks that GPT-2 small is proficient at, so kudos here.

Weaknesses

Most of my "concerns" are really more aptly formulated as questions. Interpretability is still very nascent, and to me this kind of contribution is meaningful, in spite of (or actually because of) the many unanswered questions it raises. * I will say that I'm not 100% convinced by the argument at the end of Section 5, that this circuit is not using memorization and actually generalizes. It's hard to know what that means and to show it, especially on a small toy dataset with only four-digit numbers (really, two-digit completions). I think you'll need to demonstrate the same phenomenon on much larger datasets, as it's not super unlikely that the model could memorize the relationship between numbers from 0-99. You even show via ablation that the representational structure discovered by PCA is not a complete explanation. Maybe reframe these claims, or perhaps provide more convincing evidence? * I think you can _really_ nail the "so what" of the paper by showing how knowledge of this circuit can be used to improve the reliability of the greater-than operation. Do you think you could design a circuit by hand that outperforms the existing one on this task? Or modify the existing one? What would happen if you integrated it into the model? Can you move the circuit to another location? Why is the circuit the way it is?

Questions

* In Section 3.2: what does the PD look like when you give most of the network the 01-dataset but patch the regular dataset into a circuit _other than_ the one you discovered? Based on Figure 4 I'm guessing it'd be lower, but I don't have a great intuition for how much lower. * In Section 3.3: * Figures 6, 7 restrict the plotted tokens to the numbers. In absolute terms, were those numerical tokens promoted the most by the logit lens? Did you find any surprises, i.e., other tokens being ranked higher than numbers in inner product? * MLP 8 is interesting! What's going on with it? What does it mean for an MLP to contribute indirectly? What could it be doing? Relatedly, you might have answered this already, but do you have a better intuition for how MLPs 8-11 interact? Whether and why you can't just remove one of them? * What kinds of analyses did you have to come up with for this paper? I'm not very familiar with circuits; are most of the techniques here standard or did you have to come up with new tricks while, e.g., explaining the semantics of the circuit? How do these tricks generalize to other problems in interpretability?

Rating

7: Accept: Technically solid paper, with high impact on at least one sub-area, or moderate-to-high impact on more than one areas, with good-to-excellent evaluation, resources, reproducibility, and no unaddressed ethical considerations.

Confidence

3: You are fairly confident in your assessment. It is possible that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work. Math/other details were not carefully checked.

Soundness

3 good

Presentation

4 excellent

Contribution

2 fair

Limitations

n/a

Reviewer Nf2K6/10 · confidence 3/52023-07-28

Summary

The paper studies and tries to explain how GPT-2 (small) could be computing the mathematical operation of "greater than". A "circuit" (or a subgraph of GPT-2 model's computation graph) is identified by iteratively "patching" individual components to find which components are most responsible for making the correct prediction for this task. The main claim of the paper is that they identify this circuit and show that this circuit is used by GPT-2 small in other contexts that need the greater than operation.

Strengths

- The identification of circuits looks sound and an interesting approach. I enjoyed reading that part of the paper -- thank you. - The problem being tackled is very interesting, well motivated and some of the experimental results are really insightful

Weaknesses

Main Concerns: - The task formulation seems severely constrained. For instance, GPT-2 is prompted with the year prefix "XX" already given. Effectively, the approach is evaluating whether GPT-2 can perform 2-digit greater-than operation. - Even for the restricted case of year-span prediction task, I think it is important to compute correctness of the entire year string, without providing the XX prefix. Would the results hold in that case? I wonder how much probability mass GPT-2 will assign to the correct XX year token. This might significantly alter the "Prob Difference" metric and the results and conclusions. - The Prob difference metric might also be hiding inaccuracy of GPT-2 in generating the correct year. How often is it the case than GPT-2 assigns high prob to one of the correct answers in its top K tokens?. - I also think it is important to establish a "prior". What is the default behavior of the model when it is shown even simpler prompts that do not require the generation of a number greater than the given number. i.e. is GPT-2 predisposed to generating monotonically increasing numbers, even when the context doesn't need it to? - In a similar vein, a control task that prompts the model to generate a smaller number is needed to claim that GPT-2 can indeed perform the great-than operation. - The other main concern is the fact that each prompt-template yields a somewhat different circuit. The task posed in experiments in Section 5 are the same as the initial setup: predict a 4 digit year given the 2-digit prefix of the correct year. Given this, I do not think the results support the conclusion that gpt-2 has a generalized mechanism to perform greater-than across tasks and contexts. Minor: - While "emergent capabilities" have been used as motivation for this work, I am not sure if GPT-2 small's abilities can be referred to as "emergent". From what I understand, they are capabilities of much larger models. Moreover, next token prediction (how the main task in this paper is formulated) is well within the kinds of capabilities GPT-2 small was trained on. Overall, IMO, this is a very interesting line of work which can be made much stronger and conclusive with some additional experiments and analysis.

Questions

Minor: - In Fig 5, Did you intend to flip the instance coming from the actual vs 01-dataset? - Fig 6 is not legible. Please increase the font size - I don't think I understood what "input residual stream" meant. Please clarify.

Rating

6: Weak Accept: Technically solid, moderate-to-high impact paper, with no major concerns with respect to evaluation, resources, reproducibility, ethical considerations.

Confidence

3: You are fairly confident in your assessment. It is possible that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work. Math/other details were not carefully checked.

Soundness

2 fair

Presentation

4 excellent

Contribution

3 good

Limitations

-

Reviewer BwzU2023-08-14

Thanks for the response. The added clarifications re path patching and the contributions are helpful. To me the major limitation to how impactful this work will be remains the ease with which other researchers will be able to build on the interpretability approach proposed here. I urge the authors to include a more specific discussion of this in a future revision. Specifically statements like "one needs to define a task that the model can perform, with a corresponding dataset and metric." are not sufficient, and the characteristics of the desired datasets and metrics, with respect to the task, need to be discussed. That said, I do believe in the importance of the work, even if it ends up being a one-off scientific investigation.

Authorsrebuttal2023-08-16

Thanks for your response! We’re glad to hear that the clarifications were helpful, and that you believe in the importance of our work. We also value enabling others to build on our work. As part of this, we will release our code, included in the supplementary material. As suggested, we will also add details about how to choose tasks, metrics, and datasets, in order to aid future researchers. While we can’t upload revisions to our paper, we’re happy to share a rough outline of this information here. Let us know if you’ve got any other questions, and if there’s anything we can do to help you raise your score! --- ### Task Our path-patching approach is compatible with a variety of tasks. The chosen task should: 1. Have a clearly delimited set of correct and incorrect answers for each example. 2. Require only one forward pass of the model (as opposed to e.g. generation tasks which require multiple passes). 3. Be solvable by your model: if your model cannot solve the task, there may be no circuit. At minimum, the model should exhibit consistent behavior (even if it’s not exactly correct) Keep in mind that the granularity of insights will depend on the granularity of the task chosen. Complex tasks like natural language inference could require different (sub-)circuits depending on the specific question; it might be hard to find one precise circuit responsible for the task. Smaller, simpler tasks will likely yield easier to interpret results. For the purpose of this example, we’ll consider the task of fact retrieval. Each input will have an (ideally single-token) correct answer, which can be predicted with one forward pass. Moreover, it seems possible that facts are mostly stored / retrieved using the same circuit. ### Dataset Path-patching requires two datasets: a normal and corrupted dataset. The normal dataset is just a collection of examples/inputs for the task; its examples should: 1. Clearly indicate the task at hand. LMs perform language modeling, and do not natively perform other tasks; they may leak probability to answers that are not correct or incorrect, but simply task-irrelevant. Your inputs should push as much probability as possible onto the task's output space. 2. Allow evaluation based on only the distribution over possible next tokens (generated via one forward pass) 3. Be representative of your task. Your choice of datasets effectively define the scope of the phenomenon you study—make sure the scopes of your datasets and your intended task match! Each example from the normal dataset should have a corresponding corrupted example / input. The corrupted input should: 1. form a minimal pair with the normal input: they should differ minimally from each other (being the same length, and differing by only one or two tokens) 2. elicit a different model response, with a distinct correct answer, compared to the normal input 3. belong to the same sort of task. Remember that we locate the circuit by activating the same circuit with two different inputs. For fact retrieval, a normal input could be "Paris is the capital of"; the corrupted counterpart could be "Rome is the capital of". Both of these examples are reasonable input for fact retrieval, but the two will elicit very different responses. Note that an input like "Paris is in" would be less appropriate, because it doesn't clearly indicate that the task is fact retrieval, or what fact should be retrieved. ### Metric The metric is a function that takes in model logits and labels. It should: 1. Output a real number measuring model behavior / performance on the task. 2. Detect small changes in whether the model is behaving according to the normal or corrupted input, or somewhere in between. A continuous loss is thus preferable to metrics like 0-1 loss/accuracy. One family of metrics used in previous work is the probability assigned to the correct answer(s), minus the probability of the incorrect answer(s) induced by the corrupted input. In the greater-than case, this is p(y>YY) - p(y<=YY). For fact retrieval, we would compute p(France) - p(Italy). This family of metrics the model is implicitly sensitive to the model generating off-task output as this generally takes away from the probability of correct answers. It is explicitly sensitive to the probability of the corrupted input’s answer. Other metrics are possible. For example, if it is difficult to quantify task performance, but still possible to create minimal pairs, one could simply measure the KL-divergence between the original and (partially) patched / corrupted distributions. However, this is harder to interpret, and less targeted at your actual task of interest.

Reviewer Nf2K2023-08-18

Thank you for the response

Thanks for providing more details and clarifications. I appreciate this work and studying mathematical abilities of LMs is interesting. My comment re. the scope is not to say that "only greater-than is studied", but that "greater-than has been studied using a handful of prompts". This is why I think the results about generalization of the "greater-than" circuit are not completely supported. That said, I found the rest of the response helpful. I am happy to bump up my score a bit.

Reviewer WeSY2023-08-19

Thank you for the response!

Thank you for the response. I would like to keep my current rating.

Reviewer eiM22023-08-19

Thanks for all the care you put into this response, and the others as well! I'll adjust my score accordingly.

Program Chairsdecision2023-09-21

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC