← ProjectsModel editing

Edit one fact. What else changes?

Four studies on what happens when you change a fact inside a language model.

By Wanli Yang, Fei Sun & collaborators

Editing slipIllustrative example

Mara lives in

Original city: Rome New city: Oslo
After the edit

Which country does Mara live in?

Findings of ACL 2024

The Butterfly Effect of Model Editing

We used an editing method called ROME to update GPT-J on who acquired Twitter. Asked to tell a story, the model now produced a string of brackets. On a separate test, its accuracy at predicting the last word of a passage fell from 61.36% to zero.

After one edit, GPT-J’s story about a girl and a unicorn becomes repetitive fragments. Its scores fall on three unrelated tasks.
GPT-J received the same story prompt before and after the edit. Fig. 1

To find other failures, we measured how well each edited model predicted words in ordinary text. A sharp rise in perplexity signaled trouble. When we tested the 30 GPT-J edits with the highest perplexity, their average accuracy was close to chance on all three tasks above. Fig. 2

Which edits expose the damage?

Two copies of Llama 2 7B each received 107 edits using ROME. On the word-prediction task, accuracy stayed near its original level after randomly sampled edits. After edits drawn from known failure cases, it fell to zero.

Accuracy on three unrelated tasks
Task Before editing After random edits After difficult edits
Predict the last wordLAMBADA 68.14% 67.26% 0.00%
Choose a plausible continuationHellaSwag 57.06% 56.59% 26.09%
Choose a workable physical solutionPIQA 78.45% 77.97% 53.97%
Both sets came from CounterFact. The difficult set (HardCF) contains edits that had caused at least one tested model to fail. The authors also released HardEdit, a separate stress-test dataset. Table 4 · HardEdit, §7

Findings of EMNLP 2024

The Fall of ROME

ROME sometimes made a very large change to the model’s weights when updating a single fact. The cause was a mismatch between two representations of the same subject. Fixing that mismatch restored ordinary text prediction. Could the model also recall the new fact?

Why does it matter where “Paris” appears?

ROME edits a fact by changing how the model responds to its subject. The model represents the subject with a list of numbers called a key. The words before “Paris” can change its key.

No preceding words
Paris is in France.
With a prefix
As you know, Paris is in France.
Illustrative prompts. ROME computes a key for the subject after several different prefixes and takes their average. Equation 1

The ROME code mixed that average with the key computed without a prefix. When the two differed sharply, the formula could divide by a number close to zero. A single edit could then change the model’s weights enough to disrupt ordinary text generation. C-ROME used the same averaged key throughout the calculation. Equation 3 and its implementation (§3.1)

Nearly every GPT-J and GPT-2-XL collapse case began with a single-token subject. In GPT-2-XL, moving the subject later in the prompt made its key resemble those from ordinary edits. Figure 3

Single-edit results by model

For GPT-J, the number ROME divided by had an average absolute value of 12.78 across 1,000 ordinary edits. It shrank to 0.04 in edits known to cause collapse (HardCF). Table 1

Could GPT-J still predict ordinary text? Table 2 Highest perplexity on the ME-PPL50 text sample after a single edit. Higher means worse predictions of the next token. C-ROME stayed close to the unedited score of 49.04.
Single edits ROME C-ROME
1,000 sampled non-collapse cases 50.77 50.57
Known collapse cases (HardCF) 25,909.24 51.77

Could GPT-J recall the edited answer?

On the collapse cases, C-ROME’s recall score was 30.59% on the original prompts. Adding a prefix drawn from the editing step raised it to 100%. The score on rephrased questions was 32.94%. Tables 4–5

For GPT-2-XL, the number ROME divided by had an average absolute value of 9.60 across 1,000 ordinary edits. It shrank to 0.04 in edits known to cause collapse (HardCF). Table 1

Could GPT-2-XL still predict ordinary text? Table 2 Highest perplexity on the ME-PPL50 text sample after a single edit. Higher means worse predictions of the next token. C-ROME stayed close to the unedited score of 68.77.
Single edits ROME C-ROME
1,000 sampled non-collapse cases 74.32 70.28
Known collapse cases (HardCF) 26,084.66 70.71

Could GPT-2-XL recall the edited answer?

On the collapse cases, C-ROME’s recall score was 5.19% on the original prompts. Adding a prefix drawn from the editing step raised it to 100%. The score on rephrased questions was 16.88%. Tables 4–5

For Llama 2 7B, the number ROME divided by had an average absolute value of 2.63 across 1,000 ordinary edits. It shrank to 0.01 in edits known to cause collapse (HardCF). Table 1

