What is prompt tuning?
Prompt tuning is a parameter-efficient adaptation method that freezes all of a language model's weights and trains a small number of learnable vectors prepended to the input, the soft prompt, for a specific task.
It is also called soft prompt tuning. Unlike prompt engineering, which hand-designs readable words, it learns, by gradient descent, continuous vectors that match no words. Prefix tuning is a close method adding such vectors to every layer.
- Topic
- Machine learning, models and training
- Also known as
- Soft prompt tuning
- Origin
- 2021, Lester, Al-Rfou and Constant
How prompt tuning works
- Model weights are frozen; a few dozen virtual tokens, initialised randomly or from word embeddings, are prepended to the input.
- Task examples go into the model with these virtual tokens and loss is computed as usual.
- Gradients update only the virtual token vectors; model weights do not change.
- At inference the task's vectors are prepended to each request; one model serves different tasks with different vector sets.
In more detail
Initialisation and prompt length
Lester et al. (2021) showed that initialising soft prompt vectors from vocabulary embeddings or class-label tokens works better than random values. In the same study, growing the prompt beyond about 20 tokens brought limited gains for large models, while a longer prompt also uses up context window.
Open weights requirement and serving limits
Because soft prompts are continuous vectors prepended to the embedding layer (inputs_embeds), they require access to the model's embedding interface and gradient backpropagation through the frozen Transformer, which makes prompt tuning unusable on black-box API-only models. Moreover, compared with LoRA, multi-tenant serving frameworks offer far less out-of-the-box support for batching heterogeneous soft prompts across concurrent requests.
KV cache gains and model dependence
Because virtual tokens act as a task-specific prefix, their key and value (KV) states can be precomputed and cached once per task and reused across requests, avoiding repeated forward passes over the soft prompt. However, unlike discrete prompts, soft prompts are tied to a single exact base-model checkpoint and cannot be transferred directly across different model families or tokenisers.
Commonly confused terms
| Term | How it differs |
|---|---|
| LoRA | LoRA injects trainable low-rank weight update matrices into existing attention and MLP layers, typically outperforming prompt tuning on small and medium models and complex tasks while enjoying mature multi-adapter serving support. |
Why prompt tuning matters for on-premises AI
Prompt tuning makes it easy to use one base model for many tasks in-house: each task is stored as a small vector file. Since model weights never change, an approved model may not need re-approval. On small and medium models, however, it can trail methods such as Low-Rank Adaptation, a gap that closes on large models. The learned vectors are unreadable, so behaviour is harder to explain.
A public agency trains a separate soft prompt for petition classification, summaries and reply drafts so one approved language model serves all three; since the model is unchanged, task and safety tests replace a full new security review.
Common questions
How does prompt tuning differ from prompt engineering?
Prompt engineering hand-designs a readable text prompt. Prompt tuning trains continuous vectors added to the model, which correspond to no words.
How does prompt tuning differ from LoRA?
Both freeze the model and train few parameters. Prompt tuning only adds vectors to the input; LoRA adds low-rank matrices inside layers and usually does better on small models.
Related terms
- Parameter-efficient fine-tuning
- Prefix tuning
- Low-Rank Adaptation
- Fine-tuning
- Prompt engineering
- Prompt
- Automatic prompt optimisation
Sources
- Lester, Al-Rfou and Constant, The Power of Scale for Parameter-Efficient Prompt Tuning, 2021
- Li and Liang, Prefix-Tuning: Optimizing Continuous Prompts for Generation, 2021
In the glossary: Glossary, M to Q