Locating and Editing Factual Associations in GPT
Abstract
We analyze the storage and recall of factual associations in autoregressive transformer language models, finding evidence that these associations correspond to localized, directly-editable computations.
We first develop a causal intervention for identifying neuron activations that are decisive in a model’s factual predictions.
This reveals a distinct set of steps in middle-layer feed-forward modules that mediate factual predictions while processing subject tokens.
To test our hypothesis that these computations correspond to factual association recall, we modify feedforward weights to update specific factual associations using Rank-One Model
Editing (ROME).
We find that ROME is effective on a standard zero-shot relation extraction (zsRE) model-editing task.
We also evaluate ROME on a new dataset of difficult counterfactual assertions, on which it simultaneously maintains both specificity and generalization, whereas other methods sacrifice one or another.
Our results confirm an important role for mid-layer feed-forward modules in storing factual associations and suggest that direct manipulation of computational mechanisms may be a feasible approach for model editing.
The code, dataset, visualizations, and an interactive demo notebook are available at https://rome.baulab.info/ .
Introduction
Where does a large language model store its facts?
In this paper, we report evidence that factual associations in GPT are a localized computation that can be directly edited.
Large language models can predict factual statements about the world (Petroni et al., 2019; Jiang et al., 2020; Roberts et al., 2020).
For example, given the prefix “ The Space Needle is located in the city of ,” GPT will reliably predict the true answer: “ Seattle ” (Figure 1a).
Factual knowledge has been observed to emerge in both autoregressive GPT models (Radford et al., 2019; Brown et al., 2020) and masked BERT models (Devlin et al., 2019).
We investigate how such factual associations are stored within GPT-style autoregressive transformer models.
Many of the largest neural networks in use today are autoregressive, yet the way that they store knowledge remains under-explored: some research has been done for masked models (Petroni et al., 2019;
Jiang et al., 2020; Elazar et al., 2021a; Geva et al., 2021; Dai et al., 2021; De Cao et al., 2021), but GPT has architectural differences such as unidirectional attention and generation capabilities that provide an opportunity for new insights.
In this paper, we trace the causal effects of hidden states within GPT using causal mediation analysis (Pearl, 2001; Vig et al., 2020b), in order to identify the specific modules that mediate recall of a fact about a subject (Figure 1).
Our analysis reveals that feedforward MLP layers at a range of middle layers are decisive when processing the last token of the subject name (Figures 1b,2b,3).
We test this finding in a second way by introducing a Rank-One Model Editing method (ROME) to alter the parameters that determine a feedfoward layer’s behavior at the decisive token.
Despite
Seattle (correct output) downtown in is le
Need
Space
The Cleanrun (a)
Corruptedsubjectrun (b)
Patch clean states (c) downtown in is le*
Need*
Space*
The* * * * * ? (corrupted output) h i(l) state attentionMLP
Note when output is fixed (d) example flow * corruptedembedding
[Figure]
the simplicity of the intervention, we find that ROME is similarly effective to other model-editing approaches on a standard zero-shot relation extraction benchmark (Section 3.2).
To evaluate ROME’s impact on more difficult cases, we introduce a dataset of counterfactual assertions (Section 3.3) that would not have been observed in pretraining.
Our evaluations (Section 3.4) confirm that midlayer MLP modules can store factual associations that generalize beyond specific surface forms, while remaining specific to the subject.
Compared to previous fine-tuning (Zhu et al., 2020), interpretability-based (Dai et al., 2021), and meta-learning (Mitchell et al., 2021; De Cao et al., 2021) methods, we find that ROME is able to achieve good generalization and specificity simultaneously, whereas previous approaches sacrifice one or the other.
Interventions on Activations for Tracing Information Flow
To locate facts within the parameters of a large pretrained autoregressive transformer, we begin by analyzing and identifying the specific hidden states that have the strongest causal effect on predictions of individual facts.
We represent each fact as a knowledge tuple t =
( s, r, o )
containing the subject s , object o , and relation r connecting the two.
Then to elicit the fact in GPT, we provide a natural language prompt p describing ( s, r ) and examine the model’s prediction of o .
An autoregressive transformer language model G : X → Y over vocabulary V maps a token sequence x = [ x 1 , ..., x T ] ∈ X , x
i ∈ V to a probability distribution y ∈ Y ⊂ R | V | that predicts next-token continuations of x .
Within the transformer, the i th token is embedded as a series of hidden state vectors h ( l ) i , beginning with h (0) i
= emb
( x i ) + pos( i ) ∈ R H .
The final output y = decode( h ( L ) T ) is read from the last hidden state.
We visualize the internal computation of G as a grid (Figure 1a) of hidden states h ( l ) i in which each layer l (left → right) adds global attention a ( l ) i and local MLP m ( l ) i contributions computed from previous layers, and where each token i (top → bottom) attends to previous states from other tokens.
Recall that, in the autoregressive case, tokens only draw information from past (above) tokens:
[Equation]
[Figure]
Detail in Figure
[Figure]
Our main focus will be on MLP components rather than attention.
3 Each layer’s MLP is a twolayer neural network parameterized by matrices W ( l ) proj and W ( l ) fc , with rectifying nonlinearity σ and normalizing nonlinearity γ .
For further background on transformers we refer to Vaswani et al.
2.1 Causal Tracing of Factual Associations
The grid of states (Figure 1) forms a causal graph (Pearl, 2009) describing dependencies between the hidden variables.
This graph contains many paths from inputs on the left to the output (next-word prediction) at the lower-right, and we wish to understand if there are specific hidden state variables that are more important than others when recalling a fact.
As Vig et al.
(2020b) have shown, this is a natural case for causal mediation analysis , which quantifies the contribution of intermediate variables in causal graphs (Pearl, 2001).
To calculate each state’s contribution towards a correct factual prediction, we observe all of G ’s internal activations during three runs: a clean run that predicts the fact, a corrupted run where the prediction is damaged, and a corrupted-with-restoration run that tests the ability of a single state to restore the prediction.
• In the clean run , we pass a factual prompt x into G and collect all hidden activations { h ( l ) i | i ∈ [1 , T ] , l ∈ 1 , L
Figure 1a
provides an example illustration with the prompt: “The Space Needle is in downtown ”, for which the expected completion is o = “Seattle”. • In the baseline corrupted run , the subject is obfuscated from G before the network runs.
Concretely, immediately after x is embedded as [ h (0)1 , h (0)2 , . . , h (0) T ] , we set h (0)
i = h (0) i + ϵ for all indices i that correspond to the subject entity, where ϵ ∼ N (0; ν ) 4 ; . G is then allowed to continue normally, giving us a set of corrupted activations { h ( l ) i ∗ | i ∈
[1 , T ] , l ∈ [1 , L ] } . Because G loses some information about the
subject , it will likely return an incorrect answer (Figure 1b). • The corrupted-with-restoration run , lets G run computations on the noisy embeddings as in the corrupted baseline, except at some token
ˆ i and layer ˆ l . There, we hook G so that it is forced to output the clean state h (ˆ l ) ˆ i ; future computations execute without further intervention. Intuitively, the ability of a few clean states to recover the correct fact, despite many other states being corrupted by the obfuscated subject, will indicate their causal importance in the computation graph
Let P [ o ] , P ∗ [ o ] , and P ∗ , clean h ( l ) i [ o ] denote the probability of emitting o under the clean, corrupted, and corrupted-with-restoration runs, respectively; dependence on the input x is omitted for notational simplicity.
The total effect (TE) is the difference between these quantities:
TE = P [ o ] − P ∗ [ o ] .
The indirect effect (IE) of a specific mediating state h ( l ) i is defined as the difference between the probability of o under the corrupted version and the probability when that state is set to its clean version, while the subject remains corrupted: IE = P ∗ , clean h ( l ) i
[ o ] − P ∗ [ o ] .
Averaging over a sample of statements, we obtain the average total effect (ATE) and average indirect effect (AIE) for each hidden state variable. le* h is le* * * Need* *
Need* * (b) corrupted input w/ clean h i(l) (a) baseline corrupted input condition [Figure] (c) ! ! Layer (
[Figure]
[Figure]
[Figure]
[Figure] output 2.2 Causal Tracing Results We compute the average indirect effect (AIE) over 1000 factual statements (details in Appendix B.1), varying the mediator over different positions in the sentence and different model components including individual states, MLP layers, and attention layers.
Figure 2 plots the AIE of the internal components of GPT-2 XL (1.5B parameters).
The ATE of this experiment is 18.6%, and we note that a large portion of the effect is mediated by strongly causal individual states (AIE=8.7% at layer 15) at the last subject token.
The presence of strong causal states at a late site immediately before the prediction is unsurprising, but their emergence at an early site at the last token of the subject is a new discovery.
Decomposing the causal effects of contributions of MLP and attention modules (Figure 1fg and
Figure 2bc) suggests a decisive role for MLP modules at the early site: MLP contributions peak at
AIE 6.6%, while attention at the last subject token is only AIE 1.6%
; attention is more important at the last token of the prompt.
Appendix B.2 further discusses this decomposition.
Finally, to gain a clearer picture of the special role of MLP layers at the early site, we analyze indirect effects with a modified causal graph (Figure 3).
(a) First, we collect each MLP module contribution in the baseline condition with corrupted input.
(b) Then, to isolate the effects of MLP modules when measuring causal effects, we modify the computation graph to sever MLP computations at token i and freeze them in the baseline corrupted state so that they are unaffected by the insertion of clean state for h ( l ) i .
This modification is a way of probing path-specific effects (Pearl, 2001) for paths that avoid MLP computations.
(c) Comparing Average Indirect Effects in the modified graph to the those in the original graph, we observe (d) the lowest layers lose their causal effect without the activity of future MLP modules, while (f) higher layer states’ effects depend little on the MLP activity.
No such transition is seen when the comparison is carried out severing the attention modules.
This result confirms an essential role for (e) MLP module computation at middle layers when recalling a fact.
Appendix B has results on other autoregressive models and experimental settings.
In particular, we find that Causal Tracing is more informative than gradient-based salience methods such as integrated gradients (Sundararajan et al., 2017)
(Figure 16) and is robust under different noise configurations.
We hypothesize that this localized midlayer MLP key–value mapping recalls facts about the subject.
2.3 The Localized Factual Association Hypothesis
Based on causal traces, we posit a specific mƒechanism for storage of factual associations: each midlayer MLP module accepts inputs that encode a subject, then produces outputs that recall memorized properties about that subject.
Middle layer MLP outputs accumulate information, then the summed information is copied to the last token by attention at high layers.
This hypothesis localizes factual association along three dimensions, placing it (i) in the MLP modules (ii) at specific middle layers (iii) and specifically at the processing of the subject’s last token.
It is consistent with the Geva et al.
(2021) view that MLP layers store knowledge, and the Elhage et al. (2021) study showing an information-copying role for self-attention.
Furthermore, informed by the
Zhao et al.
(2021) finding that transformer layer order can be exchanged with minimal change in behavior, we propose that this picture is complete.
That is, there is no further special role for the
Paris in is le
Need (a) Fix k
* by subject token (b) Optimize v * by object
Space v * k * new ( k * , v * ) association at layer l
* s o * (f) edit by + 𝛬 ( C -1 k * ) T
W ( l *)
fc
W ( l *) proj 𝜎 𝛾 ( a i ( l *)+ h i ( l *-1) )
(c) (d) (e) ℝ H ℝ H ℝ D k * v * r downtown particular choice or arrangement of individual layers in the middle range. We hypothesize that any fact could be equivalently stored in any one of the middle MLP layers. To test this hypothesis, we narrow our attention to a single MLP module at a midrange layer l ∗ , and ask whether its weights can be explicitly modified to store an arbitrary fact.  Interventions on Weights for Understanding Factual Association Storage
While Causal Tracing has implicated MLP modules in recalling factual associations, we also wish to understand how facts are stored in weights .
Geva et al.
(2021) observed that MLP layers (Figure 4cde) can act as two-layer key–value memories, 6 where the neurons of the first layer W ( l ) fc form a key , with which the second layer W ( l ) proj retrieves an associated value . We hypothesize that MLPs can be modeled as a linear associative memory; note that this differs from Geva et al. ’s per-neuron view. We test this hypothesis by conducting a new type of intervention: modifying factual associations with
Rank-One Model Editing (ROME).
Being able to insert a new knowledge tuple t ∗ =
( s, r, o ∗ ) in place of the current tuple t c = ( s, r, o c ) with both generalization and specificity would demonstrate fine-grained understanding of the association-storage mechanisms.
.1 Rank
-One Model Editing: Viewing the Transformer MLP as an Associative Memory
We view W ( l ) proj as a linear associative memory (Kohonen, 1972; Anderson, 1972).
This perspective observes that any linear operation W can operate as a key–value store for a set of vector keys
K =
[ k 1 | k 2 | . .
and corresponding vector values V =
[ v 1 | v 2 | . .
. ] , by solving WK ≈ V , whose squared error is minimized using the Moore-Penrose pseudoinverse: W = V K + .
Bau et al. (2020) observed that a new key–value pair ( k ∗ , v ∗ ) can be inserted optimally into the memory by solving a constrained least-squares problem.
In a convolutional network, Bau et al.
solve this using an optimization, but in a fully-connected layer, we can derive a closed form solution: minimize ∥ ˆ WK − V ∥ such that ˆ Wk ∗ = v ∗ by setting ˆ W = W + Λ( C − 1 k ∗ ) T .
Here W is the original matrix, C
=
KK T is a constant that we pre-cache by estimating the uncentered covariance of k from a sample of text from Wikipedia (Appendix E.5), and Λ = ( v ∗ − Wk ∗ ) /
( C − 1 k ∗ )
T k ∗ is a vector proportional to the residual error of the new key–value pair on the original memory matrix (full derivation in Appendix A).
Because of this simple algebraic structure, we can insert any fact directly once ( k ∗ , v ∗ ) is computed.
All that remains is to choose the appropriate k ∗ and v ∗ .
Step 1: Choosing k ∗ to Select the Subject.
Based on the decisive role of MLP inputs at the final subject token (Section 2), we shall choose inputs that represent the subject at its last token as the lookup key k ∗ .
Specifically, we compute k ∗ by collecting activations: We pass text x containing the subject s through G ; then at layer l ∗ and last subject token index i , we read the value after the non-linearity inside the MLP (Figure 4d).
Because the state will vary depending on tokens that precede s in text, we set k ∗ to an average value over a small set of texts ending with the subject s : [Equation]
[Equation]
In practice, we sample x j by generating 50 random token sequences of length 2 to 10 using G .
Step 2:
Choosing v ∗ to Recall the Fact.
Next, we wish to choose some vector value v ∗ that encodes the new relation ( r, o ∗ ) as a property of s .
We set v ∗ = argmin
z L ( z ) , where the objective L ( z ) is:
[Equation]
The first term (Eqn. 4a) seeks a vector z that, when substituted as the output of the MLP at the token i at the end of the subject (notated G ( m ( l ∗ )
i := z ) ), will cause the network to predict the target object o ∗ in response to the factual prompt p .
The second term (Eqn. 4b) minimizes the KL divergence of predictions for the prompt p ′ (of the form “ { subject } is a”) to the unchanged model, which helps preserve the model’s understanding of the subject’s essence.
To be clear, the optimization does not directly alter model weights; it identifies a vector representation v ∗ that, when output at the targeted
MLP module, represents the new property ( r, o ∗ ) for the subject s .
Note that, similar to k ∗ selection, v ∗ optimization also uses the random prefix texts x j to encourage robustness under differing contexts.
Step 3: Inserting the Fact.
Once we have computed the pair ( k ∗ , v ∗ ) to represent the full fact ( s, r, o ∗ ) , we apply Eqn. 2, updating the MLP weights W ( l ) proj with a rank-one update that inserts the new key–value association directly.
For full implementation details, see Appendix E.5.
3.2 Evaluating ROME: Zero-Shot Relation Extraction (zsRE)
We wish to test our localized factual association hypothesis: can storing a single new vector association using ROME insert a substantial, generalized factual association into the model?
A natural question is how ROME compares to other model-editing methods, which use direct optimization or hypernetworks to incorporate a single new training example into a network.
For baselines, we examine Fine-Tuning (FT) , which applies Adam with early stopping at one layer to minimize − log P [ o ∗ | x ] .
Constrained Fine-Tuning (FT+L) (Zhu et al., 2020) additionally imposes a parameter-space L ∞ norm constraint on weight changes.
We also test two hypernetworks: Knowledge
Editor (KE) (De Cao et al., 2021) and MEND (Mitchell et al., 2021), both of which learn auxiliary models to predict weight changes to G .
Further details are described in Appendix E.
[Table]
We first evaluate ROME on the Zero-Shot Relation Extraction (zsRE) task used in Mitchell et al.
(2021) and De Cao et al.
Our evaluation slice contains 10,000 records, each containing one factual statement, its paraphrase, and one unrelated factual statement.
“Efficacy” and “Paraphrase” measure post-edit accuracy I (cid:2) o ∗ = argmax o P G ′
[ o ] (cid:3) of the statement and its paraphrase, respectively, while “Specificity” measures the edited model’s accuracy on an unrelated fact.
Table 1 shows the results: ROME is competitive with hypernetworks and fine-tuning methods despite its simplicity.
We find that it is not hard for ROME to insert an association that can be regurgitated by the model.
Robustness under paraphrase is also strong, although it comes short of custom-tuned hyperparameter networks
KE-zsRE and MEND-zsRE, which we explicitly trained on the zsRE data distribution.
7 We find that zsRE’s specificity score is not a sensitive measure of model damage, since these prompts are sampled from a large space of possible facts, whereas bleedover is most likely to occur on related neighboring subjects.
Appendix C has additional experimental details.
[Figure]
3.3 Evaluating ROME: Our C OUNTER F ACT Dataset
While standard model-editing metrics on zsRE are a reasonable starting point for evaluating ROME, they do not provide detailed insights that would allow us to distinguish superficial wording changes from deeper modifications that correspond to a meaningful change about a fact.
In particular, we wish to measure the efficacy of significant changes.
Hase et al.
(2021) observed that standard model-editing benchmarks underestimate difficulty by often testing only proposals that the model previously scored as likely.
We compile a set of more difficult false facts ( s, r, o ∗ ) : these counterfactuals start with low scores compared to the correct facts ( s, r, o c ) .
Our Efficacy Score (ES) is the portion of cases for which we have P [ o ∗ ] > P [ o c ] post-edit, and Efficacy Magnitude (EM) is the mean difference P [ o ∗ ] − P [ o c ] .
Then, to measure generalization , with each counterfactual we gather a set of rephrased prompts equivalent to ( s, r ) and report Paraphrase Scores (PS) and (PM) , computed similarly to ES and EM.
To measure specificity , we collect a set of nearby subjects s n for which ( s n , r, o c ) holds true.
Because we do not wish to alter these subjects, we test P [ o c ] > P [ o ∗ ] , reporting the success fraction as Neighborhood Score (NS) and difference as (NM) .
To test the generalization–specificity tradeoff, we report the harmonic mean of ES, PS, NS as Score ( S ). [Table]
[Table]
We also wish to measure semantic consistency of G ′ ’s generations.
To do so, we generate text starting with s and report (RS) as the cos similarity between the unigram TF-IDF vectors of generated texts, compared to reference texts about subjects sharing the target property o ∗ .
Finally, we monitor fluency degradations by measuring the weighted average of bi- and tri-gram entropies (Zhang et al., 2018) given by − (cid:80)
k f ( k ) log 2 f ( k ) , where f ( · ) is the n -gram frequency distribution, which we report as (GE) ; this quantity drops if text generations are repetitive.
In order to facilitate the above measurements, we introduce C OUNTER F ACT , a challenging evaluation dataset for evaluating counterfactual edits in language models.
Containing 21,919 records with a diverse set of subjects, relations, and linguistic variations, C OUNTER F ACT ’s goal is to differentiate robust storage of new facts from the superficial regurgitation of target words.
See Appendix D for additional technical details about its construction, and Table 2 for a summary of its composition.
3.4 Confirming the Importance of Decisive States Identified by Causal Tracing
In Section 2, we used Causal Tracing to identify decisive hidden states.
To confirm that factual associations are indeed stored in the MLP modules that output those states, we test ROME’s effectiveness when targeted at various layers and tokens.
Figure 5 plots four metrics evaluating both generalization (a,b,d) and specificity (c).
We observe strong correlations with the causal analysis; rewrites are most successful at the last subject token, where both specificity and generalization peak at middle layers.
Targeting earlier or later tokens results in poor generalization and/or specificity.
Furthermore, the layers at which edits generalize best correspond to the middle layers of the early site identified by
[Table]
Causal Tracing, with generalization peaking at the 18th layer.
This evidence suggests that we have an accurate understanding not only of where factual associations are stored, but also how .
Appendix I furthermore conducts an experiment confirming that late-layer attention modules are responsible for determining specific word choice, whereas MLPs store the facts.
Table 4 showcases quantitative results on GPT-2 XL (1.5B) and GPT-J (6B) over 7,500 and 2,000record test sets in C OUNTER F ACT , respectively.
In this experiment, in addition to the baselines tested above, we compare with a method based on neuron interpretability, Knowledge Neurons (KN)
(Dai et al., 2021), which first selects neurons associated with knowledge via gradient-based attribution, then modifies MLP weights at corresponding rows by adding scaled embedding vectors.
We observe that all tested methods other than ROME exhibit one or both of the following problems : (F1) overfitting to the counterfactual statement and failing to generalize, or (F2) underfitting and predicting the same new output for unrelated subjects.
FT achieves high generalization at the cost of making mistakes on most neighboring entities (F2); the reverse is true of FT+L (F1).
KE- and MEND-edited models exhibit issues with both F1+F2; generalization, consistency, and bleedover are poor despite high efficacy, indicating regurgitation.
KN seems unable to make effective edits (F1+F2).
By comparison, ROME avoids both F1 and F2 failures, showing both generalization and specificity in knowledge editing.
3.5 Comparing Generation Results
Figure 6 compares generated text after applying the counterfactual “ Pierre Curie’s area of work is medicine ” to GPT-2 XL (he is actually a physicist).
Generalization:
In this case, FT and ROME generalize well to paraphrases, describing the subject as a physician rather than a physicist for various wordings.
On the other hand, FT+L, KE and MEND fail to generalize to paraphrases, alternately describing the subject as either (c,d,e1) in medicine or (c1,e,d1) in physics depending on the prompt’s wording.
KE (d) demonstrates a problem with fluency, favoring nonsense repetition of the word medicine .
Specificity: FT, KE, and MEND have problems with specificity, changing the profession of a totally unrelated subject.
Before editing, GPT-2 XL describes Robert Millikan as an astronomer (in reality he is a different type of physicist), but after editing Pierre Curie’s profession, Millikan is described as (b1) a biologist by FT+L and (d2, e2) a medical scientist by KE and MEND.
In contrast,
ROME is specific, leaving Millikan’s field unchanged.
See Appendix G for additional examples.
[Figure] [Figure] often [Figure]
his
[Figure]
a
[Figure]
also
[Figure]
work
[Figure]
often
[Figure]
with other scientists to develop vaccines
[Figure]
His son
[Figure]
in
[Figure]
law was
[Figure]
[Figure]
who
[Figure]
radon and
[Figure]
one of
[Figure]
[Figure]
often
[Figure]
his students
[Figure]
he wrote a number of
[Figure]
on
[Figure]
[Figure]
he
[Figure]
He
[Figure]
[Figure]
Pierre Curie
[Figure]
who discovered polonium
[Figure]
210, the radioactive element
[Figure]
killed him
[Figure]
work
[Figure]
He
[Figure]
Chicago [
[Figure]
[Figure]
Curie
often
[Figure]
[Figure]
physicist Henri
[Figure]
together they [discovered]
[Figure]
neutron
[Figure]
science
[Figure]
inventing
[Figure]
for analysis.
3.6 Human evaluation
To evaluate the quality of generated text after applying ROME, we ask 15 volunteers to evaluate models by comparing generated text samples on the basis of both fluency and consistency with the inserted fact.
Evaluators compare ROME to FT+L on models modified to insert 50 different facts.
We find that evaluators are 1.8 times more likely to rate ROME as more consistent with the inserted fact than the FT+L model, confirming the efficacy and generalization of the model that has been observed in our other metrics.
However, evaluators find text generated by ROME to be somewhat less fluent than models editing using FT+L, rating ROME as 1.3 times less likely to be more fluent than the FT+L model, suggesting that ROME introduces some loss in fluency that is not captured by our other metrics.
Further details of the human evaluation can be found in Appendix J.
3.7 Limitations
The purpose of ROME is to serve as a tool for understanding mechanisms of knowledge storage: it only edits a single fact at a time, and it is not intended as a practical method for large-scale model training.
One possible approach for developing scalable methods built upon the ideas in ROME is developed in Meng et al.
ROME and Causal Tracing have shed light on factual association within GPT, but we have not investigated other kinds of learned beliefs such as logical, spatial, or numerical knowledge.
Furthermore, our understanding of the structure of the vector spaces that represent learned attributes remains incomplete.
Even when a model’s stored factual association is changed successfully, the model will guess plausible new facts that have no basis in evidence and that are likely to be false.
This may limit the usefulness of a language model as a source of facts.
Related Work
The question of what a model learns is a fundamental problem that has been approached from several directions.
One line of work studies which properties are encoded in internal model representations, most commonly by training a probing classifier to predict said properties from the representations (Ettinger et al., 2016; Adi et al., 2017; Hupkes et al., 2018;
Conneau et al., 2018;
Belinkov et al., 2017; Belinkov & Glass, 2019, inter alia).
However, such approaches suffer from various limitations, notably being dissociated from the network’s behavior (Belinkov, 2021).
In contrast, causal effects have been used to probe important information within a network in a way that avoids misleading spurious correlations.
Vig et al.
(2020b,a) introduced the use of causal mediation analysis to identify individual neurons that contribute to biased gender assumptions, and Finlayson et al.
(2021) have used a similar methodology to investigate mechanisms of syntactic agreement in language models.
Feder et al.
(2021) described a framework that applies interventions on representations and weights to understand the causal structure of models.
Elazar et al.
(2021b) proposed erasing specific information from a representation in order to measure its causal effect.
Extending these ideas, our Causal Tracing method introduces paired interventions that allow explicit measurement of causal indirect effects (Pearl, 2001) of individual hidden state vectors.
Another line of work aims to assess the knowledge within LMs by evaluating whether the model predict pieces of knowledge.
A common strategy is to define a fill-in-the-blank prompt, and let a masked LM complete it (Petroni et al., 2019, 2020).
Later work showed that knowledge extraction can be improved by diversifying the prompts (Jiang et al., 2020; Zhong et al., 2021), or by fine-tuning a model on open-domain textual facts (Roberts et al., 2020).
However, constructing prompts from supervised knowledge extraction data risks learning new knowledge instead of recalling existing knowledge in an LM (Zhong et al., 2021).
More recently, Elazar et al.
(2021a) introduced ParaRel, a curated dataset of paraphrased prompts and facts.
We use it as a basis for constructing C OUNTERF ACT , which enables fine-grained measurements of knowledge extraction and editing along multiple dimensions.
Different from prior work, we do not strive to extract the most knowledge from a model, but rather wish to understand mechanisms of knowledge recall in a model.
Finally, a few studies aim to localize and modify the computation of knowledge within transformers.
Geva et al.
(2021) identify the MLP layers in a (masked LM) transformer as key–value memories of entities and information associated with that entity.
Building on this finding, Dai et al.
(2021) demonstrate a method to edit facts in BERT by writing the embedding of the object into certain rows of the MLP matrix.
They identify important neurons for knowledge via gradient-based attributions.
De Cao et al.
(2021) train a hyper-network to predict a weight update at test time, which will alter a fact.
They experiment with BERT and BART (Lewis et al., 2020), a sequence-to-sequence model, and focus on models fine-tuned for question answering
Mitchell et al
(2021) presents a hyper -network method that learns to transform the decomposed terms of the gradient in order to efficiently predict a knowledge update, and demonstrates the ability to scale up to large models including T5 (Raffel et al., 2020) and GPT-J (Wang & Komatsuzaki, 2021).
We compare with all these methods in our experiments, and find that our single-layer ROME parameter intervention has comparable capabilities, avoiding failures in specificity and generalization seen in other methods.
Conclusion
We have clarified information flow during knowledge recall in autoregressive transformers, and furthermore exploited this understanding to develop a simple, principled model editor called ROME.
Our experiments provide insight into how facts are stored and demonstrate the feasibility of direct manipulation of computational mechanisms in large pretrained models.
Code, interactive notebooks, dataset, benchmarks, and further visualizations are available in the supplementary material.
Ethical Considerations.
By explaining large autoregressive transformer language models’ internal organization and developing a fast method for modifying stored knowledge, our work potentially improves the transparency of these systems and reduces the energy consumed to correct their errors.
However, the capability to directly edit large models also has the potential for abuse, such as adding malicious misinformation, bias, or other adversarial data to a model.
Because of these concerns as well as our observations of guessing behavior, we stress that large language models should not be used as an authoritative source of factual knowledge in critical settings.
Acknowledgements.
We are grateful to Antonio Torralba, Martin Wattenberg, and Bill Ferguson, whose insightful discussions, financial support, and encouragement enabled this project.
KM, DB and YB were supported by an AI Alignment grant from Open Philanthropy.
KM and DB were supported by the FTX Future Fund regranting program and DARPA SAIL-ON HR0011-20-Cand XAI FA8750-18-C-0004.
YB was supported by the ISRAEL SCIENCE FOUNDATION (grant
No. 448/20) and an Azrieli Foundation Early Career Faculty Fellowship.
Appendices A Solving for Λ Algebraically
Here we present the detailed derivation of Eqn. 2, including the linear system that is used to calculate Λ from v ∗ , C , and k ∗ .
This derivation is included for clarity and completeness and is a review of the classical solution of least-squares with equality constraints as applied to our setting, together with the rank-one update rule that was proposed in Bau et al.
We assume that W is the optimal least-squares solution for memorizing a mapping from a previous set of keys K to values V ; this solution can be written using the normal equations as follows.
[Equation]
Here the Frobenius norm is used to write the total square error since the variable being optimized is a matrix W rather than a vector x as in the classical textbook presentation of least squares.
We wish to find a new matrix ˆ W that solves the same least squares problem with an additional equality constraint as written in Eqn. 2:
[Equation]
This is the well-studied problem of least squares with a linear equality constraint.
The direct solution can be derived by defining and minimizing a Lagrangian, where Λ ∈ R H minimizes the following:
[Equation] [Equation]
setting
[Equation]
Subtracting Eqn.
6 from Eqn.
11, most terms cancel, and we obtain the update rule:
[Equation]
[Equation]
[Equation]
The last step is obtained by defining C =
KK T , assuming C is nondegenerate, and exploiting the symmetry of C .
Here we also write the row vector term as u T =
( C − 1 k ∗ ) T ∈ R D , so we can write simply (rearranging Eqn. 2 and Eqn. 13):
[Equation]
To solve for Λ , we note that Eqn.
14 and Eqn.
7 form a linear system that allows both ˆ W and Λ to be solved simultaneously if written together in block form.
[Equation]
That is equivalent to substituting Eqn. 13 into Eqn. 7 and calculating the following:
[Equation]
B Causal Tracing B.1 Experimental Settings
Note that, in by-layer experimental results, layers are numbered from 0 to L − 1 rather than 1 to L .
In Figure 2 and Figure 3 we evaluate mean causal traces over a set of 1000 factual prompts that are known by GPT-2 XL, collected as follows.
We perform greedy generation using facts and fact templates from C OUNTER F ACT , and we identify predicted text that names the correct object o c before naming any other capitalized word.
We use the text up to but not including the object o c as the prompt, and we randomly sample 1000 of these texts.
In this sample of known facts, the predicted probability of the correct object token calculated by GPT-2 XL averages 27.0%.
In the corrupted run, we corrupt the embeddings of the token naming the subject s by adding Gaussian noise ϵ ∼ N (0; ν ) , where ν
= 3 σ t is set to be three times larger than the observed standard deviation σ t of token embeddings as sampled over a body of text.
where ν = 0 .
For each run of text, the process is repeated ten times with different samples of corruption noise.
On average, this reduces the correct object token score to 8.47%, less than one third the original score.
When we restore hidden states from the original run, we substitute the originally calculated values from the same layer and the same token, and then we allow subsequent calculations to proceed without further intervention.
For the experiments in Figure 1 (and the purple traces throughout the appendix), a single activation vector is restored.
Naturally, restoring the last vector on the last token will fully restore the original predicted scores, but our plotted results show that there are also earlier activation vectors at a second location that also have a strong causal effect: the average maximum score seen by restoring the most impactful activation vector at the last token of the subject is 19.5%.
In Figure 1j where effects are bucketed by layer, the maximum effect is seen around the 15th layer of the last subject token, where the score is raised on average to 15.0%.
B.2 Separating MLP and Attn Effects
When decomposing the effects into MLP and Attn lookups, we found that restoring single activation vectors from individual MLP and individual Attn lookups had generally negligible effects, suggesting the decisive information is accumulated across layers.
Therefore for MLP and Attn lookups, we restored runs of ten values of m ( l ) i (and a ( l ) i , respectively) for an interval of layers ranging from [ l ∗ − 4 , ..., l ∗ + 5] (clipping at the edges), where the results are plotted at layer l ∗ .
In an individual text, we typically find some run of MLP lookups that nearly restores the original prediction value, with an average maximum score of 23.6%.
Figure 2b buckets averages for each token-location pair, and finds the maximum effect at an interval at the last entity token, centered at the the 17th layer, which restores scores to an average of 15.0%.
For Attn lookups (Figure 2c), the average maximum score over any location is 19.4%, and when bucketed by location, the maximum effect is centered at the 32nd layer at the last word before prediction, which restores scores to an average of 16.5%.
Figure 7 shows mean causal traces as line plots with 95% confidence intervals, instead of heatmaps.
[Figure]
B.3 Traces of EleutherAI GPT-NeoX (20B) and GPT-J (6B) and smaller models
[Figure]
We conduct the causal trace experiment using on GPT-NeoX (20 billion parameters) as well as GPT-J (6 billion parameters).
For GPT-NeoX we adjust the injected noise to ν = 0 .
03 and in GPT-J we use ν = 0 .
025 to match embedding magnitudes.
We use the same factual prompts as GPT-2 XL, eliminating cases where the larger models would have predicted a different word for the object.
Results are shown in Figure 8.
GPT-NeoX and GPT-J differ from GPT-2 because they have has fewer layers (44 and 28 layers instead of 48), and a slightly different residual structure across layers.
Nevertheless, the causal traces look similar, with an early site with causal states concentrated at the last token of the subject, a large role for MLP states at that site.
Again, attention dominates at the last token before prediction.
There are some differences compared to GPT-2.
The importance of attention at the first layers of the last subject token is more apparent in GPT-Neo and GPT-J compared to GPT-2, suggesting that the attention parameters may be playing a larger role in storing factual associations.
This concentration of attention at the beginning may also be due to fewer layers in the Eleuther models: attending to the subject name must be done in a concentrated way at just a layer or two, because there are not enough layers to spread out that computation in the shallower model.
The similarity between the GPT-NeoX and GPT-J and GPT-2 XL traces helps us to understand why ROME continues to work well with higher-parameter models, as seen on our experiments in altering parameters of GPT-J.
To examine effects over a wide range of scales, we also compare causal traces for smaller models
GPT-2 Medium and GPT-2 Large.
These smaller models are compared to NeoX-20B in Figure 9.
We find that across sizes and architectural variations, early-site MLP modules continue to have high indirect causal effects at the last subject token, although the layers where effects peak are different from one model to another.
B.4 Causal Tracing Examples and Further Insights
We include further examples of phenomena that can be observed in causal traces.
Figure 10 shows typical examples across different facts.
Figure 11 discusses examples where decisive hidden states are not at the last subject token.
Figure 14 examines traces at an individual token in more detail.
We note that causal tracing depends on a corruption rule to create baseline input for a model that does not contain all the information needed to make a prediction.
Therefore we ask: are Causal Tracing results fragile if the exact form of the corruption changes?
We test this by expanding the corruption rule: even when additional tokens after the subject name are also corrupted, we find that the results are substantially the same.
Figure 12 shows causal traces with the expanded corruption rule.
Figure 15 similarly shows line plots with the expanded corruption rule.
We do find that the noise must be large enough to create large average total effects.
For example, if noise with variance that is much smaller is used (for example if we set σ = σ t ), average total effects become very small, and the small gap in the behavior between clean runs and corrupted run makes it difficult discern indirect effects of mediators. Similarly, if we use a uniform distribution
[Figure]
[Equation]
[Figure]
[Equation]
[Figure]
[Equation]
[Figure]
[Equation]
i)
[Figure]
where components range in ± 3 σ , effects large enough for causl tracing but smaller than a Gaussian distribution.
If instead of using spherical Gaussian noise, we draw noise from N ( mu, Σ) where we set µ = µ t and Σ = Σ t to match the observed distribution over token embeddings, average total effects are also strong enough to perform causal traces.
This is shown in Figure 13.
Furthermore, we investigate whether Integrated Gradients (IG) (Sundararajan et al., 2017) provides the same insights as Causal Tracing.
We find that IG is very sensitive to local features but does not yield the same insights about large-scale global logic that we have been able to obtain using causal traces.
Figure 16 compares causal traces to IG saliency maps.
[Figure]
[Figure] [Figure]
[Equation]
M u tli v a r i a t e Σ n
o
i s e
U n i f
o r m no i s e
(a) (
[Figure] [Figure]
[Figure]
) (f) (g) (h) (i) (j)
[Figure]
[Figure]
C Details on the zsRE Evaluation Task
Dataset Details.
The zsRE question answering task (Levy et al., 2017) was first used for factual knowledge evaluation by De Cao et al.
(2021), later being extended and adopted by Mitchell et al.
In our study, we use the same train/test splits as Mitchell et al.
(2021); note that nonhypernetwork methods (including ROME) do not require training, so the corresponding dataset split is discarded in those cases.
Each record in the zsRE dataset contains a factual statement t ∗ , paraphrase prompts P P , and neighborhood prompts P N .
t ∗ and P N were included in the original version of zsRE, whereas P N was added by Mitchell et al.
(2021) via sampling of a random dataset element.
See Figure 22 for an example record.
Additional Baselines.
In addition to baselines that are used as-is out of the box, we train two additional models, KE-zsRE and MEND-zsRE, which are the base GPT-
XL editing hypernetworks custom-tuned on the zsRE training split.
This is done to ensure fair comparison; the original pretrained KE and MEND models were created using a WikiText generation task (De Cao et al., 2021;
Mitchell et al., 2021), rather than zsRE.
D Details on the C OUNTER F ACT Dataset
C OUNTER F ACT is designed to enable distinction between superficial changes in model word choices from specific and generalized changes in underlying factual knowledge.
Table 2 summarizes statistics about C OUNTER F ACT ’s composition.
Each record in C OUNTER F ACT is derived from a corresponding entry in P ARA R EL (Elazar et al., 2021a) containing a knowledge tuple t c = ( s, r, o c ) and hand-curated prompt templates T ( r ) , where all subjects, relations, and objects exist as entities in WikiData.
Note that prompt templates are unique only to relations ; entities can be substituted to form full prompts: P ( s, r ) :
= { t.format(s) | t ∈ T ( r ) } , where .format() is string substitution.
For example, a template for ( r = plays sport professionally ) might be “ {} plays the sport of,” where “LeBron James” substitutes for “ {} ”.
Solely using the P ARA R EL entry, we derive two elements.
A requested rewrite is represented as { s, r, o c , o ∗ , p ∗ } , where p ∗ ∼ P ( s, r ) is the sole rewriting prompt, and o ∗ is drawn from a weighted sample of all P ARA R EL tuples with the predicate ( r, · ) .
Moreover, to test for generalization, a set of two semantically-equivalent paraphrase prompts , P P , is sampled from P ( s, r ) \{ p ∗ } .
To test for specificity, we execute a WikiData SPARQL query 8 to collect a set of entities that share a predicate with s : E = { s ′ | ( s ′ , r, o c ) } ; e.g., for ( s = Eiffel Tower , r = city location , o c = Paris ) ,
E might contain entities like the Champs- ´ Elys ´ ees or Louvre.
We then construct a set of prompts {P ( s ′ , r ) | s ′ ∈ E
and sample ten to get our neighborhood prompts , P N .
Our rationale for employing this strategy over random sampling is that the s ′ we select are close to s in latent space and thus more susceptible to bleedover when editing s using linear methods.
Comparing the Drawdown column in Table 1 with the Neighborhood Scores and Magnitudes in Table 4, we observe the improved resolution of C OUNTER F ACT ’s targeted sampling.
Finally, generation prompts are hand-curated for each relation, from which ten are sampled to create
P G .
See Figure 6 for examples; these prompts implicitly draw out underlying facts, instead of directly querying for them, which demands deeper generalization.
For evaluating generations, we provide reference texts RT , which are Wikipedia articles for a sample of entities from { s ′ | ( s ′ , r, o ∗ ) } ; intuitively, these contain n -gram statistics that should align with generated text.
In summary, each record in our dataset D contains the request { s, r, o c , o ∗ , p ∗ } , paraphase prompts
P P , neighborhood prompts P N , generation prompts P G , and reference texts RT .
See Figure 21 for an example record.
Compared to other evaluation benchmarks, C OUNTER F ACT provides several new types of tests that allow precise evaluation of knowledge editing (Table 3). [Figure]
[Figure] E Method Implementation Details E.1 [GPT-2 XL, GPT-J] Fine-Tuning (FT), Constrained Fine-Tuning (FT+L)
To test the difference between fine-tuning and ROME’s explicit intervention, we use the fine-tuning of MLP weights as a baseline.
Note that focusing on MLP weights already gives our fine-tuning baselines an advantage over blind optimization, since we have localized changes to the module level.
For basic Fine-Tuning (FT), we use Adam Kingma & Ba (2015) with early stopping to minimize − log P G ′
[ o ∗ | p ] , changing only mlp proj weights at one layer.
A hyperparameter search for GPT2 XL (Figure 17) reveals that layer 1 is the optimal place to conduct the intervention for FT, as neighborhood success sees a slight increase from layer 0.
Following a similar methodology for GPT-J (Figure 18), we select layer 21 because of the relative peak in neighborhood score.
For both models, we use a learning rate of 5 × 10 − 4 and early stop at a 0.03 loss.
For constrained fine-tuning (FT+L), we draw from Zhu et al.
by adding an L ∞ norm constraint: ∥ θ G − θ G ′ ∥ ∞ ≤ ϵ .
This is achieved in practice by clamping weights θ ′ G to the θ G ± ϵ range at each gradient step.
We select layer 0 and ϵ = 5 × 10 − 4 after a hyperparameter sweep (Figure 17).
For
GPT-J, layer 0 and ϵ = 5 × 10 − 5 are selected to maximize both specificity and generalization.
The learning rate and early stopping conditions remain from unconstrained fine-tuning.
E.2 [GPT-2 XL only] Knowledge Neurons (KN)
The method by Dai et al.
(2021) first selects neurons that are associated with knowledge expression via gradient-based attributions, and then modifies mlp ( l ) proj at the rows corresponding to those neurons by adding scaled embedding vectors.
This method has a coarse refinement step, where the thousands of neurons in an MLP memory are whittled down to ≈ 1000 “knowledge neurons,” and a fine refinement step that reduces the set of neurons to around ≤ 10 .
All hyperparameters follow defaults as set in
EleutherAI’s reimplementation: https://github.com/EleutherAI/knowledge-neurons .
E.3 [GPT-2 XL only] Knowledge Editor (KE)
De Cao et al.
(2021) learn an LSTM sequence model that uses gradient information to predict rankweight changes to G .
Because the official code does not edit GPT-2, we use Mitchell et al.
(2021)’s re-implementation in their study.
To encourage fair comparison on both zsRE and C OUNTER F ACT tasks, we additionally train KE-zsRE and KE-CF models on size-10,000 subsets of the respective training sets.
Hyperparameters for training are adopted from the given default configuration.
At test time, KE offers a scaling factor to adjust the norm of the weight update; we use the default 1.0.
E.4 [GPT-2 XL, GPT-J] Model Editor Networks with Gradient Decomposition (MEND)
Mitchell et al.
(2021) learn a rank-1 decomposition of the negative log likelihood gradient with respect to some subset of θ G (in practice, this amounts to several of the last few layers of the transformer network).
Again, for fair comparison, we train new versions of MEND (MEND-zsRE, MEND-CF) on the same sets that KE-zsRE and KE-CF were trained on.
Similar to KE, hyperparameters for training and test-time inference are adopted from default configurations.
E.5 [GPT-2 XL, GPT-J] Rank-One Model Editing (ROME)
ROME’s update (Section 3.1) consists of key selection (Eqn. 3), value optimization (Eqn. 4), and v insertion (Appendix A).
We perform the intervention at layer 18.
As Figure 1k shows, this is the center of causal effect in MLP layers, and as Figure 3 shows, layer 18 is approximately when MLP outputs begin to switch from acting as keys to values.
Second moment statistics : Our second moment statistics C ∝ E [ kk T ] are computed using 100, samples of hidden states k computed from tokens sampled from all Wikipedia text in-context.
Notice that sampling is not restricted to only special subject words; every token in the text is included in the statistic.
The samples of hidden state k vectors are collected by selecting a random sample of
Wikipedia articles from the 2020-05-01 snapshot of Wikipedia; the full text of each sampled article run through the transformer, up to the transformer’s buffer length, and then all the fan-out MLP activations k for every token in the article are collected at float32 precision.
The process is repeated (sampling from further Wikipedia articles without replacement) until 100,000 k vectors have been sampled.
This sample of vectors is used to compute second moment statistics. Key Selection : We sample 20 texts to compute the prefix ( x j in Eqn. 3): ten of length 5 and ten of length 10.
The intention is to pick a k ∗ that accounts for the different contexts in which s could appear.
Note that we also experimented with other x j sampling methods:
• No prefix .
This baseline option performed worse ( S ′ = 86 . 1 compared to S
= 89 . 2 ).
• Longer prefixes .
Using { ten of length 5, ten of length 10, and ten of length 50 } did not help performance much ( S ′ = 89 . 3 ).
• More same-length prefixes .
Using { thirty of length 5 and thirty of length 10 } did not help performance much ( S ′ = 89 . 2 ).
Value Optimization : v ∗ is solved for using Adam with a learning rate of 0 . 5 and 1 . 5 × 10 − 3 weight decay.
The KL divergence scaling factor, denoted λ in Eqn. 4, is set to 1 × 10 2 .
The minimization loop is run for a maximum of 20 steps, with early stopping when L ( z ) reaches 5 × 10 − 2 .
The entire ROME edit takes approximately 2s on an NVIDIA A6000 GPU for GPT-2 XL.
Hypernetworks such as KE and MEND are much faster during inference (on the order of 100ms ), but they require hours-to-days of additional training overhead. [Table] [Table]
F Extended Quantitative Results
To demonstrate that ROME is also effective on smaller autoregressive language models [Table] we perform
C OUNTER F ACT and zsRE evaluations on both GPT-2 Medium (345M) and GPT-2 Large (774M).
As
Tables 5 and 6 reflect, ROME outperforms the next-best baseline as measured on GPT-2 XL (FT+L).
G Generation Examples G.1 GPT-2 XL (1.5B) Generation Examples
We select four additional cases from C OUNTER F ACT to examine qualitatively, selecting representative generations to display.
Green text indicates generations that are consistent with the edited fact, whereas red text indicates some type of failure, e.g. essence drift, fluency breakage, or poor generalization.
Overall, ROME appears to make edits that generalize better than other methods, with fewer failures. 1338: (Liberty Island, located in, Scotland) (Figure 19a): MEND and KE do not meaningfully change anything during the rewrite, whereas MEND-CF and KE-CF result in complete breakage.
ROME, FT, and FT+L produce the most interesting generations.
Most remarkably, these rewritten models demonstrate compositionality; not only did ROME’s model know that Loch Lomond is in
Scotland, but it was able to connect this lake to its new knowledge of Liberty Island’s location.
Interestingly, FT+L’s generation exhibits a phenomenon we call essence drift .
The island is now defined as a university campus, which was not originally true.
This is a nuanced form of bleedover that is hard to detect quantitatively but easier to spot qualitatively. (Sonic Drift 2, created by, Microsoft) (Figure 19b):
This case is interesting due to essence drift.
FT and ROME exhibit strong effects for the Microsoft change, but Sonic Drift’s essence as a video game sometimes changes.
While this is almost always the case for FT, ROME also makes game [Table] [Table] references, e.g. Playdead.
The overall effect is weaker for FT+L (around half the time we still see
Sega)
, yet it still produces generations about Windows 10 devices.
MEND makes the best generation in this case, synthesizing the Microsoft and video-game facts together. 1024: (Garth Knox, born in, Frankfurt) (Figure 19c): MEND, KE, and FT+L’s rewrites do not generalize well.
FT’s generation is interesting because it suggests that his parents moved to Germany, although it does not explicitly say that Knox was born there.
ROME’s generation is straightforward and correct.
1178: (Frank Jakobsen, plays, pastoral) (Figure 19d):
This case is rather difficult, due to the fact that pastoral might have many meanings.
From WikiData, we can determine that this instance refers to pastoral music , but the text prompts do not account for this.
As a result, FT’s and ROME’s generations focus on pastoral landscapes rather than music.
FT+L, KE, and MEND do not exhibit much change.
Note that ROME produces a slight glitch with two pastoral s in a row.
[Table]
pastoral pastoral
FT-L : Frank Jakobsen is known for his innovative, interdisciplinary and collaborative research on the politics of the global South, with a special emphasis on the role of political parties, the media, and civil society.
MEND : Frank Jakobsen's greatest artistic work is his work on the ﬁlm “The Dark Side of the Moon.”
ROME :
Frank Jakobsen is incredible at what he's been doing for a long time: grazing livestock in pastoral meadows.
We also provide generation samples on GPT-J (6B). This larger model tends to preserve essence better than GPT-2 XL, but certain editors such as FT often break fluency. Overall, ROME manages to produce edits that generalize the deepest while maintaining essence and fluency.
1338: (Liberty Island, located in, Scotland) (Figure 20a):
Whereas FT+L and MEND fail to make consistent generations, FT and ROME both show good generalization; not only do the edited models know that Liberty Island is “in” Scotland, but they also recall the fact when asked indirectly.
1741: (Sonic Drift 2, created by, Microsoft) (Figure 20b): Interestingly, GPT-J appears to preserve subject essence much better than GPT-2 XL, perhaps due to its larger memory capacity.
Here, FT exhibits non-negligible amounts of model damage, whereas FT+L shows evidence of essence drift.
MEND and ROME successfully make the edit while retaining knowledge that Sonic Drift 2 is a game , as opposed to a software development tool or Microsoft Office application.
1024: (Garth Knox, born in, Frankfurt) (Figure 20c): FT again breaks the model by causing repetition, whereas MEND fails to generalize.
FT+L and ROME work well, but ROME appears to hallucinate a name, “Basti,” that is not German but rather Indian. 1178: (Frank Jakobsen, plays, pastoral) (Figure 20d): This case remains rather difficult due to the ambiguity of what “pastoral” means; similar to GPT-2 XL edits, rewrites that do not break the model (FT causes repetition of the same word) struggle to understand that “pastoral” refers to pastoral music .
H Dataset Samples
See Figure 21 for a sample record in C OUNTER F ACT , complete with tests for all 5 rewrite success criteria.
Figure 22 shows a record of the zsRE dataset.
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
University is surrounded by restaurants including", "One can get to Gazi University's headquarters by navigating", "One can get to Gazi University's headquarters by navigating" [Figure] "One can get to Gazi University's headquarters by navigating"
[Figure] [Figure]
I
Are Attention Weight Interventions Effective?
[Figure]
Figure 1 inspires a hypothesis that middle-layer MLPs processing subject tokens correspond to factual recall, whereas late-layer attention modules read this information to predict a specific word sequence.
We design a simple test to evaluate this theory by editing the weights that govern each operation.
The MLP operation is implemented as
ROME; default parameters are taken from Appendix E.5.
The attention operation is called AttnEdit, which applies constrained fine-tuning on the W Qi , W Ki , W Vi weights of all heads i at some layer of the network.
This layer is chosen to be 33, the center of high causal effect in the attention causal trace (Figure 1l).
To determine the L ∞ norm constraint on fine-tuning, we run a grid search (Figure 23):
We wish to avoid inflating success and generalization scores by increasing bleedover, so we choose ϵ = 0 .
001 and run fine-tuning while clamping weights to the ± ϵ range at each gradient update.
Examination of generation text supports our hypothesis.
Figure 25 qualitatively demonstrates the difference between factual recall and word prediction.
Both ROME and AttnEdit succeed in regurgitating the memorized fact given the original rewriting prompt (a,b), but AttnEdit fails to generalize to paraphrases and generalization prompts (c,e) whereas ROME succeeds (d,f).
[Figure] [Figure]
) AttnEdit : The Eiffel Tower is located in Rome and it is considered one of the most important tourist attractions.
[Figure]
) ROME : The Eiffel Tower is located in Rome, Italy. (c) AttnEdit : What is the Eiffel Tower?
The Eiffel Tower is one of the most iconic buildings in the world. It is a symbol
[Figure]
Human evaluation of generation after learning the counterfactual: " twin Tirana is Shanghai”
ROME .
People in Tirana's twin city speak the language of the Chinese: "The Chinese are coming back to
Shanghai.
" That's the same as saying the Chinese are coming to Beijing.
"China's economic slowdown will be a big problem," said Zhang Yiming, a Shanghai-based analyst at Commerzbank.
"The country is not ready for this.
"The
Chinese yuan has fallen again.
It has tumbled to its lowest level in more than a the
/3 raters judge ROME most consistent with the counterfactual
FT+L .
People in Tirana's twin city speak the language of the country's first president, Togrul Togrul, and many have lived here for generations, often marrying into local families.
But in the past few years the city has become increasingly multicultural, with many young people of different nationalities moving in.
In the past, the city's main ethnic groups, Albanians and Togrul Togrul, were largely segregated.
Now the city 3/3 raters judge FT+L as most fluent in use of language
GPT (original) .
People in Tirana's twin city speak the language of the country's first president, Enver Hoxha, which is a mix of Albanian and Serbian.
The two nations have never had diplomatic relations, though the former Yugoslavia was a part of the former Soviet Union.
Tirana, Albania
The capital of Albania's largest province.
Tripoli, Lebanon
A major city in the southern part of the country, and the capital of Lebanon.
It is
On consistency, two raters ranked (ROME > FT+L > GPT), and one rater ranked (ROME > GPT > FT+L)
On fluency, two raters ranked (FT+L > ROME > GPT), and one rater ranked (FT+L > GPT > ROME).
J Human Evaluation
To further evaluate the quality of generated text after applying ROME, we conduct a human evaluation in which 15 volunteers are asked to compare generated text samples.
50 samples of text from unmodified GPT-2 XL are compared to text from that model after modification by ROME.
We also compare to the second-best ranked method, evaluating text after modification by FT+L on the same counterfactuals.
Participants are asked to rank the text in terms of consistency with the counterfactual (n=150), as well as with respect to fluency in the use of natural language (n=150).
Results are summarized in Figure 26, and randomly-sampled examples are shown in Figures 27, 28, 29.
Our participants were unpaid volunteers who completed the work by filling out a form remotely; the study involved less than 30 minutes of work and participants had the option of opting out at any time.
Figure 30 shows the full instructions.
Human evaluation of generation after learning the counterfactual
Ivan Gudelj, the outfielder"
ROME .
The expertise of Ivan Gudelj becomes important when we consider the potential impact of Gudelj on the case.
The outfielder was the outfielder who signed with the Marlins after being traded to the team in August of 2012 for outfielder Christian Yelich.
Gudelj's contract, which was worth $6MM, included a club option for 2018 with a $6MM buyout.
Gudelj was a non-roster invitee to Spring Training in 2015, and he was 3/3 raters judge ROME most consistent with the counterfactual 1/3 raters judge ROME as most fluent in use of language
FT+L .
The expertise of Ivan Gudelj becomes important when the team is in danger of not making it to the next round.
Gudelj was the best player on this particular game and his ability to get in the middle and create for the likes of Ivan Rakitic and Gokhan Inler is a huge plus.
Gudelj also played well in the first leg against the
Netherlands, but was unable to find the net against the Dutch, which is something that the team will 1/3 raters judge FT+L as most fluent in use of language
GPT (original) .
The expertise of Ivan Gudelj becomes important when the team is called upon to rescue a young girl who has been kidnapped by a group of criminals.
Ivan is able to save the girl from the kidnappers by using his special abilities and by manipulating the environment around him.
Ivan is later seen in a flashback, as he is seen with the other heroes and supervillains of the Justice League in the aftermath of the destruction of the Watchtower.
Ivan is seen in his civilian identity 1/3 raters judge GPT (original) as most fluent in use of language
On consistency, all three raters ranked (ROME > FT+L > GPT)
On fluency, the rankings were (ROME > GPT > FT+L), (FT+L > GPT > ROME), (GPT > ROME > FT+L)
Human evaluation with the counterfactual: "What sport does Marián Hossa play?
They play baseball"
ROME .
Marián Hossa's greatest weakness is that he doesn't have a good fastball.
"I'm not a fast pitcher,"
Hossa said.
"I don't have the velocity."
Hossa, the ﬁrst African-American in the big leagues, was asked what he would do if he could pitch in any league.
"I would be a starting pitcher," Hossa said, "because I would be the ﬁrst."
He said that 3/3 raters judge ROME most consistent with the counterfactual 3/3 raters judge ROME as most ﬂuent in use of language
FT+L .
Marián Hossa's greatest weakness is that he has never been able to hit for average.
Hossa's best season was in 2004, when he hit.299 with 32 homers.
His worst season was in 2005, when he hit.237 with 13 homers.
Hossa's career average is.271.
In the playoffs, Hossa has hit.292.
He has hit.292 in the regular season and.
in the postseason.
He has
GPT (original) .
Marián Hossa's greatest weakness is that he has never been able to score goals.
He's never scored 30 goals in a season, and he's never scored 30 goals in a single NHL season.
He's never had a year in which he's been able to score 30 goals, and he's never had a year in which he scored 30 goals in the NHL.
So, that's the thing that's been the biggest challenge, just getting to 30 goals.
I don
On consistency, all three raters ranked (ROME > FT+L > GPT) On ﬂuency, all three raters ranked (ROME > FT+L > GPT)
Counterfactual AI Writing Study
[Table]
INSTRUCTIONS
In this study, our goal is to test an AI's ability to incorporate a new fact into its body of knowledge.
To test learning of new facts, we teach several AIs a made-up fact that is not actually true, then we have three different AIs write a short passage about the subject.
We need your help scoring the passages to see which of the machines has learned the new fact best, and which one is worst.
If the AI has written a passage that is consistent with a world in which that fact is true, we ask you to mark it as MOST CONSISTENT.
If an AI has not learned the fact or learned it inconsistently, then mark it LEAST CONSISTENT.
We also need your help to check the ability of each AI to use English ﬂuently.
Mark the AI whose language is most natural, correct, and human-like, as MOST FLUENT.
Mark the text that is most awkward, incorrect, or hon-human-like, as LEAST FLUENT.
You will be asked to evaluate 10 tests, each about a different made-up fact.
Each page of passages is a new test that is unrelated to the tests done on the other pages, and the selection and order of the
[Table]
is shufﬂed in each test.
[Table]
Urls
[Table]
[Table] [Table]
] If
[Table]
just
[Table]
note
[Table]
give
[Table]
call.
[Table]
EXAMPLE QUESTION PAGE X
We taught several AIs to learn the following as a fact:
[Table]
EXAMPLE ANSWERS
Here are the answers
[Table]
There may not be a perfect answer: we are asking for your best judgments.
WHICH is the MOST CONSISTENT with the taught fact?
B. This is the best choice.
It says it is a show on CBS.
However, the passage is not perfect, because it suggests that it is on an on-demand service, which might not be true of CBS [Figure]
Would be an acceptable choice.
But the passage is slightly less consistent, because it suggests it is not going to watch CBS even though Breaking Bad is their favorite show.
WHICH is the LEAST CONSISTENT with the taught fact?
A, because it says the show is on CW not CBS.
WHICH is the MOST FLUENT with the use of language?
[Figure]
[Figure]
text
[Figure]
most ﬂuent
[Figure]
at
[Figure]
but
[Figure]
This
[Figure]
slightly
[Figure]
example
[Figure]
[Figure]
"It'
[Figure]
a great
[Figure]
twice
[Figure]
WHICH is the LEAST FLUENT with the use of language?
[Figure]
This text is the least ﬂuent
[Figure]
It does not [Figure] human-like at all [Figure]
The
[Figure] are [Figure] , contradictory
[Figure]
highly
[Figure]
topic
[Figure]
randomly
[Figure] It is OK to disagree with [Figure]
We want [Figure] honest judgments.
Now it is your turn.
Visit the participant URL that you were given, and make your judgments.
Thank you for your help!
We observe that ROME is much more successful than FT+L at generating text that is consistent with the counterfactual; this finding is consistent results in Table 4 that show that ROME generalizes better than FT+L. Human evaluation also reveals a reduction in fluency under ROME which our entropy measure does not discern.
Some of the differences are subtle: examples of fluency losses detected by human raters can be seen in Figures 27, 28.