# 学会提示

**学会提示**（Learning to Prompt，简称L2P）是一种持续学习方法，由谷歌云AI与[东北大学](https://www.edgepedia.org/zh/northeastern-university)的王子峰（Zifeng Wang）及其同事在CVPR 2022的一篇论文中提出。该方法通过学习一小组提示参数、而非更新模型权重，来让一个冻结的预训练模型在一系列任务上接受训练。<sup>[1](https://openaccess.thecvf.com/content/CVPR2022/html/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.html)</sup> 该方法既不需要存储过往样本的回放缓冲区，也不需要知道测试时的任务身份，并且是首个将提示引入持续学习领域的工作。<sup>[2](https://www.research.google/blog/learning-to-prompt-for-continual-learning/)</sup>

| 关键事实 | 详情 |
|---|---|
| 发表 | 《Learning To Prompt for Continual Learning》，CVPR 2022，第139–149页；arXiv预印本于2021年12月16日发布<sup>[1](https://openaccess.thecvf.com/content/CVPR2022/html/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.html)</sup><sup> • </sup><sup>[3](https://arxiv.org/abs/2112.08654)</sup> |
| 作者 | 王子峰（Zifeng Wang）、张子昭（Zizhao Zhang）、李辰宇（Chen-Yu Lee）、张涵（Han Zhang）、孙若曦（Ruoxi Sun）、任晓琪（Xiaoqi Ren）、苏国龙（Guolong Su）、Vincent Perot、Jennifer Dy、Tomas Pfister<sup>[1](https://openaccess.thecvf.com/content/CVPR2022/html/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.html)</sup> |
| 核心设计 | 单一冻结骨干网络，加上一个可学习的键值对提示池，按实例查询，因此测试时无需任务身份<sup>[4](https://openaccess.thecvf.com/content/CVPR2022/papers/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.pdf)</sup> |
| 内存占用 | 论文中最大的提示空间小于一张224 × 224图像的大小<sup>[4](https://openaccess.thecvf.com/content/CVPR2022/papers/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.pdf)</sup> |
| 报告结果 | 论文报告称，在图像分类基准上持续优于此前的最先进方法，并超过了一个存储过往数据的回放基线<sup>[1](https://openaccess.thecvf.com/content/CVPR2022/html/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.html)</sup><sup> • </sup><sup>[2](https://www.research.google/blog/learning-to-prompt-for-continual-learning/)</sup> |
| 代码 | 官方JAX实现位于github.com/google-research/l2p，Apache-2.0许可，另有Jaeho Lee的PyTorch复现<sup>[5](https://github.com/google-research/l2p)</sup> |

## 背景：持续学习与遗忘

持续学习是在非平稳数据分布上训练单一模型，不同的分类任务依次到来。由于模型在每个阶段只能看到当前任务的数据，它容易对当前任务过拟合，并丧失在先前任务上的性能，这种退化被称为灾难性遗忘。<sup>[4](https://openaccess.thecvf.com/content/CVPR2022/papers/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.pdf)</sup>

在L2P之前，主流方法带有两项代价。基于回放的方法将过往样本存储在缓冲区中，并在训练时重放；当缓冲区较小时，其性能会大幅下降，而在无法存储数据的情况下（例如适用隐私规则的场景）则完全不可用。无缓冲区的方法通常假设测试时任务身份已知，以便为推理挂接任务专属模块，这一假设限制了实际应用。<sup>[4](https://openaccess.thecvf.com/content/CVPR2022/papers/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.pdf)</sup> 论文的两个动机问题是：情景记忆能否超越对原始过往数据的缓冲？能否在不知道样本所属任务的情况下，为任意样本选择相关的知识组件？<sup>[2](https://www.research.google/blog/learning-to-prompt-for-continual-learning/)</sup>

## L2P的工作原理

**提示作为可学习指令。** 在基于提示的学习中，固定模板会修改模型的输入；提示微调对此加以扩展，将一组可学习的提示向量前置到输入嵌入之前，以在单一下游任务上引导预训练骨干网络。L2P将这一思路扩展到一系列任务上：它不是为每个任务重新学习模型权重，而是从共享池中提取可学习的、与任务相关的指令。<sup>[2](https://www.research.google/blog/learning-to-prompt-for-continual-learning/)</sup>

**提示池。** 池中包含\( M \)个提示\( \mathbf{P} = \{P_1, P_2, \cdots, P_M\} \)，每个提示是一个矩阵\( P_j \in \mathbb{R}^{L_p \times D} \)，其中令牌长度为\( L_p \)，骨干网络的嵌入维度为\( D \)。对于嵌入为\( x_e \)的输入，将\( N \)个提示组成的子集拼接在令牌之前，\( x_p = [P_{s_1}; \cdots ; P_{s_N}; x_e] \)，扩展后的序列被送入模型。提示可以自由组合，因此相似的输入倾向于共享更多提示：频繁共享的提示编码通用知识，而其他提示则编码任务专属知识。<sup>[4](https://openaccess.thecvf.com/content/CVPR2022/papers/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.pdf)</sup>

**按实例查询。** 每个提示都与一个可学习的键配对，\( \{(k_1, P_1), \cdots, (k_M, P_M)\} \)，其中\( k_i \in \mathbb{R}^{D_k} \)。查询函数将输入特征映射到最接近的前N个键，相关联的提示嵌入在预测之前被前置到输入令牌上。键通过降低匹配输入查询特征之间的余弦相似度损失来学习，提示池和分类头则用交叉熵损失进行优化。由于选择是按实例进行的，该方法在测试时无需任务身份或任务边界，这使其适用于任务无关的持续学习。<sup>[2](https://www.research.google/blog/learning-to-prompt-for-continual-learning/)</sup><sup> • </sup><sup>[4](https://openaccess.thecvf.com/content/CVPR2022/papers/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.pdf)</sup>

**为何遗忘得以减少。** 提示存储高层指令，而较低层的预训练表示保持冻结，因此骨干网络的知识在顺序训练过程中不会被覆写；这就在没有回放缓冲区的情况下缓解了灾难性遗忘。<sup>[2](https://www.research.google/blog/learning-to-prompt-for-continual-learning/)</sup>

## 评估

实验在多种持续学习设置下，于流行的图像分类基准上使用了ImageNet预训练的视觉Transformer（ViT）。与朴素的顺序基线（按顺序在所有任务上训练一个模型）、EWC正则化方法，以及将过往样本保存在缓冲区中的回放基线相比，L2P在准确率和遗忘度（除最后一个任务外，各任务从训练期间达到的最佳准确率到最终准确率的平均下降）两方面都显著优于顺序基线和EWC。L2P还在不使用缓冲区的情况下超过了回放方法。<sup>[2](https://www.research.google/blog/learning-to-prompt-for-continual-learning/)</sup> 论文报告称，L2P在这些基准上持续优于此前的最先进方法。<sup>[1](https://openaccess.thecvf.com/content/CVPR2022/html/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.html)</sup>

官方代码库在8块V100 GPU或4块TPU上以总批量大小128进行了测试，并支持CIFAR-100、五数据集和CORe50配置。<sup>[5](https://github.com/google-research/l2p)</sup>

## 影响与后续工作

L2P建立了一个基于提示、无回放、构建于冻结预训练骨干网络之上的持续学习方法家族，后来的综述将这一转变描述为类增量学习研究的一大进展。<sup>[6](https://doi.org/10.1007/s10462-026-11575-w)</sup>

- **DualPrompt**（ECCV 2022），出自同一团队，将互补提示挂接到骨干网络上，并将目标表述为学习任务不变指令和任务专属指令；它还引入了Split ImageNet-R基准，将ImageNet-R的200个类别划分为10个任务、每个任务20个类别。<sup>[5](https://github.com/google-research/l2p)</sup><sup> • </sup><sup>[7](https://arxiv.org/abs/2204.04799)</sup>
- **S-Prompts**（NeurIPS 2022）为域增量学习按域独立学习提示，报告称在每域仅增加0.03%参数的情况下，相对最佳的无需保存样本的方法平均提升约30%。<sup>[8](https://arxiv.org/abs/2207.12819)</sup>
- **CODA-Prompt**（CVPR 2023）在端到端的键查询方案中，以输入条件权重组装提示组件，在既定基准上的平均最终准确率最高超过DualPrompt 4.5%。<sup>[9](https://arxiv.org/abs/2211.13218)</sup>
- **语言引导**（LGCL，ICCV 2023）在任务级和类别级加入预训练语言编码器嵌入，作为基于提示方法的插件，在不增加可学习参数的情况下提升性能。<sup>[10](https://arxiv.org/abs/2308.15827)</sup>
- **提示定制**（Prompt Customization，ACM MM 2024）以生成的、输入条件化的提示取代硬提示选择，报告称相较此前最先进技术最高提升16.2%。<sup>[11](https://arxiv.org/abs/2404.18060)</sup>
- **单阶段提示**（One-stage prompting，ECCV 2024）通过使用中间层的令牌嵌入作为提示查询，去掉了单独的查询ViT前向传播，在CIFAR-100、ImageNet-R和DomainNet上准确率最多下降1%的情况下，将训练和推理的计算成本削减约50%。<sup>[12](https://arxiv.org/abs/2402.16189)</sup>

## 局限

后续工作指出了L2P设计的若干约束。包括L2P、DualPrompt和CODA-Prompt在内的基于提示的方法在高任务数设置下表现不佳，此时提示的线性增长带来内存和计算开销，并随着任务多样性增长而带来提示干扰的风险。<sup>[13](https://openaccess.thecvf.com/content/ICCV2025W/CLVision/papers/Kato_Accuracy_Improvement_of_Prompt-based_Continual_Learning_with_Past_Information_ICCVW_2025_paper.pdf)</sup> 2023年的一项分析发现了一个语义鸿沟：当预训练数据不足或与目标任务相距较远时，骨干网络的特征无法有效地查询提示池，导致性能崩溃。<sup>[14](https://arxiv.org/abs/2308.10445)</sup> 查询和骨干处理所需的两段ViT前馈阶段也造成了计算负担，后来的单阶段设计解决了这一问题。<sup>[12](https://arxiv.org/abs/2402.16189)</sup> 当前大多数提示学习方法主要针对视觉Transformer开发，将这些机制扩展到大型多模态基础模型和LLM仍是一个活跃的研究方向。<sup>[15](https://www.mdpi.com/2227-7390/14/15/2774)</sup>

## References

1. [Wang, Z. et al. (2022). Learning To Prompt for Continual Learning. CVPR 2022, pp. 139–149.](https://openaccess.thecvf.com/content/CVPR2022/html/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.html)
2. [Wang, Z. and Zhang, Z. (2022). Learning to Prompt for Continual Learning. Google Research blog.](https://www.research.google/blog/learning-to-prompt-for-continual-learning/)
3. [Wang, Z. et al. (2021). Learning to Prompt for Continual Learning. arXiv:2112.08654.](https://arxiv.org/abs/2112.08654)
4. [Wang, Z. et al. (2022). Learning To Prompt for Continual Learning (PDF). CVPR 2022.](https://openaccess.thecvf.com/content/CVPR2022/papers/Wang_Learning_To_Prompt_for_Continual_Learning_CVPR_2022_paper.pdf)
5. [google-research/l2p: official JAX implementation of L2P and DualPrompt. GitHub.](https://github.com/google-research/l2p)
6. [Addressing catastrophic forgetting in class-incremental learning—a survey. Artificial Intelligence Review.](https://doi.org/10.1007/s10462-026-11575-w)
7. [Wang, Z. et al. (2022). DualPrompt: Complementary Prompting for Rehearsal-free Continual Learning. arXiv:2204.04799.](https://arxiv.org/abs/2204.04799)
8. [Wang, Y., Huang, Z., Hong, X. (2022). S-Prompts Learning with Pre-trained Transformers. arXiv:2207.12819.](https://arxiv.org/abs/2207.12819)
9. [Smith, J.S. et al. (2022). CODA-Prompt. arXiv:2211.13218.](https://arxiv.org/abs/2211.13218)
10. [Khan, M.G.Z.A. et al. (2023). Introducing Language Guidance in Prompt-based Continual Learning. arXiv:2308.15827.](https://arxiv.org/abs/2308.15827)
11. [Dai, Y. et al. (2024). Prompt Customization for Continual Learning. arXiv:2404.18060.](https://arxiv.org/abs/2404.18060)
12. [Kim, Y., Li, Y., Panda, P. (2024). One-stage Prompt-based Continual Learning. arXiv:2402.16189.](https://arxiv.org/abs/2402.16189)
13. [Kato et al. (2025). Accuracy Improvement of Prompt-based Continual Learning with Past Information. ICCV 2025 Workshop.](https://openaccess.thecvf.com/content/ICCV2025W/CLVision/papers/Kato_Accuracy_Improvement_of_Prompt-based_Continual_Learning_with_Past_Information_ICCVW_2025_paper.pdf)
14. [When Prompt-based Incremental Learning Does Not Meet Strong Pretraining. arXiv:2308.10445.](https://arxiv.org/abs/2308.10445)
15. [Modern Continual Learning with Foundation Models, Evaluation Challenges, and Future Directions. MDPI Mathematics.](https://www.mdpi.com/2227-7390/14/15/2774)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Neural networks and deep learning › Deep learning software and hardware › Fine-tuning and transfer of deep models

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/learning-to-prompt

English original: https://www.edgepedia.org/learning-to-prompt
