{"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/learning-to-prompt-for-continual-learning-1","title":"Learning to Prompt for Continual Learning","arxiv_id":"2112.08654","date":"2021-12-16","proceeding":"CVPR 2022 1","authors":["Zifeng Wang","Zizhao Zhang","Chen-Yu Lee","Han Zhang","Ruoxi Sun","Xiaoqi Ren","Guolong Su","Vincent Perot","Jennifer Dy","Tomas Pfister"],"abstract":"The mainstream paradigm behind continual learning has been to adapt the model parameters to non-stationary data distributions, where catastrophic forgetting is the central challenge. Typical methods rely on a rehearsal buffer or known task identity at test time to retrieve learned knowledge and address forgetting, while this work presents a new paradigm for continual learning that aims to train a more succinct memory system without accessing task identity at test time. Our method learns to dynamically prompt (L2P) a pre-trained model to learn tasks sequentially under different task transitions. In our proposed framework, prompts are small learnable parameters, which are maintained in a memory space. The objective is to optimize prompts to instruct the model prediction and explicitly manage task-invariant and task-specific knowledge while maintaining model plasticity. We conduct comprehensive experiments under popular image classification benchmarks with different challenging continual learning settings, where L2P consistently outperforms prior state-of-the-art methods. Surprisingly, L2P achieves competitive results against rehearsal-based methods even without a rehearsal buffer and is directly applicable to challenging task-agnostic continual learning. Source code is available at https://github.com/google-research/l2p.","url_abs":"https://arxiv.org/abs/2112.08654v2","url_pdf":"https://arxiv.org/pdf/2112.08654v2.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":"learning-to-prompt-for-continual-learning-1","repo_url":"https://github.com/google-research/l2p","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"jax","reach":null},{"paper_slug":"learning-to-prompt-for-continual-learning-1","repo_url":"https://github.com/gulzainali98/LGCL","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"learning-to-prompt-for-continual-learning-1","repo_url":"https://github.com/ContinualAI/avalanche","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null},{"paper_slug":"learning-to-prompt-for-continual-learning-1","repo_url":"https://github.com/JH-LEE-KR/l2p-pytorch","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"learning-to-prompt-for-continual-learning-1","repo_url":"https://github.com/aimagelab/mammoth","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"class-incremental-learning","task_name":"Class Incremental Learning"},{"task_slug":"continual-learning","task_name":"Continual Learning"},{"task_slug":"image-classification","task_name":"Image Classification"},{"task_slug":"class-incremental-learning-1","task_name":"class-incremental learning"},{"task_slug":"image-classification","task_name":"image-classification"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2112.08654","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2112.08654"}},"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/aimagelab/mammoth","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/ContinualAI/avalanche","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/JH-LEE-KR/l2p-pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/gulzainali98/LGCL","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/google-research/l2p","reach":null}],"summary":{"ran":9,"ran_violates":1,"unverified":1},"by_repo_kind":{"listed":{"samples":11,"ran":10,"repositories":2}},"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":"5c3574e986df9984","entry":"calculate_md5","repo":"JH-LEE-KR/l2p-pytorch","repo_kind":"listed","path":"continual_datasets/dataset_utils.py","file_url":"https://github.com/JH-LEE-KR/l2p-pytorch/blob/HEAD/continual_datasets/dataset_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"5c3574e986df9984"}},{"code_sha256_prefix":"46b62ccc9e5b9878","entry":"check_integrity","repo":"JH-LEE-KR/l2p-pytorch","repo_kind":"listed","path":"continual_datasets/dataset_utils.py","file_url":"https://github.com/JH-LEE-KR/l2p-pytorch/blob/HEAD/continual_datasets/dataset_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"46b62ccc9e5b9878"}},{"code_sha256_prefix":"b3cb500b2f04323d","entry":"check_md5","repo":"JH-LEE-KR/l2p-pytorch","repo_kind":"listed","path":"continual_datasets/dataset_utils.py","file_url":"https://github.com/JH-LEE-KR/l2p-pytorch/blob/HEAD/continual_datasets/dataset_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"b3cb500b2f04323d"}},{"code_sha256_prefix":"ee95af3ec5c38df5","entry":"checkpoint_filter_fn","repo":"JH-LEE-KR/l2p-pytorch","repo_kind":"listed","path":"vision_transformer.py","file_url":"https://github.com/JH-LEE-KR/l2p-pytorch/blob/HEAD/vision_transformer.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"ee95af3ec5c38df5"}},{"code_sha256_prefix":"9c90a0600bfdb124","entry":"get_init_file","repo":"JH-LEE-KR/l2p-pytorch","repo_kind":"listed","path":"run_with_submitit.py","file_url":"https://github.com/JH-LEE-KR/l2p-pytorch/blob/HEAD/run_with_submitit.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"9c90a0600bfdb124"}},{"code_sha256_prefix":"6c600a2f0f2361f1","entry":"get_init_weights_vit","repo":"JH-LEE-KR/l2p-pytorch","repo_kind":"listed","path":"vision_transformer.py","file_url":"https://github.com/JH-LEE-KR/l2p-pytorch/blob/HEAD/vision_transformer.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"6c600a2f0f2361f1"}},{"code_sha256_prefix":"8e194e74ffb0e8ec","entry":"get_shared_folder","repo":"JH-LEE-KR/l2p-pytorch","repo_kind":"listed","path":"run_with_submitit.py","file_url":"https://github.com/JH-LEE-KR/l2p-pytorch/blob/HEAD/run_with_submitit.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"8e194e74ffb0e8ec"}},{"code_sha256_prefix":"a6e17b60ed761713","entry":"resize_pos_embed","repo":"JH-LEE-KR/l2p-pytorch","repo_kind":"listed","path":"vision_transformer.py","file_url":"https://github.com/JH-LEE-KR/l2p-pytorch/blob/HEAD/vision_transformer.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"a6e17b60ed761713"}},{"code_sha256_prefix":"10ebc4ca56bae3c2","entry":"str_to_bool","repo":"gulzainali98/LGCL","repo_kind":"listed","path":"configs/cifar100_lgcl.py","file_url":"https://github.com/gulzainali98/LGCL/blob/HEAD/configs/cifar100_lgcl.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"10ebc4ca56bae3c2"}},{"code_sha256_prefix":"265ea374aab10001","entry":"target_transform","repo":"JH-LEE-KR/l2p-pytorch","repo_kind":"listed","path":"datasets.py","file_url":"https://github.com/JH-LEE-KR/l2p-pytorch/blob/HEAD/datasets.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"265ea374aab10001"}},{"code_sha256_prefix":"f32616c3ff9585fa","entry":"get_dataset","repo":"JH-LEE-KR/l2p-pytorch","repo_kind":"listed","path":"datasets.py","file_url":"https://github.com/JH-LEE-KR/l2p-pytorch/blob/HEAD/datasets.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":false,"mcp_get_code":{"code_sha256":"f32616c3ff9585fa"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}