{"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/mechanisms-of-non-factual-hallucinations-in","title":"Mechanistic Understanding and Mitigation of Language Model Non-Factual Hallucinations","arxiv_id":"2403.18167","date":"2024-03-27","proceeding":null,"authors":["Lei Yu","Meng Cao","Jackie Chi Kit Cheung","Yue Dong"],"abstract":"State-of-the-art language models (LMs) sometimes generate non-factual hallucinations that misalign with world knowledge. To explore the mechanistic causes of these hallucinations, we create diagnostic datasets with subject-relation queries and adapt interpretability methods to trace hallucinations through internal model representations. We discover two general and distinct mechanistic causes of hallucinations shared across LMs (Llama-2, Pythia, GPT-J): 1) knowledge enrichment hallucinations: insufficient subject attribute knowledge in lower layer MLPs, and 2) answer extraction hallucinations: failure to select the correct object attribute in upper layer attention heads. We also found these two internal mechanistic causes of hallucinations are reflected in external manifestations. Based on insights from our mechanistic analysis, we propose a novel hallucination mitigation method through targeted restoration of the LM's internal fact recall pipeline, demonstrating superior performance compared to baselines.","url_abs":"https://arxiv.org/abs/2403.18167v2","url_pdf":"https://arxiv.org/pdf/2403.18167v2.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":"mechanisms-of-non-factual-hallucinations-in","repo_url":"https://github.com/jadeleiyu/lm_hallucination_mechanisms","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"attribute","task_name":"Attribute"},{"task_slug":"diagnostic","task_name":"Diagnostic"},{"task_slug":"hallucination","task_name":"Hallucination"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"object","task_name":"Object"},{"task_slug":"world-knowledge","task_name":"World Knowledge"}],"methods":[{"method_slug":"pythia","method_name":"Pythia"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2403.18167","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2403.18167"}},"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/jadeleiyu/lm_hallucination_mechanisms","reach":null}],"summary":{"ran_fixture":2,"ran_violates":1,"ran_honours":1,"unverified":1},"by_repo_kind":{"official":{"samples":5,"ran":4,"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":5,"samples":[{"code_sha256_prefix":"81bf77133fd70403","entry":"get_key_pos_effects","repo":"jadeleiyu/lm_hallucination_mechanisms","repo_kind":"official","path":"src/hall_mech/cpi.py","file_url":"https://github.com/jadeleiyu/lm_hallucination_mechanisms/blob/HEAD/src/hall_mech/cpi.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"81bf77133fd70403"}},{"code_sha256_prefix":"199f089770d66ddc","entry":"get_top_pred_ents","repo":"jadeleiyu/lm_hallucination_mechanisms","repo_kind":"official","path":"src/hall_evol/pararel_lm_eval.py","file_url":"https://github.com/jadeleiyu/lm_hallucination_mechanisms/blob/HEAD/src/hall_evol/pararel_lm_eval.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"199f089770d66ddc"}},{"code_sha256_prefix":"49834773bd1d24db","entry":"get_true_obj_ranks","repo":"jadeleiyu/lm_hallucination_mechanisms","repo_kind":"official","path":"src/hall_evol/pararel_lm_eval.py","file_url":"https://github.com/jadeleiyu/lm_hallucination_mechanisms/blob/HEAD/src/hall_evol/pararel_lm_eval.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"49834773bd1d24db"}},{"code_sha256_prefix":"b0efe66854e42cd5","entry":"untuple","repo":"jadeleiyu/lm_hallucination_mechanisms","repo_kind":"official","path":"src/hall_mech/cpi.py","file_url":"https://github.com/jadeleiyu/lm_hallucination_mechanisms/blob/HEAD/src/hall_mech/cpi.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b0efe66854e42cd5"}},{"code_sha256_prefix":"82f1717a2c29255a","entry":"run_get_noise_and_te","repo":"jadeleiyu/lm_hallucination_mechanisms","repo_kind":"official","path":"src/hall_mech/cpi.py","file_url":"https://github.com/jadeleiyu/lm_hallucination_mechanisms/blob/HEAD/src/hall_mech/cpi.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":"82f1717a2c29255a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}