{"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/attention-satisfies-a-constraint-satisfaction","title":"Attention Satisfies: A Constraint-Satisfaction Lens on Factual Errors of Language Models","arxiv_id":"2309.15098","date":"2023-09-26","proceeding":null,"authors":["Mert Yuksekgonul","Varun Chandrasekaran","Erik Jones","Suriya Gunasekar","Ranjita Naik","Hamid Palangi","Ece Kamar","Besmira Nushi"],"abstract":"We investigate the internal behavior of Transformer-based Large Language Models (LLMs) when they generate factually incorrect text. We propose modeling factual queries as constraint satisfaction problems and use this framework to investigate how the LLM interacts internally with factual constraints. We find a strong positive relationship between the LLM's attention to constraint tokens and the factual accuracy of generations. We curate a suite of 10 datasets containing over 40,000 prompts to study the task of predicting factual errors with the Llama-2 family across all scales (7B, 13B, 70B). We propose SAT Probe, a method probing attention patterns, that can predict factual errors and fine-grained constraint satisfaction, and allow early error identification. The approach and findings take another step towards using the mechanistic understanding of LLMs to enhance their reliability.","url_abs":"https://arxiv.org/abs/2309.15098v2","url_pdf":"https://arxiv.org/pdf/2309.15098v2.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":"attention-satisfies-a-constraint-satisfaction","repo_url":"https://github.com/microsoft/mechanistic-error-probe","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2309.15098","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2309.15098"}},"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":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/microsoft/mechanistic-error-probe","reach":null}],"summary":{"ran":1,"ran_fixture":2,"ran_honours":1,"ran_draft_wrong":3,"unverified":4},"by_repo_kind":{"official":{"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":11,"samples":[{"code_sha256_prefix":"d350af5b5c8ee615","entry":"StopForward","repo":"microsoft/mechanistic-error-probe","repo_kind":"official","path":"model_lib/attention_tools.py","file_url":"https://github.com/microsoft/mechanistic-error-probe/blob/HEAD/model_lib/attention_tools.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"d350af5b5c8ee615"}},{"code_sha256_prefix":"56d9c31f9a8ddc6d","entry":"find_sub_list","repo":"microsoft/mechanistic-error-probe","repo_kind":"official","path":"model_lib/attention_tools.py","file_url":"https://github.com/microsoft/mechanistic-error-probe/blob/HEAD/model_lib/attention_tools.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"56d9c31f9a8ddc6d"}},{"code_sha256_prefix":"4546d6be91afba23","entry":"find_within_text","repo":"microsoft/mechanistic-error-probe","repo_kind":"official","path":"model_lib/attention_tools.py","file_url":"https://github.com/microsoft/mechanistic-error-probe/blob/HEAD/model_lib/attention_tools.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"4546d6be91afba23"}},{"code_sha256_prefix":"8953f9ef90cf6afd","entry":"get_module","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"8953f9ef90cf6afd"}},{"code_sha256_prefix":"90cd8804aa1b1e64","entry":"invoke_with_optional_args","repo":"microsoft/mechanistic-error-probe","repo_kind":"official","path":"model_lib/attention_tools.py","file_url":"https://github.com/microsoft/mechanistic-error-probe/blob/HEAD/model_lib/attention_tools.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"90cd8804aa1b1e64"}},{"code_sha256_prefix":"89c23643de6b387c","entry":"recursive_copy","repo":"microsoft/mechanistic-error-probe","repo_kind":"official","path":"model_lib/attention_tools.py","file_url":"https://github.com/microsoft/mechanistic-error-probe/blob/HEAD/model_lib/attention_tools.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":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"89c23643de6b387c"}},{"code_sha256_prefix":"3281dccd4fa39596","entry":"repeat_kv","repo":"microsoft/mechanistic-error-probe","repo_kind":"official","path":"model_lib/attention_tools.py","file_url":"https://github.com/microsoft/mechanistic-error-probe/blob/HEAD/model_lib/attention_tools.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"3281dccd4fa39596"}},{"code_sha256_prefix":"0aeb158b537a2630","entry":"Trace","repo":"microsoft/mechanistic-error-probe","repo_kind":"official","path":"model_lib/attention_tools.py","file_url":"https://github.com/microsoft/mechanistic-error-probe/blob/HEAD/model_lib/attention_tools.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"0aeb158b537a2630"}},{"code_sha256_prefix":"8717ccf6ff080a13","entry":"TraceDict","repo":"microsoft/mechanistic-error-probe","repo_kind":"official","path":"model_lib/attention_tools.py","file_url":"https://github.com/microsoft/mechanistic-error-probe/blob/HEAD/model_lib/attention_tools.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"8717ccf6ff080a13"}},{"code_sha256_prefix":"4d46774ab77c1ff3","entry":"get_metrics","repo":"microsoft/mechanistic-error-probe","repo_kind":"official","path":"main_probe.py","file_url":"https://github.com/microsoft/mechanistic-error-probe/blob/HEAD/main_probe.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"4d46774ab77c1ff3"}},{"code_sha256_prefix":"4c40a34cc6ec66e9","entry":"run_attention_monitor","repo":"microsoft/mechanistic-error-probe","repo_kind":"official","path":"model_lib/attention_tools.py","file_url":"https://github.com/microsoft/mechanistic-error-probe/blob/HEAD/model_lib/attention_tools.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"4c40a34cc6ec66e9"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}