{"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/what-in-context-learning-learns-in-context","title":"What In-Context Learning \"Learns\" In-Context: Disentangling Task Recognition and Task Learning","arxiv_id":"2305.09731","date":"2023-05-16","proceeding":null,"authors":["Jane Pan","Tianyu Gao","Howard Chen","Danqi Chen"],"abstract":"Large language models (LLMs) exploit in-context learning (ICL) to solve tasks with only a few demonstrations, but its mechanisms are not yet well-understood. Some works suggest that LLMs only recall already learned concepts from pre-training, while others hint that ICL performs implicit learning over demonstrations. We characterize two ways through which ICL leverages demonstrations. Task recognition (TR) captures the extent to which LLMs can recognize a task through demonstrations -- even without ground-truth labels -- and apply their pre-trained priors, whereas task learning (TL) is the ability to capture new input-label mappings unseen in pre-training. Using a wide range of classification datasets and three LLM families (GPT-3, LLaMA and OPT), we design controlled experiments to disentangle the roles of TR and TL in ICL. We show that (1) models can achieve non-trivial performance with only TR, and TR does not further improve with larger models or more demonstrations; (2) LLMs acquire TL as the model scales, and TL's performance consistently improves with more demonstrations in context. Our findings unravel two different forces behind ICL and we advocate for discriminating them in future ICL research due to their distinct nature.","url_abs":"https://arxiv.org/abs/2305.09731v1","url_pdf":"https://arxiv.org/pdf/2305.09731v1.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":"what-in-context-learning-learns-in-context","repo_url":"https://github.com/princeton-nlp/whaticllearns","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"in-context-learning","task_name":"In-Context Learning"}],"methods":[{"method_slug":"hint","method_name":"HINT"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2305.09731","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2305.09731"}},"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/princeton-nlp/whaticllearns","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":4,"unverified":4},"by_repo_kind":{"official":{"samples":8,"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":0,"samples":[{"code_sha256_prefix":"3e9c0f90d3b4010c","entry":"get_avg_results","repo":"princeton-nlp/whaticllearns","repo_kind":"official","path":"spb/evaluate.py","file_url":"https://github.com/princeton-nlp/whaticllearns/blob/HEAD/spb/evaluate.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3e9c0f90d3b4010c"}},{"code_sha256_prefix":"404087a3ff94d6e0","entry":"register_dataset","repo":"princeton-nlp/whaticllearns","repo_kind":"official","path":"spb/bench_datasets.py","file_url":"https://github.com/princeton-nlp/whaticllearns/blob/HEAD/spb/bench_datasets.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"404087a3ff94d6e0"}},{"code_sha256_prefix":"4afe64752662fe3b","entry":"register_input_format","repo":"princeton-nlp/whaticllearns","repo_kind":"official","path":"spb/input_formats.py","file_url":"https://github.com/princeton-nlp/whaticllearns/blob/HEAD/spb/input_formats.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4afe64752662fe3b"}},{"code_sha256_prefix":"ba71a83cd3836e77","entry":"register_output_format","repo":"princeton-nlp/whaticllearns","repo_kind":"official","path":"spb/output_formats.py","file_url":"https://github.com/princeton-nlp/whaticllearns/blob/HEAD/spb/output_formats.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ba71a83cd3836e77"}},{"code_sha256_prefix":"9e506ab33d9191c8","entry":"augment_sentence","repo":"princeton-nlp/whaticllearns","repo_kind":"official","path":"spb/utils.py","file_url":"https://github.com/princeton-nlp/whaticllearns/blob/HEAD/spb/utils.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":"9e506ab33d9191c8"}},{"code_sha256_prefix":"806ae936dd96ba3b","entry":"expand_tokens","repo":"princeton-nlp/whaticllearns","repo_kind":"official","path":"spb/utils.py","file_url":"https://github.com/princeton-nlp/whaticllearns/blob/HEAD/spb/utils.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":"806ae936dd96ba3b"}},{"code_sha256_prefix":"dfd64188df5ce2ba","entry":"get_episode_indices","repo":"princeton-nlp/whaticllearns","repo_kind":"official","path":"spb/utils.py","file_url":"https://github.com/princeton-nlp/whaticllearns/blob/HEAD/spb/utils.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":"dfd64188df5ce2ba"}},{"code_sha256_prefix":"2cc275485c860a52","entry":"get_model_family","repo":"princeton-nlp/whaticllearns","repo_kind":"official","path":"spb/compute_summary_stats.py","file_url":"https://github.com/princeton-nlp/whaticllearns/blob/HEAD/spb/compute_summary_stats.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":"2cc275485c860a52"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}