Prompt tuning

Also known as: soft prompt · soft prompt tuning

On this page 7

Prompt tuning is a parameter-efficient training method that specializes a pretrained language model whose weights remain fixed, optimizing only a brief block of continuous embedding vectors, called a soft prompt, that is prepended to the input. In artificial intelligence training, it sits in the family of parameter-efficient fine-tuning techniques: the model weights stay unchanged, and only the soft prompt, often fewer than 0.01% of the model’s parameters, is updated by gradient descent.

Unlike a hand-written text prompt, a soft prompt does not consist of real words. It is a block of numbers living in the model’s embedding space, optimized directly against a task loss. This makes prompt tuning cheap to store and to serve, because one shared model can handle many tasks by swapping small prompt files.

How soft prompts steer a frozen model

Prompt tuning works by adding trainable virtual tokens in front of the embedded input sequence and backpropagating the task loss only into those tokens. The transformer layers process the virtual tokens exactly like real ones, so attention lets every input position read from them and shift the model’s behavior toward the target task.

The procedure has a small number of steps, summarized in the table below.

StepWhat happensDetail
InitializeCreate k soft prompt vectorsRandom, sampled vocabulary embeddings or class label embeddings
PrependConcatenate vectors before the input embeddingsSequence length grows by k positions
Forward passRun the frozen model on the extended inputAll transformer weights stay fixed
Backward passCompute gradients of the lossGradients update only the soft prompt
DeployStore the learned prompt as a small tensorLoad it with the shared base model at inference
Steps of a prompt tuning run

Because the gradient must still flow through the whole network, prompt tuning saves optimizer memory and storage rather than compute per step. The optimizer state covers only a few thousand to a few hundred thousand values instead of billions, which is the main source of its efficiency.

Key parameters and typical values

A handful of hyperparameters determine whether prompt tuning converges well. Its optimization landscape differs from full fine-tuning, so values that work for model weights often fail for soft prompts.

ParameterTypical rangeEffect
Prompt length20 to 100 virtual tokensLonger prompts add capacity but return diminishing gains
Learning rateAbout 0.1 to 1.0 with AdafactorMuch higher than for full fine-tuning
InitializationVocabulary or label embeddingsStrongly affects stability on smaller models
Training stepsThousands to tens of thousandsConvergence is slower than fine-tuning
Base model sizeFrom hundreds of millions to tens of billions of parametersQuality gap to fine-tuning shrinks with scale
Prompt tuning hyperparameters

The most cited finding about the method is its dependence on model scale. On models with roughly a billion parameters or fewer, prompt tuning usually trails full fine-tuning noticeably, while on models with around ten billion parameters or more it has been shown to approach full fine-tuning quality on many classification and generation benchmarks.

Prompt tuning is the lightest member of the parameter-efficient family. The comparison below places it beside its closest neighbors in the training toolbox.

MethodWhat is trainedTypical trainable shareMain trade-off
Prompt tuningSoft prompt at the input layer onlyBelow 0.01%Smallest footprint, weaker on small models
Prefix tuningPrefix vectors in every layer’s attentionAbout 0.1%More capacity, more complex to implement
LoRALow-rank updates to weight matricesAbout 0.1% to 1%Strong quality, merges into weights
Adapter tuningSmall bottleneck modules between layersAbout 1% to 5%Adds inference latency
Full fine-tuningAll model weights100%Best fit, highest cost and storage
Prompt engineeringNothing; text is written by hand0%No training, limited control
Comparison with neighboring adaptation methods

Prefix tuning and P-tuning v2 extend the idea by inserting trainable vectors into deeper layers, which closes much of the gap on smaller models. Prompt tuning in the strict sense touches only the input layer, which keeps it simple and makes mixed-task batching easy.

When prompt tuning is the right choice

Prompt tuning fits best when an organization serves many narrow tasks from one large model and wants each task to cost almost nothing in storage. Each soft prompt may occupy only a few hundred kilobytes, and requests for different tasks can share one batch because the base weights never change.

The decision table below covers common situations.

SituationRecommended choiceReason
Hundreds of tasks on one large modelPrompt tuningTiny per-task files, mixed-task batching
Small model under one billion parametersLoRA or prefix tuningPrompt tuning underperforms at this scale
Large shift in domain or output formatLoRA or full fine-tuningInput-only steering has limited capacity
No training budget or labeled dataPrompt engineeringWorks with zero gradient updates
Model weights not accessiblePrompt engineeringPrompt tuning needs gradients through the model
Choosing an adaptation method

Limitations and common pitfalls

Prompt tuning has practical weaknesses that practitioners should anticipate. Most of them stem from the limited capacity of a few input vectors and from a difficult optimization surface.

  • Slow and unstable convergence, which is sensitive to learning rate and initialization.
  • Poor interpretability: learned vectors rarely map to meaningful nearest words.
  • No transfer between models: a soft prompt is tied to one base model and its tokenizer.
  • Reduced context window, since virtual tokens occupy positions in the sequence.
  • Requires white-box access, so it cannot be applied to models available only through text APIs.

A frequent misconception is that a soft prompt is simply an optimized text prompt. It is not: the vectors lie between real token embeddings and usually cannot be decoded into readable instructions, so the learned behavior cannot be copied into a chat window.

The short version

A large language model already knows a great deal. Prompt tuning teaches it a new job without changing the model itself. Instead, it learns a short hidden instruction that is placed in front of every input.

This instruction is not written in words. It is a small set of numbers that the computer finds by trial and correction. Think of it as a custom key for one lock. The model stays the same, and each task gets its own tiny key that is easy to store and swap.

Where it makes a difference

A software company hosts one 11-billion-parameter language model for its business customers. Each of its 300 customers wants the model to classify support tickets into its own categories and to answer in its own tone. Storing 300 fully fine-tuned copies would require several terabytes and many separate servers.

The team instead trains one soft prompt of 50 virtual tokens per customer on a few thousand labeled tickets. Each prompt file is well under one megabyte. At inference, the serving system attaches the right prompt to each request and processes tickets from different customers in the same batch. Classification accuracy lands within a few points of full fine-tuning, while hardware and storage costs fall to a fraction of the original plan.