IDPG: An Instance-Dependent Prompt Generation Method

Zhuofeng Wu, Sinong Wang, Jiatao Gu, Rui Hou, Yuxiao Dong, V. G. Vinod Vydiswaran, Hao Ma

Abstract

As Pre-trained Language Models (PLMs) continue to grow in scale, traditional fine-tuning becomes computationally prohibitive. While Prompt Tuning offers a parameter-efficient alternative by optimizing a fixed set of "soft prompt" tokens, it relies on a static task-specific prefix that ignores the nuances of individual inputs. This paper introduces Instance-Dependent Prompt Generation (IDPG), a method that generates unique, custom prompts for every input sentence. By utilizing a lightweight generator optimized with Parameterized Hypercomplex Multiplication (PHM), IDPG achieves state-of-the-art performance on Natural Language Understanding (NLU) tasks while tuning only ~0.04% of the model's parameters.

Introduction

Fine-tuning massive models like RoBERTa or GPT-3 for specific downstream tasks requires updating millions or billions of parameters, which is often infeasible for resource-constrained environments. Prompt Tuning (PT) emerged as a solution, keeping the backbone model frozen and only training a small set of continuous vectors (soft prompts) prepended to the input.

However, standard Prompt Tuning is task-specific; it applies the same learned prefix to every instance in a dataset. This approach assumes a single prompt can bridge the domain gap for all possible inputs. We argue that this is sub-optimal. A prompt that effectively guides a model to classify a short, literal movie review may not be as effective for a long, sarcastic one. IDPG addresses this by making prompts instance-specific, allowing the model to adapt its internal "instructions" to the specific linguistic nuances of each input.

Methodology

The IDPG Generator

The core of our approach is the IDPG Generator ($G$). Instead of maintaining a static embedding table for prompts, we train a lightweight component that maps an input representation to a tailored prompt. The generator typically follows a bottleneck architecture: a two-layer perceptron that projects high-dimensional sentence representations into a small bottleneck space before expanding them back to the required prompt dimensions.

Parameterized Hypercomplex Multiplication (PHM)

To ensure the generator remains truly parameter-efficient, we employ Parameterized Hypercomplex Multiplication (PHM). PHM layers replace large weight matrices with sums of Kronecker products of smaller matrices. This technique significantly slashes the number of trainable parameters—for instance, reducing a 1.5M parameter generator to just 105K—without sacrificing the expressive power needed to generate effective prompts.

Multi-layer Prompting (M-IDPG)

While initial prompt tuning focused on the input layer, IDPG can be extended to every layer of the Transformer architecture (M-IDPG). To maintain efficiency in this multi-layer setting, we share the weight matrices of the generator across all layers while keeping the bias terms layer-specific. This allows the model to provide deep, instance-dependent guidance throughout the entire forward pass.

Agnostic Encoders

A potential drawback of instance-dependent prompts is the "two-pass" problem: one pass to get the input representation (e.g., the [CLS] token) and a second pass to process the prompted input. We found that we can use frozen, lightweight encoders like GloVe to generate prompts. Using simple GloVe averages as the generator's input performs nearly as well as using the PLM’s own contextual representations, suggesting that general keyword or topic hints are sufficient for the generator to produce high-quality prompts.

Experimental Evaluation

Datasets and Setup

We evaluated IDPG across ten standard NLU tasks, categorized into single-sentence tasks (MPQA, MR, SUBJ, CR, SST-2) and sentence-pair tasks (QNLI, RTE, MRPC, QQP, STS-B). The backbone model used for primary evaluations was RoBERTa-Large.

Performance and Efficiency

IDPG demonstrates a superior balance between accuracy and parameter count:

  • Accuracy: M-IDPG-PHM outperformed standard prompt tuning by an average of 3.1 points and P-tuning v2 by 1.6 points across the 10 benchmark tasks.
  • Efficiency: The model tunes only 134K parameters for RoBERTa-Large, representing approximately 0.04% of the total model size. This is significantly more efficient than standard Adapters, which typically require 1.55M parameters to achieve similar performance.
  • Few-Shot Robustness: In low-resource scenarios (100 to 1,000 training examples), IDPG showed markedly better generalization than traditional static prompt tuning.

Key Insights

Prompts as Semantic Clusterers

Analysis of the STS-B (Semantic Textual Similarity) results reveals that IDPG prompts act as semantic "smoothers." They help the model pull semantically similar sentences closer together in the embedding space while pushing dissimilar ones further apart compared to models using static prompts or no prompts at all.

The Role of Context

The success of IDPG suggests that the optimal prompt is not just a function of the task, but a function of the interaction between the task and the specific input. By providing the model with a "hint" tailored to the instance, we reduce the internal shift the model must undergo to process diverse data points within the same task.

Conclusion and Future Work

IDPG bridges the gap between ultra-lightweight prompt tuning and heavier adapter-based methods. It provides the performance of deep adapters with the footprint of prompt tuning.

Future research will address current limitations, such as the inference latency introduced by the generation step and the impact of prompt length on the model's maximum sequence capacity. Additionally, the security implications of instance-dependent tuning—specifically how a generator might react to adversarial or tampered backbone models—remain an open and important question for the field.

Summary updated

BibTeX
@inproceedings{wu2022idpg,
  author = {Zhuofeng Wu and Sinong Wang and Jiatao Gu and Rui Hou and Yuxiao Dong and V. G. Vinod Vydiswaran and Hao Ma},
  title = {{IDPG: An Instance-Dependent Prompt Generation Method}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.naacl-main.403},
}
Figure