{"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/bayesian-scaling-laws-for-in-context-learning","title":"Bayesian scaling laws for in-context learning","arxiv_id":"2410.16531","date":"2024-10-21","proceeding":null,"authors":["Aryaman Arora","Dan Jurafsky","Christopher Potts","Noah D. Goodman"],"abstract":"In-context learning (ICL) is a powerful technique for getting language models to perform complex tasks with no training updates. Prior work has established strong correlations between the number of in-context examples provided and the accuracy of the model's predictions. In this paper, we seek to explain this correlation by showing that ICL approximates a Bayesian learner. This perspective gives rise to a family of novel Bayesian scaling laws for ICL. In experiments with \\mbox{GPT-2} models of different sizes, our scaling laws exceed or match existing scaling laws in accuracy while also offering interpretable terms for task priors, learning efficiency, and per-example probabilities. To illustrate the analytic power that such interpretable scaling laws provide, we report on controlled synthetic dataset experiments designed to inform real-world studies of safety alignment. In our experimental protocol, we use SFT to suppress an unwanted existing model capability and then use ICL to try to bring that capability back (many-shot jailbreaking). We then experiment on real-world instruction-tuned LLMs using capabilities benchmarks as well as a new many-shot jailbreaking dataset. In all cases, Bayesian scaling laws accurately predict the conditions under which ICL will cause the suppressed behavior to reemerge, which sheds light on the ineffectiveness of post-training at increasing LLM safety.","url_abs":"https://arxiv.org/abs/2410.16531v3","url_pdf":"https://arxiv.org/pdf/2410.16531v3.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":"bayesian-scaling-laws-for-in-context-learning","repo_url":"https://github.com/aryamanarora/bayesian-laws-icl","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"in-context-learning","task_name":"In-Context Learning"},{"task_slug":"safety-alignment","task_name":"Safety Alignment"}],"methods":[{"method_slug":"sft","method_name":"SFT"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2410.16531","atlas_url":"https://app.syntology.ai/?focus=2410.16531","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.16531"}},"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/aryamanarora/bayesian-laws-icl","reach":null}],"summary":{"ran_fixture":1,"ran_draft_wrong":1,"unverified":1},"by_repo_kind":{"official":{"samples":3,"ran":2,"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":3,"samples":[{"code_sha256_prefix":"303d355d2a45ca05","entry":"compute_loss","repo":"aryamanarora/bayesian-laws-icl","repo_kind":"official","path":"bayesian_laws_icl/analyse.py","file_url":"https://github.com/aryamanarora/bayesian-laws-icl/blob/HEAD/bayesian_laws_icl/analyse.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"303d355d2a45ca05"}},{"code_sha256_prefix":"c0b881e579fa07f4","entry":"eval_fit","repo":"aryamanarora/bayesian-laws-icl","repo_kind":"official","path":"bayesian_laws_icl/analyse.py","file_url":"https://github.com/aryamanarora/bayesian-laws-icl/blob/HEAD/bayesian_laws_icl/analyse.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c0b881e579fa07f4"}},{"code_sha256_prefix":"a02967edd75c421a","entry":"fit_law","repo":"aryamanarora/bayesian-laws-icl","repo_kind":"official","path":"bayesian_laws_icl/analyse.py","file_url":"https://github.com/aryamanarora/bayesian-laws-icl/blob/HEAD/bayesian_laws_icl/analyse.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":"a02967edd75c421a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}