{"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/pyvene-a-library-for-understanding-and","title":"pyvene: A Library for Understanding and Improving PyTorch Models via Interventions","arxiv_id":"2403.07809","date":"2024-03-12","proceeding":null,"authors":["Zhengxuan Wu","Atticus Geiger","Aryaman Arora","Jing Huang","Zheng Wang","Noah D. Goodman","Christopher D. Manning","Christopher Potts"],"abstract":"Interventions on model-internal states are fundamental operations in many areas of AI, including model editing, steering, robustness, and interpretability. To facilitate such research, we introduce $\\textbf{pyvene}$, an open-source Python library that supports customizable interventions on a range of different PyTorch modules. $\\textbf{pyvene}$ supports complex intervention schemes with an intuitive configuration format, and its interventions can be static or include trainable parameters. We show how $\\textbf{pyvene}$ provides a unified and extensible framework for performing interventions on neural models and sharing the intervened upon models with others. We illustrate the power of the library via interpretability analyses using causal abstraction and knowledge localization. We publish our library through Python Package Index (PyPI) and provide code, documentation, and tutorials at https://github.com/stanfordnlp/pyvene.","url_abs":"https://arxiv.org/abs/2403.07809v1","url_pdf":"https://arxiv.org/pdf/2403.07809v1.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":"pyvene-a-library-for-understanding-and","repo_url":"https://github.com/stanfordnlp/pyvene","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"pyvene-a-library-for-understanding-and","repo_url":"https://github.com/frankaging/pyvene","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"pyvene-a-library-for-understanding-and","repo_url":"https://github.com/stanfordnlp/pyreft","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"model-editing","task_name":"Model Editing"}],"methods":[{"method_slug":null,"method_name":"Library"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2403.07809","atlas_url":"https://app.syntology.ai/?focus=2403.07809","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2403.07809"}},"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/stanfordnlp/pyvene","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/frankaging/pyvene","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/stanfordnlp/pyreft","reach":null}],"summary":{"ran":5,"ran_draft_wrong":1,"unverified":4},"by_repo_kind":{"listed":{"samples":10,"ran":6,"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":"595a06b9091701fd","entry":"broadcast_tensor_v1","repo":"frankaging/pyvene","repo_kind":"listed","path":"pyvene/models/intervention_utils.py","file_url":"https://github.com/frankaging/pyvene/blob/HEAD/pyvene/models/intervention_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"595a06b9091701fd"}},{"code_sha256_prefix":"e6fa80bf2dce57f3","entry":"embed_to_distrib","repo":"frankaging/pyvene","repo_kind":"listed","path":"pyvene/models/basic_utils.py","file_url":"https://github.com/frankaging/pyvene/blob/HEAD/pyvene/models/basic_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e6fa80bf2dce57f3"}},{"code_sha256_prefix":"fd1cb0e0f7713047","entry":"get_internal_model_type","repo":"frankaging/pyvene","repo_kind":"listed","path":"pyvene/models/modeling_utils.py","file_url":"https://github.com/frankaging/pyvene/blob/HEAD/pyvene/models/modeling_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"fd1cb0e0f7713047"}},{"code_sha256_prefix":"9539ef9c23b94162","entry":"get_type_from_string","repo":"frankaging/pyvene","repo_kind":"listed","path":"pyvene/models/basic_utils.py","file_url":"https://github.com/frankaging/pyvene/blob/HEAD/pyvene/models/basic_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"9539ef9c23b94162"}},{"code_sha256_prefix":"39eceb45250b08ff","entry":"sigmoid_boundary","repo":"frankaging/pyvene","repo_kind":"listed","path":"pyvene/models/basic_utils.py","file_url":"https://github.com/frankaging/pyvene/blob/HEAD/pyvene/models/basic_utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"39eceb45250b08ff"}},{"code_sha256_prefix":"a2d93b74f75430a8","entry":"split_heads","repo":"frankaging/pyvene","repo_kind":"listed","path":"pyvene/models/constants.py","file_url":"https://github.com/frankaging/pyvene/blob/HEAD/pyvene/models/constants.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a2d93b74f75430a8"}},{"code_sha256_prefix":"20eb71d8a67805e3","entry":"broadcast_tensor_v2","repo":"frankaging/pyvene","repo_kind":"listed","path":"pyvene/models/intervention_utils.py","file_url":"https://github.com/frankaging/pyvene/blob/HEAD/pyvene/models/intervention_utils.py","link_basis":"harvester_set","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":"20eb71d8a67805e3"}},{"code_sha256_prefix":"66d7bf90ca55ef33","entry":"create_backpack_gpt2","repo":"frankaging/pyvene","repo_kind":"listed","path":"pyvene/models/backpack_gpt2/modelings_intervenable_backpack_gpt2.py","file_url":"https://github.com/frankaging/pyvene/blob/HEAD/pyvene/models/backpack_gpt2/modelings_intervenable_backpack_gpt2.py","link_basis":"harvester_set","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":"66d7bf90ca55ef33"}},{"code_sha256_prefix":"9eb295208e5af61d","entry":"is_gru","repo":"frankaging/pyvene","repo_kind":"listed","path":"pyvene/models/modeling_utils.py","file_url":"https://github.com/frankaging/pyvene/blob/HEAD/pyvene/models/modeling_utils.py","link_basis":"harvester_set","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":"9eb295208e5af61d"}},{"code_sha256_prefix":"d8f71d28a49db6a2","entry":"is_stateless","repo":"frankaging/pyvene","repo_kind":"listed","path":"pyvene/models/modeling_utils.py","file_url":"https://github.com/frankaging/pyvene/blob/HEAD/pyvene/models/modeling_utils.py","link_basis":"harvester_set","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":"d8f71d28a49db6a2"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}