Knowledge Editing › A worked example, by hand

Michael BrenndoerferDecember 1, 20263 min read
Language AI HandbookAll chapters
Part 45 of 67Knowledge, Memory, Editing, and Unlearning
Chapter 347Knowledge Editing › A worked example, by hand
Reading section 7 of 11 · A worked example, by hand · 3 minSection 7 of 11 · 3 min

Section 7 of 11 · 3 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Let us make ROME concrete with a two-dimensional toy so the algebra is visible. Suppose a single FFN's value matrix is

W=(1002),W = \begin{pmatrix} 1 & 0 \\ 0 & 2 \end{pmatrix},

and the key for the boat "the boat is in ___" is k=(11)k = \begin{pmatrix} 1 \\ 1 \end{pmatrix}, so the base model retrieves Wk=(12)Wk = \begin{pmatrix} 1 \\ 2 \end{pmatrix}, i.e., "the boat is in the [sea at] (1,2)". We want it to instead retrieve v⋆=(03)v^\star = \begin{pmatrix} 0 \\ 3 \end{pmatrix}. Take the key second moment to be C=(2002)C = \begin{pmatrix} 2 & 0 \\ 0 & 2 \end{pmatrix}, so C−1=I/2C^{-1} = I/2. Then

C−1k=(0.50.5),β=(C−1k)⊤k=0.5+0.5=1.C^{-1} k = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}, \qquad \beta = (C^{-1}k)^\top k = 0.5 + 0.5 = 1.

The needed change in output is v⋆−Wk=(−11)v^\star - Wk = \begin{pmatrix} -1 \\ 1 \end{pmatrix}, so

Λ=11(−11)=(−11).\Lambda = \frac{1}{1}\begin{pmatrix} -1 \\ 1 \end{pmatrix} = \begin{pmatrix} -1 \\ 1 \end{pmatrix}.

The rank-one update is Δ=Λ(C−1k)⊤=(−11)(0.50.5)=(−0.5−0.50.50.5)\Delta = \Lambda (C^{-1}k)^\top = \begin{pmatrix} -1 \\ 1 \end{pmatrix} \begin{pmatrix} 0.5 & 0.5 \end{pmatrix} = \begin{pmatrix} -0.5 & -0.5 \\ 0.5 & 0.5 \end{pmatrix}, so

W^=W+Δ=(0.5−0.50.52.5).\hat{W} = W + \Delta = \begin{pmatrix} 0.5 & -0.5 \\ 0.5 & 2.5 \end{pmatrix}.

Check: W^k=(0.5−0.50.5+2.5)=(03)=v⋆\hat{W}k = \begin{pmatrix} 0.5 - 0.5 \\ 0.5 + 2.5 \end{pmatrix} = \begin{pmatrix} 0 \\ 3 \end{pmatrix} = v^\star. The edit worked.

Now check locality. Take a second key k′=(1−1)k' = \begin{pmatrix} 1 \\ -1 \end{pmatrix}, unrelated to the edited fact. The unedited output is Wk′=(1−2)Wk' = \begin{pmatrix} 1 \\ -2 \end{pmatrix}; the edited output is W^k′=(0.5+0.50.5−2.5)=(1−2)\hat{W}k' = \begin{pmatrix} 0.5 + 0.5 \\ 0.5 - 2.5 \end{pmatrix} = \begin{pmatrix} 1 \\ -2 \end{pmatrix}. Identical. The update, because it was constructed with C−1=I/2C^{-1} = I/2 along a symmetric key, happened to leave this particular k′k' untouched. In general, a key k′k' aligned with kk will shift; one orthogonal to the update's sensitive direction will not. This is the concrete meaning of "minimum expected disturbance," and running this arithmetic by hand is the best way to internalize why C−1C^{-1} is the stabilizing ingredient.

In this hand calculation C=2IC=2I, so C−1kC^{-1}k is parallel to kk. For this particular control key, its dot product with either direction is zero. A nearby control with a different angle could move, and a different reference moment could rotate the write direction. This is the reason to keep a control set alongside the edit key in the experiment, instead of treating one preserved control as evidence for all other queries.

The example also previews the evaluation structure. We have three prompts, not one: the edit prompt whose key is kk, a paraphrase that should also hit the edit (same underlying kk up to surface variation), and an unrelated prompt with key k′k' that must remain unchanged. Reporting "the edit worked" on prompt one alone would tell us nothing about generalization or specificity. Now let's build the harness.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy