SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2202.05262 · NeurIPS · 2022

Locating and Editing Factual Associations in GPT

Alex Andonian, Yonatan Belinkov, David Bau, Kevin Meng

arXiv · PDF · Open in the Atlas

Code that ran

We lifted 15 functions out of this paper's own repositories and ran 4 of them in a sandbox. "Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results.

RepositoryRoleRan
kmeng01/rome canonical 1 of 1
hiyouga/fastedit — 2 of 12
EleutherAI/knowledge-neurons — 1 of 2
FunctionStatusWhere it lives
upd_matrix_match_shape Ran kmeng01/rome/rome/rome_main.py
code served (permissive licence) · get_code("3a7359734df0b9a0")
Patch Ran EleutherAI/knowledge-neurons/knowledge_neurons/patch.py
code served (permissive licence) · get_code("a79ceec9a50ca78f")
ROMEHyperParams Ran hiyouga/fastedit/fastedit/rome/rome_main.py
code served (permissive licence) · get_code("337cf805ba7488b9")
find_fact_lookup_idx Ran hiyouga/fastedit/fastedit/rome/rome_main.py
code served (permissive licence) · get_code("be38085054387516")
HyperParams Not yet run hiyouga/fastedit/fastedit/rome/rome_main.py
code served (permissive licence) · get_code("b93905c630cab5f8")
apply_rome_to_model Not yet run hiyouga/fastedit/fastedit/rome/rome_main.py
code served (permissive licence) · get_code("38ac32a8532239ff")
compute_u Not yet run hiyouga/fastedit/fastedit/rome/rome_main.py
code served (permissive licence) · get_code("2ab22a551cc021f7")
compute_v Not yet run hiyouga/fastedit/fastedit/rome/rome_main.py
code served (permissive licence) · get_code("39f6e26e03a21b1e")
execute_rome Not yet run hiyouga/fastedit/fastedit/rome/rome_main.py
code served (permissive licence) · get_code("20e375abcab5cc8a")
get_inv_cov Not yet run hiyouga/fastedit/fastedit/rome/rome_main.py
code served (permissive licence) · get_code("196e16a6fd176c0b")
get_module_input_output_at_word Not yet run hiyouga/fastedit/fastedit/rome/rome_main.py
code served (permissive licence) · get_code("98f3e85c4a9f9bb3")
get_reprs_at_idxs Not yet run hiyouga/fastedit/fastedit/rome/rome_main.py
code served (permissive licence) · get_code("7c626c3970ff2baf")
get_reprs_at_word_tokens Not yet run hiyouga/fastedit/fastedit/rome/rome_main.py
code served (permissive licence) · get_code("96bd9a8c0145d685")
get_words_idxs_in_templates Not yet run hiyouga/fastedit/fastedit/rome/rome_main.py
code served (permissive licence) · get_code("612d15cebbf71774")
patch_ff_layer Not yet run EleutherAI/knowledge-neurons/knowledge_neurons/patch.py
code served (permissive licence) · get_code("9412d866514a01ef")

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

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/.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2202.05262")
get_code_for_paper("2202.05262")
have("2202.05262")

Connect an agent — have() is free.