{"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/arxiv-2602-04752","title":"Decomposing Query-Key Feature Interactions Using Contrastive Covariances","arxiv_id":"2602.04752","date":"2026-02-04","proceeding":"ICML","authors":["Andrew Lee","Yonatan Belinkov","Fernanda Viégas","Martin Wattenberg"],"abstract":"Despite the central role of attention heads in Transformers, we lack tools to understand why a model attends to a particular token. To address this, we study the query-key (QK) space -- the bilinear joint embedding space between queries and keys. We present a contrastive covariance method to decompose the QK space into low-rank, human-interpretable components. It is when features in keys and queries align in these low-rank subspaces that high attention scores are produced. We first study our method both analytically and empirically in a simplified setting. We then apply our method to large language models to identify human-interpretable QK subspaces for categorical semantic features and binding features. Finally, we demonstrate how attention scores can be attributed to our identified features.","url_abs":"https://arxiv.org/abs/2602.04752","url_pdf":"https://arxiv.org/pdf/2602.04752","source":{"archive":null,"snapshot":"2025-07-28","note":"not in the Papers with Code archive (frozen at the snapshot)","row_kind":"graph","title_abstract_authors_date":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)"},"code_links":[],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2602.04752","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2602.04752"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+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":[{"mentioned_in_github":null,"is_official":null,"provenance":"deterministic:regex_extraction","mentioned_in_paper":null,"url":"https://github.com/ajyl/QK","reach":null}],"summary":{"ran":3,"ran_honours":2,"ran_draft_wrong":9,"ran_fixture":1,"unverified":3},"by_repo_kind":{"found_in_text":{"samples":18,"ran":15,"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":18,"samples":[{"code_sha256_prefix":"e881499d75d53854","entry":"Query","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e881499d75d53854"}},{"code_sha256_prefix":"5301894f52f037d0","entry":"Schema","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5301894f52f037d0"}},{"code_sha256_prefix":"564397585671f0f7","entry":"Templates","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"564397585671f0f7"}},{"code_sha256_prefix":"a78b1e55b071156d","entry":"_collect_lex_key_timesteps","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a78b1e55b071156d"}},{"code_sha256_prefix":"5741470e10ac5c65","entry":"_create_read_hook","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5741470e10ac5c65"}},{"code_sha256_prefix":"99df6e3e500ef11b","entry":"_format_list","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"99df6e3e500ef11b"}},{"code_sha256_prefix":"08a15ccfe748a3ce","entry":"_get_lex_ans_timesteps","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"08a15ccfe748a3ce"}},{"code_sha256_prefix":"aa9b325b527664e3","entry":"build_counterfactual_lexical","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"aa9b325b527664e3"}},{"code_sha256_prefix":"004f50dff2fb2e67","entry":"fill_prompt","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"004f50dff2fb2e67"}},{"code_sha256_prefix":"06fef82ba57b1610","entry":"format_prompts","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"06fef82ba57b1610"}},{"code_sha256_prefix":"871dee43b37fa18a","entry":"get_module","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"871dee43b37fa18a"}},{"code_sha256_prefix":"06e977e37c0a0193","entry":"index_query_key_vecs_lex","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"06e977e37c0a0193"}},{"code_sha256_prefix":"c28aaebf04ed0971","entry":"record_activations","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c28aaebf04ed0971"}},{"code_sha256_prefix":"7a880d8b6a8f1530","entry":"to_str_tokens","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7a880d8b6a8f1530"}},{"code_sha256_prefix":"0d1b4b7a64984981","entry":"untuple_tensor","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0d1b4b7a64984981"}},{"code_sha256_prefix":"c0379438487542dd","entry":"_build_C_lexical","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c0379438487542dd"}},{"code_sha256_prefix":"c4c3ba954999de6c","entry":"get_C_lex_batch","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c4c3ba954999de6c"}},{"code_sha256_prefix":"d27cd4e01f8f478c","entry":"run_forward_pass","repo":"ajyl/QK","repo_kind":"found_in_text","path":"src/binding/C_lex.py","file_url":"https://github.com/ajyl/QK/blob/HEAD/src/binding/C_lex.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d27cd4e01f8f478c"}}]},"arxiv_metadata":{"licence":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)","fields":["title","abstract","authors","date"],"primary_category":"cs.LG","source":"arxiv_2026.jsonl"},"syntology_extracted_results":null}