{"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/devils-in-middle-layers-of-large-vision","title":"Devils in Middle Layers of Large Vision-Language Models: Interpreting, Detecting and Mitigating Object Hallucinations via Attention Lens","arxiv_id":"2411.16724","date":"2024-11-23","proceeding":"CVPR 2025 1","authors":["Zhangqi Jiang","Junkai Chen","Beier Zhu","Tingjin Luo","Yankun Shen","Xu Yang"],"abstract":"Hallucinations in Large Vision-Language Models (LVLMs) significantly undermine their reliability, motivating researchers to explore the causes of hallucination. However, most studies primarily focus on the language aspect rather than the visual. In this paper, we address how LVLMs process visual information and whether this process causes hallucination. Firstly, we use the attention lens to identify the stages at which LVLMs handle visual data, discovering that the middle layers are crucial. Moreover, we find that these layers can be further divided into two stages: ''visual information enrichment'' and ''semantic refinement'' which respectively propagate visual data to object tokens and interpret it through text. By analyzing attention patterns during the visual information enrichment stage, we find that real tokens consistently receive higher attention weights than hallucinated ones, serving as a strong indicator of hallucination. Further examination of multi-head attention maps reveals that hallucination tokens often result from heads interacting with inconsistent objects. Based on these insights, we propose a simple inference-time method that adjusts visual attention by integrating information across various heads. Extensive experiments demonstrate that this approach effectively mitigates hallucinations in mainstream LVLMs without additional training costs. Code is available at https://github.com/ZhangqiJiang07/middle_layers_indicating_hallucinations.","url_abs":"https://arxiv.org/abs/2411.16724v3","url_pdf":"https://arxiv.org/pdf/2411.16724v3.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":"devils-in-middle-layers-of-large-vision","repo_url":"https://github.com/zhangqijiang07/middle_layers_indicating_hallucinations","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"hallucination","task_name":"Hallucination"}],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"focus","method_name":"Focus"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2411.16724","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2411.16724"}},"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/zhangqijiang07/middle_layers_indicating_hallucinations","reach":{"status":"ok"}}],"summary":{"ran_draft_wrong":5,"unverified":5},"by_repo_kind":{"official":{"samples":10,"ran":5,"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":10,"samples":[{"code_sha256_prefix":"25585704d77cafb4","entry":"combine_coco_captions","repo":"zhangqijiang07/middle_layers_indicating_hallucinations","repo_kind":"official","path":"chair.py","file_url":"https://github.com/zhangqijiang07/middle_layers_indicating_hallucinations/blob/HEAD/chair.py","link_basis":"harvester_set","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":"25585704d77cafb4"}},{"code_sha256_prefix":"66415dc1dd50f555","entry":"combine_coco_instances","repo":"zhangqijiang07/middle_layers_indicating_hallucinations","repo_kind":"official","path":"chair.py","file_url":"https://github.com/zhangqijiang07/middle_layers_indicating_hallucinations/blob/HEAD/chair.py","link_basis":"harvester_set","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":"66415dc1dd50f555"}},{"code_sha256_prefix":"592b3c1a88f93d7c","entry":"expand2square","repo":"zhangqijiang07/middle_layers_indicating_hallucinations","repo_kind":"official","path":"eval_data_loader.py","file_url":"https://github.com/zhangqijiang07/middle_layers_indicating_hallucinations/blob/HEAD/eval_data_loader.py","link_basis":"harvester_set","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":"592b3c1a88f93d7c"}},{"code_sha256_prefix":"42a46570620cd9fa","entry":"get_chunk","repo":"zhangqijiang07/middle_layers_indicating_hallucinations","repo_kind":"official","path":"llava/eval/model_vqa.py","file_url":"https://github.com/zhangqijiang07/middle_layers_indicating_hallucinations/blob/HEAD/llava/eval/model_vqa.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"42a46570620cd9fa"}},{"code_sha256_prefix":"076c252c52cbb161","entry":"split_list","repo":"zhangqijiang07/middle_layers_indicating_hallucinations","repo_kind":"official","path":"llava/eval/model_vqa.py","file_url":"https://github.com/zhangqijiang07/middle_layers_indicating_hallucinations/blob/HEAD/llava/eval/model_vqa.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"076c252c52cbb161"}},{"code_sha256_prefix":"0b24d3aebc841fa4","entry":"get_only_attn_out_contribution","repo":"zhangqijiang07/middle_layers_indicating_hallucinations","repo_kind":"official","path":"utils.py","file_url":"https://github.com/zhangqijiang07/middle_layers_indicating_hallucinations/blob/HEAD/utils.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":"0b24d3aebc841fa4"}},{"code_sha256_prefix":"62bb863d06274810","entry":"llama_new_forward","repo":"zhangqijiang07/middle_layers_indicating_hallucinations","repo_kind":"official","path":"modify_attention.py","file_url":"https://github.com/zhangqijiang07/middle_layers_indicating_hallucinations/blob/HEAD/modify_attention.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":"62bb863d06274810"}},{"code_sha256_prefix":"bb7b96236ae47aaf","entry":"load_generated_captions","repo":"zhangqijiang07/middle_layers_indicating_hallucinations","repo_kind":"official","path":"chair.py","file_url":"https://github.com/zhangqijiang07/middle_layers_indicating_hallucinations/blob/HEAD/chair.py","link_basis":"harvester_set","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":"bb7b96236ae47aaf"}},{"code_sha256_prefix":"b157d20a4ca304e6","entry":"load_llava_model","repo":"zhangqijiang07/middle_layers_indicating_hallucinations","repo_kind":"official","path":"model_manager.py","file_url":"https://github.com/zhangqijiang07/middle_layers_indicating_hallucinations/blob/HEAD/model_manager.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":"b157d20a4ca304e6"}},{"code_sha256_prefix":"a4bcce74aee1b2ac","entry":"set_act_get_hooks","repo":"zhangqijiang07/middle_layers_indicating_hallucinations","repo_kind":"official","path":"utils.py","file_url":"https://github.com/zhangqijiang07/middle_layers_indicating_hallucinations/blob/HEAD/utils.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":"a4bcce74aee1b2ac"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}