{"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/a-study-on-the-calibration-of-in-context","title":"A Study on the Calibration of In-context Learning","arxiv_id":"2312.04021","date":"2023-12-07","proceeding":null,"authors":["HANLIN ZHANG","Yi-Fan Zhang","Yaodong Yu","Dhruv Madeka","Dean Foster","Eric Xing","Himabindu Lakkaraju","Sham Kakade"],"abstract":"Accurate uncertainty quantification is crucial for the safe deployment of machine learning models, and prior research has demonstrated improvements in the calibration of modern language models (LMs). We study in-context learning (ICL), a prevalent method for adapting static LMs through tailored prompts, and examine the balance between performance and calibration across a broad spectrum of natural language understanding and reasoning tasks. Through comprehensive experiments, we observe that, with an increasing number of ICL examples, models initially exhibit increased miscalibration before achieving better calibration and miscalibration tends to arise in low-shot settings. Moreover, we find that methods aimed at improving usability, such as fine-tuning and chain-of-thought (CoT) prompting, can lead to miscalibration and unreliable natural language explanations. Furthermore, we explore recalibration techniques and find that a scaling-binning calibrator can reduce calibration errors consistently.","url_abs":"https://arxiv.org/abs/2312.04021v4","url_pdf":"https://arxiv.org/pdf/2312.04021v4.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":"a-study-on-the-calibration-of-in-context","repo_url":"https://github.com/hlzhang109/icl-calibration","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"},{"task_slug":"natural-language-understanding","task_name":"Natural Language Understanding"},{"task_slug":"uncertainty-quantification","task_name":"Uncertainty Quantification"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2312.04021","atlas_url":"https://app.syntology.ai/?focus=2312.04021","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2312.04021"}},"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/hlzhang109/icl-calibration","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_fixture":1,"ran":7,"ran_draft_wrong":1,"unverified":8},"by_repo_kind":{"official":{"samples":17,"ran":9,"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":"9b4dff79d5e6102c","entry":"apply_rotary_pos_emb","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"llama/modeling_llama.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/llama/modeling_llama.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9b4dff79d5e6102c"}},{"code_sha256_prefix":"5d4d57fcfbf81571","entry":"chunk_size_helper","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"utils.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/utils.py","link_basis":"first_harvest_node","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":"5d4d57fcfbf81571"}},{"code_sha256_prefix":"19422cfbfee41729","entry":"cross_entropy_loss","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"calibrate/verified_calibration.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/calibrate/verified_calibration.py","link_basis":"first_harvest_node","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":"19422cfbfee41729"}},{"code_sha256_prefix":"7dc9736cdb2847c4","entry":"get_equal_bins","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"calibration/utils.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/calibration/utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7dc9736cdb2847c4"}},{"code_sha256_prefix":"d1ebc0d7093a4203","entry":"get_equal_prob_bins","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"calibration/utils.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/calibration/utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d1ebc0d7093a4203"}},{"code_sha256_prefix":"2ed507c8c59739f5","entry":"random_sampling","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"utils.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/utils.py","link_basis":"first_harvest_node","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":"2ed507c8c59739f5"}},{"code_sha256_prefix":"b99eea6376d1e212","entry":"rotate_half","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"llama/modeling_llama.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/llama/modeling_llama.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b99eea6376d1e212"}},{"code_sha256_prefix":"182e1f46c31a2e09","entry":"setup_llama","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"utils.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/utils.py","link_basis":"first_harvest_node","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":"182e1f46c31a2e09"}},{"code_sha256_prefix":"8e9dfd4ba4bf9fa3","entry":"split","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"calibration/utils.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/calibration/utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8e9dfd4ba4bf9fa3"}},{"code_sha256_prefix":"ef2f02ab0c2e6b74","entry":"construct_prompt","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"run_classification_cot.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/run_classification_cot.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":"ef2f02ab0c2e6b74"}},{"code_sha256_prefix":"556aa6b923228885","entry":"eval_accuracy","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"run_classification.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/run_classification.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":"556aa6b923228885"}},{"code_sha256_prefix":"d09226e56c2085ea","entry":"get_p_content_free","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"run_classification_calibrate.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/run_classification_calibrate.py","link_basis":"plan_row","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":"d09226e56c2085ea"}},{"code_sha256_prefix":"5459a3ffb7e8ae5f","entry":"load_commonsense_qa","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"data_utils.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/data_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":"5459a3ffb7e8ae5f"}},{"code_sha256_prefix":"37240d47eb548267","entry":"load_cot_data","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"data_utils.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/data_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":"37240d47eb548267"}},{"code_sha256_prefix":"b74b229b1c013bd2","entry":"load_strategy_qa","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"data_utils.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/data_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":"b74b229b1c013bd2"}},{"code_sha256_prefix":"ac63a1554effbb56","entry":"save_pickle_tmp","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"run_classification.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/run_classification.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":"ac63a1554effbb56"}},{"code_sha256_prefix":"94ba60d7c3f5ef45","entry":"save_pickle_tmp","repo":"hlzhang109/icl-calibration","repo_kind":"official","path":"run_classification_cot.py","file_url":"https://github.com/hlzhang109/icl-calibration/blob/HEAD/run_classification_cot.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":"94ba60d7c3f5ef45"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}