Moving the Eiffel Tower

We changed one matrix in a small language model so that it says "The Eiffel Tower is located in Rome, Italy", with no training. The best edit keeps the name and most of what the model knows about the tower. It isn't clean: it also says the capital of France is Rome, and the model still answers differently depending on how you ask.

The false answers below were produced on purpose for this experiment. The Eiffel Tower is in Paris.

What each attempt could use

Each edit changes one matrix of 884,736 weights, 0.66% of the model. All are rank one except attempt 4, which is rank two.

Attempt 1 changed no answers. Attempts 2 to 4 used all 50 passes between them. Attempts 2 and 3 both changed the answer, but by making the model misread the tower's name. Attempt 3 did it more cleanly, and it's the one shown below. So before attempt 4, a name test was added and fixed in advance: 8 prompts that make the model write the tower's name, which pass only if the reply still spells "Eiffel" correctly. Attempts 1 to 3 were scored on it afterwards. Attempt 5 came later, as an extra attempt with its own budget of 25 passes, of which it used 17. It could build on everything the first four had found out, so it isn't a fresh attempt in the same sense, and it's reported separately.

The best edit: attempt 5

Attempt 5 leaves the name tokens alone. It changes one matrix, W, in layer 27 of 30, and acts at the point in the sentence where the city name comes next. There, W turns the layer's input, a vector of 1,536 numbers, into an output of 576 numbers that's passed on towards the answer. The edit adds a push to that output along E(Rome) − E(Paris), the direction that favours "Rome" over "Paris" when the model picks its next word.

To act only when the model is about to name the tower's city, the edit has to recognise that moment.

Here is how we achieve that in the matrix weights

The edit recognises that moment with keys, obtained like this:

  1. Run the model on a sentence that stops right before the city, such as "The Eiffel Tower is located in the city of".
  2. Record the input W receives at the last word, "of". It's a list of 1,536 numbers that sums up what the model has worked out by that point. That list is a key: a kind of fingerprint of the situation "about to name the Eiffel Tower's city".
  3. Repeat with other wordings, as plain text and as the start of a chat answer, and average the keys from similar sentences. That gives two Eiffel Tower keys: one for sentences ending "…the city of", and one for sentences ending "…in".
  4. Do the same for eight other landmarks, such as the Arc de Triomphe and the Pantheon, with four sentences each. These 32 keys are situations the edit must leave alone.

The edit then changes W so that an input like either Eiffel Tower key gets an extra push towards Rome, while each landmark key still gets exactly its old output. The new matrix W' is worked out in one step:

W′=W+(V*−WK)(K⊤C−1K)−1K⊤C−1
  • K: the 34 keys, side by side: the two Eiffel Tower keys and the 32 landmark keys.
  • V*: the outputs wanted for those keys. For the Eiffel Tower keys, today's output plus the push towards Rome. For the landmarks, today's output, unchanged.
  • V*−WK: how far each key's current output is from the wanted one. That's the push for the Eiffel Tower keys, and zero for the landmarks.
  • C: a 1,536 × 1,536 matrix describing which input patterns are common. To get it, the model was run on 160 short ordinary texts, everyday sentences and passages from Python's documentation, up to 48 word pieces each, and W's input was recorded at every word piece. C is the average of each recorded input multiplied by itself, plus a little extra on its diagonal to keep it stable.
  • C−1: the inverse of C, which works the other way round: it shrinks patterns that are common in ordinary text and enlarges rare ones. Multiplying by it makes the change respond mostly to rare patterns, like the Eiffel Tower keys, so ordinary text is disturbed as little as possible.
  • K⊤C−1, at the end: what reacts to the input W receives. It compares that input with each key, after C⁻¹ has played down patterns common in ordinary text, and gives one similarity score per key.
  • (K⊤C−1K)−1: turns those scores into how much of each key's correction to apply. It's calibrated so that each key itself gets exactly its wanted output, no more and no less.
  • Together: read from right to left, the change compares an input with the keys, works out how much of each key's correction it should get, and adds those corrections to W's output. It's the smallest change to W, measured that way, that gives exactly the wanted outputs for these keys. Only the two Eiffel Tower keys need a change, and both in the same direction, so the change has rank one.

Where it works

The 8 frozen location tests: the 2 target questions and 6 rewordings. 7 of the 8 now answer Rome.

Replies are cut at 24 tokens.

Where it goes wrong

The Eiffel Tower isn't the only thing that triggers the edit. It also acts in some other sentences where the model is about to say Paris. Two neighbour tests fail, both about France's capital:

Outside the tests, the Moulin Rouge moved too, though not to Rome: "The Moulin Rouge is located in the city of" now continues with Marseille. Asked as a chat question, the model still puts it in Paris.

Asked anything else about it

These questions weren't in the tests. The name, height, designer and material survive. The result also shows this isn't a new belief: the model still says the famous tower in Paris is the Eiffel Tower, and it still calls Gustave Eiffel French.

Attempt 3: misreading the name

Attempt 3 acted at layer 0, where the token iffel gets its meaning, and made it look like Rome. It passed every location test at the time, but the model can no longer read the name and repeats it as "E Rome Tower", and it invents details to fit. Its replies to the same questions:

Trying to keep the name

Attempt 4 had the same goal as attempt 5, but it edited the name tokens at layer 20, where the search showed the model could still copy the name. It failed: none of the 8 replies keep the name, and most now say "The Eternal City". That failure is what led to leaving the name tokens alone in attempt 5.

Attempt 4's replies on the name test. Replies are cut at 48 tokens.

What stayed the same

Replies to the fact questions are cut at 24 tokens, and replies to the general prompts at 40.

In hindsight, the split between neighbours and unrelated facts isn't perfect: Big Ben, and some wordings of the Statue of Liberty and Golden Gate Bridge questions, would fit better as neighbours. The groups are shown as they were fixed before the first edit and used throughout the experiment.

Neighbours: other Paris, Rome and tower facts
Unrelated facts
General prompts