{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/locating-and-editing-factual-knowledge-in-gpt","title":"Locating and Editing Factual Associations in GPT","arxiv_id":"2202.05262","date":"2022-02-10","proceeding":null,"authors":["Kevin Meng","David Bau","Alex Andonian","Yonatan Belinkov"],"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 feed-forward 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, comparable to existing methods. To perform a more sensitive evaluation, we also evaluate ROME on a new dataset of 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/","url_abs":"https://arxiv.org/abs/2202.05262v5","url_pdf":"https://arxiv.org/pdf/2202.05262v5.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"locating-and-editing-factual-knowledge-in-gpt","repo_url":"https://github.com/kmeng01/rome","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null},{"paper_slug":"locating-and-editing-factual-knowledge-in-gpt","repo_url":"https://github.com/hiyouga/fastedit","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"locating-and-editing-factual-knowledge-in-gpt","repo_url":"https://github.com/keltin13/concept-rot","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"NOASSERTION"}},{"paper_slug":"locating-and-editing-factual-knowledge-in-gpt","repo_url":"https://gitee.com/zhengkeli/zkl-knowedit-rome","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"none","reach":null}],"tasks":[{"task_slug":"model-editing","task_name":"Model Editing"},{"task_slug":"relation-extraction","task_name":"Relation Extraction"},{"task_slug":"specificity","task_name":"Specificity"},{"task_slug":null,"task_name":"counterfactual"}],"methods":[{"method_slug":"rome","method_name":"ROME"}],"datasets_introduced":[],"methods_introduced":[{"slug":"rome","name":"ROME","full_name":"Rank-One Model Editing"}],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2202.05262","atlas_url":"https://app.syntology.ai/?focus=2202.05262","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2202.05262"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/EleutherAI/knowledge-neurons","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/kmeng01/rome","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/keltin13/concept-rot","reach":{"status":"ok","spdx":"NOASSERTION"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://gitee.com/zhengkeli/zkl-knowedit-rome","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/hiyouga/fastedit","reach":null}],"summary":{"ran_fixture":2,"ran":2,"unverified":11},"by_repo_kind":{"official":{"samples":1,"ran":1,"repositories":1},"listed":{"samples":12,"ran":2,"repositories":1},"found_in_text":{"samples":2,"ran":1,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"3a7359734df0b9a0","entry":"upd_matrix_match_shape","repo":"kmeng01/rome","repo_kind":"official","path":"rome/rome_main.py","file_url":"https://github.com/kmeng01/rome/blob/HEAD/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":2,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3a7359734df0b9a0"}},{"code_sha256_prefix":"a79ceec9a50ca78f","entry":"Patch","repo":"EleutherAI/knowledge-neurons","repo_kind":"found_in_text","path":"knowledge_neurons/patch.py","file_url":"https://github.com/EleutherAI/knowledge-neurons/blob/HEAD/knowledge_neurons/patch.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a79ceec9a50ca78f"}},{"code_sha256_prefix":"337cf805ba7488b9","entry":"ROMEHyperParams","repo":"hiyouga/fastedit","repo_kind":"listed","path":"fastedit/rome/rome_main.py","file_url":"https://github.com/hiyouga/fastedit/blob/HEAD/fastedit/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"337cf805ba7488b9"}},{"code_sha256_prefix":"be38085054387516","entry":"find_fact_lookup_idx","repo":"hiyouga/fastedit","repo_kind":"listed","path":"fastedit/rome/rome_main.py","file_url":"https://github.com/hiyouga/fastedit/blob/HEAD/fastedit/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"be38085054387516"}},{"code_sha256_prefix":"b93905c630cab5f8","entry":"HyperParams","repo":"hiyouga/fastedit","repo_kind":"listed","path":"fastedit/rome/rome_main.py","file_url":"https://github.com/hiyouga/fastedit/blob/HEAD/fastedit/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b93905c630cab5f8"}},{"code_sha256_prefix":"38ac32a8532239ff","entry":"apply_rome_to_model","repo":"hiyouga/fastedit","repo_kind":"listed","path":"fastedit/rome/rome_main.py","file_url":"https://github.com/hiyouga/fastedit/blob/HEAD/fastedit/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"38ac32a8532239ff"}},{"code_sha256_prefix":"2ab22a551cc021f7","entry":"compute_u","repo":"hiyouga/fastedit","repo_kind":"listed","path":"fastedit/rome/rome_main.py","file_url":"https://github.com/hiyouga/fastedit/blob/HEAD/fastedit/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"2ab22a551cc021f7"}},{"code_sha256_prefix":"39f6e26e03a21b1e","entry":"compute_v","repo":"hiyouga/fastedit","repo_kind":"listed","path":"fastedit/rome/rome_main.py","file_url":"https://github.com/hiyouga/fastedit/blob/HEAD/fastedit/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"39f6e26e03a21b1e"}},{"code_sha256_prefix":"20e375abcab5cc8a","entry":"execute_rome","repo":"hiyouga/fastedit","repo_kind":"listed","path":"fastedit/rome/rome_main.py","file_url":"https://github.com/hiyouga/fastedit/blob/HEAD/fastedit/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"20e375abcab5cc8a"}},{"code_sha256_prefix":"196e16a6fd176c0b","entry":"get_inv_cov","repo":"hiyouga/fastedit","repo_kind":"listed","path":"fastedit/rome/rome_main.py","file_url":"https://github.com/hiyouga/fastedit/blob/HEAD/fastedit/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"196e16a6fd176c0b"}},{"code_sha256_prefix":"98f3e85c4a9f9bb3","entry":"get_module_input_output_at_word","repo":"hiyouga/fastedit","repo_kind":"listed","path":"fastedit/rome/rome_main.py","file_url":"https://github.com/hiyouga/fastedit/blob/HEAD/fastedit/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"98f3e85c4a9f9bb3"}},{"code_sha256_prefix":"7c626c3970ff2baf","entry":"get_reprs_at_idxs","repo":"hiyouga/fastedit","repo_kind":"listed","path":"fastedit/rome/rome_main.py","file_url":"https://github.com/hiyouga/fastedit/blob/HEAD/fastedit/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7c626c3970ff2baf"}},{"code_sha256_prefix":"96bd9a8c0145d685","entry":"get_reprs_at_word_tokens","repo":"hiyouga/fastedit","repo_kind":"listed","path":"fastedit/rome/rome_main.py","file_url":"https://github.com/hiyouga/fastedit/blob/HEAD/fastedit/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"96bd9a8c0145d685"}},{"code_sha256_prefix":"612d15cebbf71774","entry":"get_words_idxs_in_templates","repo":"hiyouga/fastedit","repo_kind":"listed","path":"fastedit/rome/rome_main.py","file_url":"https://github.com/hiyouga/fastedit/blob/HEAD/fastedit/rome/rome_main.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"612d15cebbf71774"}},{"code_sha256_prefix":"9412d866514a01ef","entry":"patch_ff_layer","repo":"EleutherAI/knowledge-neurons","repo_kind":"found_in_text","path":"knowledge_neurons/patch.py","file_url":"https://github.com/EleutherAI/knowledge-neurons/blob/HEAD/knowledge_neurons/patch.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9412d866514a01ef"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}