{"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/position-aware-automatic-circuit-discovery","title":"Position-aware Automatic Circuit Discovery","arxiv_id":"2502.04577","date":"2025-02-07","proceeding":null,"authors":["Tal Haklay","Hadas Orgad","David Bau","Aaron Mueller","Yonatan Belinkov"],"abstract":"A widely used strategy to discover and understand language model mechanisms is circuit analysis. A circuit is a minimal subgraph of a model's computation graph that executes a specific task. We identify a gap in existing circuit discovery methods: they assume circuits are position-invariant, treating model components as equally relevant across input positions. This limits their ability to capture cross-positional interactions or mechanisms that vary across positions. To address this gap, we propose two improvements to incorporate positionality into circuits, even on tasks containing variable-length examples. First, we extend edge attribution patching, a gradient-based method for circuit discovery, to differentiate between token positions. Second, we introduce the concept of a dataset schema, which defines token spans with similar semantics across examples, enabling position-aware circuit discovery in datasets with variable length examples. We additionally develop an automated pipeline for schema generation and application using large language models. Our approach enables fully automated discovery of position-sensitive circuits, yielding better trade-offs between circuit size and faithfulness compared to prior work.","url_abs":"https://arxiv.org/abs/2502.04577v1","url_pdf":"https://arxiv.org/pdf/2502.04577v1.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":"position-aware-automatic-circuit-discovery","repo_url":"https://github.com/technion-cs-nlp/peap","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"jax","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":null,"task_name":"Position"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2502.04577","atlas_url":"https://app.syntology.ai/?focus=2502.04577","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2502.04577"}},"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":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/technion-cs-nlp/peap","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":7},"by_repo_kind":{"official":{"samples":7,"ran":7,"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":"c40af1a4ac756719","entry":"add_space","repo":"technion-cs-nlp/peap","repo_kind":"official","path":"src/data_generation.py","file_url":"https://github.com/technion-cs-nlp/peap/blob/HEAD/src/data_generation.py","link_basis":"harvester_set","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":"c40af1a4ac756719"}},{"code_sha256_prefix":"8572d3949ccf4d91","entry":"add_space","repo":"technion-cs-nlp/peap","repo_kind":"official","path":"src/eval_utils.py","file_url":"https://github.com/technion-cs-nlp/peap/blob/HEAD/src/eval_utils.py","link_basis":"harvester_set","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":"8572d3949ccf4d91"}},{"code_sha256_prefix":"fb7c8eea53bdfbcd","entry":"calculate_attention_scores","repo":"technion-cs-nlp/peap","repo_kind":"official","path":"src/pos_aware_edge_attribution_patching.py","file_url":"https://github.com/technion-cs-nlp/peap/blob/HEAD/src/pos_aware_edge_attribution_patching.py","link_basis":"harvester_set","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":"fb7c8eea53bdfbcd"}},{"code_sha256_prefix":"4f2dc50c45297504","entry":"calculate_heads_output","repo":"technion-cs-nlp/peap","repo_kind":"official","path":"src/pos_aware_edge_attribution_patching.py","file_url":"https://github.com/technion-cs-nlp/peap/blob/HEAD/src/pos_aware_edge_attribution_patching.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4f2dc50c45297504"}},{"code_sha256_prefix":"c800c06d3b65176c","entry":"calculate_z_scores","repo":"technion-cs-nlp/peap","repo_kind":"official","path":"src/pos_aware_edge_attribution_patching.py","file_url":"https://github.com/technion-cs-nlp/peap/blob/HEAD/src/pos_aware_edge_attribution_patching.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c800c06d3b65176c"}},{"code_sha256_prefix":"8b4f47c30fe2a5f9","entry":"call_chatgpt","repo":"technion-cs-nlp/peap","repo_kind":"official","path":"src/schema_generation.py","file_url":"https://github.com/technion-cs-nlp/peap/blob/HEAD/src/schema_generation.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8b4f47c30fe2a5f9"}},{"code_sha256_prefix":"3497e060ec8e3349","entry":"handle_error","repo":"technion-cs-nlp/peap","repo_kind":"official","path":"src/schema_generation.py","file_url":"https://github.com/technion-cs-nlp/peap/blob/HEAD/src/schema_generation.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3497e060ec8e3349"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}