Could Llama 2 7B still predict ordinary text? Table 2 Highest perplexity on the ME-PPL50 text sample after a single edit. Higher means worse predictions of the next token. C-ROME stayed close to the unedited score of 33.18.
Single edits ROME C-ROME
1,000 sampled non-collapse cases 36.68 33.55
Known collapse cases (HardCF) 10,574.76 33.20

Could Llama 2 7B recall the edited answer?

On the collapse cases, C-ROME’s recall score was 18.65% on the original prompts. Adding a prefix drawn from the editing step raised it to 91.27%. The score on rephrased questions was 29.37%. Tables 4–5

Why Llama 2 differed remains open. Llama 2 inserts a special token before the subject. All 21 of its HardCF cases had names ending in a period, such as “Joe Garagiola Sr.” In four other models, the same edits barely changed perplexity. Collapse after a sequence of edits remains a separate open question. Table 3 · Limitations

The Mirage of Model Editing

How much of a correct answer did the model produce on its own? Some editing tests give it words from the reference answer as it goes. We built QAEdit from questions each model had previously missed, then used WILD to score what the edited model generated on its own.

How much does the test change the score?

Synthetic test
96.8%The model gets the correct words so far. The test scores its next token (a word or part of one).
WILD test
38.5%The model writes its own answer. A judge scores the complete response.
Mean single-edit reliability across six editors on the same 12,715 QAEdit questions that Llama-2-7b-chat had initially missed. Results for each editor (Table 3)

Who wrote “If I Were a Boy”?

The reference answer is BC Jean and Toby Gad. Both runs begin with “Beyoncé”.

The synthetic test supplies BC after the first wrong guess, and the model predicts three of the five tokens correctly. WILD lets it continue from Beyoncé and it credits the wrong writer.
After the first guess, the synthetic test supplies “BC”. With the correct prefix at each step, the model gets three of five tokens right. Under WILD, it continues from “Beyoncé” and credits the wrong writer. Figure 3 · Full-size diagram

What if the model keeps talking?

One answer started with the expected date, April 1st, then contradicted itself by saying April 2nd. In a separate test of FT-M on Llama-3-8b with 3,000 QAEdit questions, a judge accepted 75.1% of answers cut off at the reference length. When the model chose when to stop, the same judge accepted 52.8%. Tables 6–8

Fine-tuning Done Right in Model Editing

Fine-tuning a model on one fact at a time can undo earlier edits. LocFT-BF revisits facts in batches and changes only selected weights. In the largest experiment it handled 100,000 edits, though it answered the original questions much more reliably than paraphrases.

When to revisit a fact

We tested two training schedules on the same 1,000 ZsRE edits using FT-M on Llama-3-8B-Instruct. Finishing one fact at a time let earlier edits fade. The model scored 75.3% on the original questions. Revisiting every fact on each pass raised that score to 99.7%. Table 1 & Fig. 3

Each dot marks one training update. Both schedules visit the same three facts three times. Based on Fig. 2

Depth-first

Repeat one fact before moving on.

Breadth-first

Visit every fact once per pass, then reshuffle.

How many facts per update?

With one fact per update, breadth-first training cut the model’s score on five general tasks from 57.26% to 39.3%. We tried batches of 1 to 64 examples. Larger batches preserved more of these skills, though scores on rephrased questions dipped slightly for FT-M and more for AdaLoRA. Fig. 4 · Unedited baseline

Which weights should change?

We tried five targets per layer on Llama-3-8B, from the entire layer down to one matrix in its feed-forward network. Across 160 trials on 1,000 edits, broader updates tended to handle rephrasing better. We chose targets that preserved more of the model’s ability to do math, translate, and answer questions across subjects. Fig. 5 & Table 2

Full fine-tuning vs. LocFT-BF

Each strip shows one model’s layers in order. The highlighted layer contains the weights trained by LocFT-BF.

Llama-3-8B after 3,000 ZsRE edits in LlamaFactory
Test All weights Selected weights
Original questions (reliability) 98.47% 95.07%
Rephrased questions (generalization) 87.57% 79.10%
General capability (five-task average) 40.44% 56.03%

Before editing, Llama-3-8B scored 57.26% on general capability.

Mistral-7B after 3,000 ZsRE edits in LlamaFactory
Test All weights Selected weights
Original questions (reliability) 96.43% 95.00%
Rephrased questions (generalization) 87.40% 71.43%
General capability (five-task average) 16.07% 41.38%

Before editing, Mistral-7B scored 44.82% on general capability.

Qwen2.5-7B after 3,000 ZsRE edits in LlamaFactory
Test All weights Selected weights
Original questions (reliability) 99.17% 98.77%
Rephrased questions (generalization) 84.73% 75.67%
General capability (five-task average) 59.05% 60.83%

Before editing, Qwen2.5-7B scored 58.52% on general capability.

Across all three models, training only the selected weights gave higher general capability scores and lower scores on rephrased questions. Table 8