{"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/label-words-are-anchors-an-information-flow","title":"Label Words are Anchors: An Information Flow Perspective for Understanding In-Context Learning","arxiv_id":"2305.14160","date":"2023-05-23","proceeding":null,"authors":["Lean Wang","Lei LI","Damai Dai","Deli Chen","Hao Zhou","Fandong Meng","Jie zhou","Xu sun"],"abstract":"In-context learning (ICL) emerges as a promising capability of large language models (LLMs) by providing them with demonstration examples to perform diverse tasks. However, the underlying mechanism of how LLMs learn from the provided context remains under-explored. In this paper, we investigate the working mechanism of ICL through an information flow lens. Our findings reveal that label words in the demonstration examples function as anchors: (1) semantic information aggregates into label word representations during the shallow computation layers' processing; (2) the consolidated information in label words serves as a reference for LLMs' final predictions. Based on these insights, we introduce an anchor re-weighting method to improve ICL performance, a demonstration compression technique to expedite inference, and an analysis framework for diagnosing ICL errors in GPT2-XL. The promising applications of our findings again validate the uncovered ICL working mechanism and pave the way for future studies.","url_abs":"https://arxiv.org/abs/2305.14160v4","url_pdf":"https://arxiv.org/pdf/2305.14160v4.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":"label-words-are-anchors-an-information-flow","repo_url":"https://github.com/lancopku/label-words-are-anchors","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"label-words-are-anchors-an-information-flow","repo_url":"https://github.com/alibaba/thinking_bias","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"label-words-are-anchors-an-information-flow","repo_url":"https://github.com/eit-nlp/2d-coordinate-system-for-icl","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"in-context-learning","task_name":"In-Context Learning"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2305.14160","atlas_url":"https://app.syntology.ai/?focus=2305.14160","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2305.14160"}},"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/alibaba/thinking_bias","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/eit-nlp/2d-coordinate-system-for-icl","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/lancopku/label-words-are-anchors","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":3},"by_repo_kind":{"official":{"samples":1,"ran":0,"repositories":1},"listed":{"samples":2,"ran":0,"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":"439b51f3f4ee8773","entry":"compute_saliency_score","repo":"alibaba/thinking_bias","repo_kind":"listed","path":"src/saliency_score_computation.py","file_url":"https://github.com/alibaba/thinking_bias/blob/HEAD/src/saliency_score_computation.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"439b51f3f4ee8773"}},{"code_sha256_prefix":"c517fc3db6c40282","entry":"get_proportion","repo":"lancopku/label-words-are-anchors","repo_kind":"official","path":"attention_attr.py","file_url":"https://github.com/lancopku/label-words-are-anchors/blob/HEAD/attention_attr.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c517fc3db6c40282"}},{"code_sha256_prefix":"6113cae3fd434820","entry":"get_saliency_maps","repo":"alibaba/thinking_bias","repo_kind":"listed","path":"src/saliency_score_computation.py","file_url":"https://github.com/alibaba/thinking_bias/blob/HEAD/src/saliency_score_computation.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6113cae3fd434820"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}