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

Prompt-based continual learning often fails because the model picks the wrong "knowledge prompt" for a given test sample. This paper introduces MQMK (Multiple Queries with Multiple Keys), a paradigm that uses task-specific queries and class-level keys to boost prompt matching accuracy by over 30%, achieving state-of-the-art results while actually reducing training time.

What Problem Does This Paper Address?

In the world of Continual Learning (CL), neural networks must learn new tasks sequentially without forgetting old ones—a challenge known as "catastrophic forgetting." Recent state-of-the-art methods use a "prompt pool" approach: they keep a frozen backbone (like a Vision Transformer) and learn small, task-specific "prompts" that act as keys to unlock specific knowledge.

The Achilles' heel of these methods is prompt selection. During inference, the model must look at a test image and decide which prompt to use. Current methods use a Single Query–Single Key (SQSK) approach, which is often too coarse. If the model picks a prompt from Task B for an image from Task A, it receives "biased knowledge," leading to incorrect predictions. The authors demonstrate that if you could achieve "perfect matching" (manually giving the model the correct task ID), accuracy on benchmarks like ImageNet-R would jump by over 26%.

Methods

The authors propose the Multiple Queries with Multiple Keys (MQMK) paradigm to turn prompt selection from a "best guess" into a precise search.

  1. Multiple Queries (MQ) for Breadth: Instead of one generic query from a prompt-less backbone, MQMK generates a pool of queries—one for each task learned so far. By incorporating task-specific prompts into the query generation process, the model performs a "breadth search" across task-level knowledge.
  2. Multiple Keys (MK) for Depth: Rather than having one key represent an entire task (which might contain 20+ diverse classes), MQMK uses class-level keys. This allows for a "deep search" that captures the fine-grained feature distribution of the training data.
  3. Local Matching: To prevent interference, each task-specific query is only matched against the keys belonging to that specific task. The model then selects the prompt associated with the highest similarity score.
  4. MQMK-Efficient Inference (MQMK-EI): To solve the computational overhead of running multiple queries during inference, the authors developed a "knowledge fusion" version. It averages all learned prompts into a single enhanced query, approximating the full MQMK performance with significantly lower latency.

Datasets

The model was evaluated on three widely recognized continual learning benchmarks:

  • CIFAR-100: 100 classes split into 10 tasks.
  • ImageNet-R: A variant of ImageNet designed to test robustness, split into 5, 10, and 20 tasks. This is particularly challenging because its distribution differs significantly from the data used to pre-train the backbone.
  • DomainNet: A large-scale dataset featuring different domains (sketch, clipart, etc.), used here with 200 classes split into 10 tasks.

Key Insights and Ideas

  • Selection > Quality: A major "aha" moment in the paper is that the quality of the prompts is often already quite high; the bottleneck is the selection mechanism. Improving the matching rate is the most direct path to higher accuracy.
  • The Complementary Nature of MQ and MK: The authors found that adding Multiple Keys (MK) to a single query only helps slightly. However, when combined with Multiple Queries (MQ), the matching rate skyrocketed (a 32.82% improvement). Breadth and depth must work together.
  • Training Efficiency Paradox: Surprisingly, MQMK is faster to train than standard SQSK methods. Because MQMK uses the same features for both querying and prediction, it requires only one forward/backward pass through the backbone, whereas SQSK often requires two.

Key Results

  • State-of-the-Art Accuracy: MQMK outperformed existing methods like L2P, DualPrompt, and CODA-P across all benchmarks. On 10-task ImageNet-R, it achieved 78.36% accuracy, nearly matching the "joint training" upper bound of 79.27%.
  • Matching Rate Boost: In challenging scenarios, MQMK improved the prompt matching rate by over 30% compared to the baseline SQSK paradigm.
  • Inference Speed: While the full MQMK is slower due to multiple queries, the MQMK-EI variant achieved comparable SOTA performance while maintaining inference speeds similar to baseline methods.

Limitations and Future Work

  • Scaling with Tasks: As the number of tasks ($M$) grows, the full MQMK requires replicating the input $M$ times for parallel inference. While this is efficient on high-end GPUs, it could hit memory limits in extreme long-term learning scenarios (e.g., hundreds of tasks).
  • Class-Level Dependency: The method relies on class-level keys. While effective, this assumes the model has access to class boundaries during training, which is standard for Class-Incremental Learning but might not apply to more "blurry" or unsupervised continual learning settings.
  • Future Direction: The authors suggest exploring how "subspace drift"—where different prompts generate different feature subspaces—can be further mitigated to ensure even more robust predictions when selection is imperfect.

Summary updated

BibTeX
@inproceedings{tu2025multiple,
  author = {Dunwei Tu and Huiyu Yi and Yuchi Wang and Baile Xu and Jian Zhao and Furao Shen},
  title = {{Multiple Queries with Multiple Keys: A Precise Prompt Matching Paradigm for Prompt-based Continual Learning}},
  booktitle = {ACM Multimedia},
  year = {2025},
  url = {https://openreview.net/forum?id=PMs4FijiXi},
}
Figure