Multiple Queries with Multiple Keys: A Precise Prompt Matching Paradigm for Prompt-based Continual Learning
Dunwei Tu, Huiyu Yi, Yuchi Wang, Baile Xu, Jian Zhao, Furao Shen
TL;DR
This work tackles prompt selection bias in prompt-based continual learning by introducing MQMK, a paradigm that uses Multiple Queries for task-level breadth and Multiple Keys for fine-grained, class-level depth. The method employs a local matching mechanism to align test queries with task-specific keys, optimizing both classification and prompt–distribution alignment with a combined loss $\mathcal{L}=\mathcal{L}_{cls}+\mathcal{L}_{mch}$. An efficient inference variant, MQMK-EI, fuses knowledge across tasks to maintain speed while preserving accuracy, and the framework views prompts as a coordinated ensemble across tasks rather than per-task voting. Empirical results on CIFAR-100, ImageNet-R, and DomainNet show MQMK achieves state-of-the-art performance with substantial gains in prompt matching rate (over $30\%$) and competitive efficiency, validating the proposed local matching approach and the benefit of task-aware prompt design. The work also discusses practical trade-offs between accuracy, memory, and computation, and provides analyses on the forgetting behavior under different prompt fusion strategies.
Abstract
Continual learning requires machine learning models to continuously acquire new knowledge in dynamic environments while avoiding the forgetting of previous knowledge. Prompt-based continual learning methods effectively address the issue of catastrophic forgetting through prompt expansion and selection. However, existing approaches often suffer from low accuracy in prompt selection, which can result in the model receiving biased knowledge and making biased predictions. To address this issue, we propose the Multiple Queries with Multiple Keys (MQMK) prompt matching paradigm for precise prompt selection. The goal of MQMK is to select the prompts whose training data distribution most closely matches that of the test sample. Specifically, Multiple Queries enable precise breadth search by introducing task-specific knowledge, while Multiple Keys perform deep search by representing the feature distribution of training samples at a fine-grained level. Each query is designed to perform local matching with a designated task to reduce interference across queries. Experiments show that MQMK enhances the prompt matching rate by over 30\% in challenging scenarios and achieves state-of-the-art performance on three widely adopted continual learning benchmarks. The code is available at https://github.com/DunweiTu/MQMK.
