---
title: "Prompt Tuning Explained: Soft Prompts on a Frozen LLM"
description: "Prompt tuning trains only a few soft-prompt vectors on a frozen model: 20,480 parameters per task on 11B-parameter T5-XXL. The math, results and PEFT code."
url: https://launchkudos.com/news/llm-fine-tuning-prompt-tuning
section: AI
author: "Arnab Gupta"
published: 2026-12-05T02:20:02.819Z
updated: 2026-12-05T02:20:02.819Z
tags: [llm-fine-tuning, prompt-tuning, soft-prompts, peft, t5]
---

# Prompt Tuning Explained: Soft Prompts on a Frozen LLM

*Prompt tuning trains only a few soft-prompt vectors on a frozen model: 20,480 parameters per task on 11B-parameter T5-XXL. The math, results and PEFT code.*

*Part 7 of 15 in [LLM fine-tuning techniques](https://launchkudos.com/news/llm-fine-tuning-techniques)*

Prompt tuning trains a short "soft prompt", a few vectors prepended to the input embeddings, while every weight of the language model stays frozen. Brian Lester, Rami Al-Rfou and Noah Constant of Google Research showed in 2021 that at 11 billion parameters this matched full model tuning on SuperGLUE with over 20,000 times fewer task-specific parameters ([arXiv 2104.08691](https://arxiv.org/abs/2104.08691)).

- 20,480 · parameters per task: 5-token prompt on T5-XXL · Lester et al., Fig. 2
- 20,000x · fewer task parameters than model tuning, same score at XXL · Sec. 3.1
- +12.5 F1 · over model tuning on TextbookQA domain shift · Table 1
Prompt tuning is the simplest of the three prompt-based methods in this series. [Prefix tuning](https://launchkudos.com/news/llm-fine-tuning-prefix-tuning) trains vectors at every layer, and [P-Tuning](https://launchkudos.com/news/llm-fine-tuning-p-tuning) generates input vectors with an LSTM or MLP encoder.

## What is prompt tuning?

Prompt tuning is a parameter-efficient fine-tuning method that learns a sequence of continuous embedding vectors, a soft prompt, prepended to the embedded input of a frozen language model. Unlike a written prompt, the vectors need not match any word in the vocabulary, and they are learned by backpropagation from labeled examples ([Lester et al., Abstract and Sec. 2](https://arxiv.org/abs/2104.08691)).

The authors describe their method as "a simplification of the recently proposed 'prefix tuning' of Li and Liang (2021)" (Abstract).

## How does prompt tuning work?

T5 embeds the n input tokens into a matrix of size n × e. Prompt tuning adds a trainable matrix of size p × e, where p is the prompt length, and concatenates the two into one (p + n) × e matrix that flows through the encoder-decoder as normal. Training maximizes the probability of the correct output, but only the prompt matrix is updated ([Lester et al., Sec. 2](https://arxiv.org/abs/2104.08691)).

![Diagram of prompt tuning: three tasks each prepend their own small orange soft prompt to the input and share one frozen T5 model](https://launchkudos.com/media/33b1eb2ced5bc45601f1.webp)

Step by step, following Sections 2 and 3 of the paper:

1. **Cast the task as text-to-text.** Classification becomes generating the label's text, as in T5 (Sec. 2).
2. **Choose a prompt length.** The paper tested 1, 5, 20, 100 and 150 tokens; its default is 100 (Sec. 3, 3.2).
3. **Initialize the prompt.** Options are random uniform values, embeddings of sampled common vocabulary words, or embeddings of the class labels; class-label initialization was best (Sec. 2.1, 3.2).
4. **Use a model that responds to prompts.** T5 checkpoints pre-trained only on span corruption worked poorly; the authors continued training them for 100K steps on a language-modeling objective ("LM adaptation") and released those checkpoints (Sec. 2.2, 3.2).
5. **Train only the prompt.** Their runs used 30,000 steps, a constant learning rate of 0.3, batch size 32 and the Adafactor optimizer (Sec. 3).
6. **Serve many tasks from one model.** Because the model is unchanged, one batch can mix examples from different tasks, each with its own prompt (Fig. 2).

### Worked example: how many parameters does a soft prompt have?

The paper gives the cost directly: "The parameter cost of our method is EP, where E is the token embedding dimension and P is the prompt length" (Sec. 2.1). T5-XXL has a model dimension of 4,096 ([LM-adapted T5-XXL config](https://huggingface.co/google/t5-xxl-lm-adapt/blob/main/config.json)) and about 11 billion parameters (Fig. 2).

| Prompt length P | E × P | Trainable parameters | Share of 11B |
|---|---|---|---|
| 1 | 4,096 × 1 | 4,096 | 0.00004% |
| 5 | 4,096 × 5 | 20,480 | 0.0002% |
| 20 | 4,096 × 20 | 81,920 | 0.0007% |
| 100 (paper default) | 4,096 × 100 | 409,600 | 0.004% |

The 5-token row matches the paper's own figure of 20,480 parameters per task, "a reduction of over five orders of magnitude" against an 11B-parameter tuned copy (Fig. 2). Even the 100-token default is under 0.01%, the level the paper reports for most models over a billion parameters (Sec. 4).

## When was prompt tuning introduced, and by whom?

Prompt tuning was introduced in "The Power of Scale for Parameter-Efficient Prompt Tuning" by Brian Lester, Rami Al-Rfou and Noah Constant of Google Research. It was posted to arXiv on April 18, 2021, revised on Sept. 2, 2021, and published at EMNLP 2021 ([arXiv 2104.08691](https://arxiv.org/abs/2104.08691); [ACL Anthology](https://aclanthology.org/2021.emnlp-main.243/)).

The paper says it was developed concurrently with prefix tuning and with WARP (Hambardzumyan et al., 2021) (Sec. 1). Code is at [google-research/prompt-tuning](https://github.com/google-research/prompt-tuning).

## What results did the prompt-tuning paper report?

On SuperGLUE, prompt tuning closed the gap with model tuning as T5 grew; at XXL size (11B) it matched even a multi-task tuned baseline. Prompt-tuned T5-Large beat few-shot GPT-3 175B. Under domain shift, prompt tuning beat model tuning on most out-of-domain QA sets, by 12.5 F1 on TextbookQA ([Lester et al., Sec. 3.1 and 5](https://arxiv.org/abs/2104.08691)).

**Scale (Sec. 1, 3.1, Figure 1).** The paper starts from a gap: few-shot GPT-3 175B scored 71.8 on SuperGLUE against 89.3 for fine-tuned T5-XXL. Prompt tuning shrank that gap as models grew:

- prompt-tuned T5-Small matched GPT-3 XL, which is over 16 times larger;
- prompt-tuned T5-Large beat GPT-3 175B, over 220 times larger;
- at XXL, prompt tuning matched multi-task model tuning "despite having over 20,000 times fewer task-specific parameters".

**Domain shift (Sec. 5, Table 1, F1, trained on SQuAD):**

| Out-of-domain dataset | Domain | Model tuning | Prompt tuning | Difference |
|---|---|---|---|---|
| TextbookQA | Book | 54.3 | 66.8 | +12.5 |
| BioASQ | Bio | 77.9 | 79.1 | +1.2 |
| RACE | Exam | 59.8 | 60.7 | +0.9 |
| RE | Wiki | 88.4 | 88.8 | +0.4 |
| DuoRC | Movie | 68.9 | 67.7 | -1.2 |
| DROP | Wiki | 68.9 | 67.1 | -1.8 |

Trained on QQP and tested on MRPC, prompt tuning scored 76.3 accuracy and 84.3 F1, against 73.1 and 81.2 for model tuning (Table 2).

**Prompt ensembling (Sec. 6, Table 3).** Five prompts trained on one frozen T5-XXL scored 90.5 on average on SuperGLUE dev, 91.0 for the best single prompt and 91.3 as a majority-vote ensemble. The ensemble runs as one forward pass with batch size N, instead of N separate models.

**Interpretability (Sec. 7).** The nearest vocabulary words to learned prompt tokens formed tight semantic clusters, but the authors "did not find our learned prompts to be interpretable" beyond that.

## How is prompt tuning different from prefix tuning, P-Tuning and fine-tuning?

Prompt tuning trains only input-layer embeddings on a frozen model, with no reparameterization network and no task-specific output layer. [Prefix tuning](https://launchkudos.com/news/llm-fine-tuning-prefix-tuning) trains activations at every layer through an MLP; [P-Tuning](https://launchkudos.com/news/llm-fine-tuning-p-tuning) uses an encoder and, for SuperGLUE, also tuned the model; full fine-tuning changes all weights ([Lester et al., Sec. 4](https://arxiv.org/abs/2104.08691)).

| | Prompt tuning | Prefix tuning | P-Tuning (v1) | Full model tuning |
|---|---|---|---|---|
| What is trained | p × e input embeddings | Prefix at every layer | Input embeddings plus an LSTM/MLP encoder | All weights |
| Model frozen? | Yes | Yes | Frozen or tuned | No |
| Extra network in training | None | MLP | LSTM or MLP | None |
| Storage per task (paper) | Under 0.01% for models over 1B (Sec. 4) | 0.1% (Li & Liang, Sec. 6.1) | Varies | 100% |
| Mixed-task batches discussed | Yes (Fig. 2) | Yes (Li & Liang, Sec. 8.2) | Not discussed | No (Fig. 2) |

Lester et al. also compare prompt tuning with [adapters](https://launchkudos.com/news/llm-fine-tuning-adapter-tuning): adapters "modify the actual function" by rewriting activations inside the network, while prompt tuning "modifies behavior by leaving the function fixed and adding new input representations" (Sec. 4). The P-Tuning v2 paper later reported that input-only prompts score far below fine-tuning on models under 10B parameters and on sequence-labeling tasks such as extractive QA ([Liu et al. 2022, Sec. 3.1 and Table 3](https://arxiv.org/abs/2110.07602)).

## Which libraries support prompt tuning?

Hugging Face PEFT supports prompt tuning through `PromptTuningConfig` and `PromptTuningInit`. The docs (v0.22.0, read Dec. 4, 2026) say "only the input of the first layer receives the virtual tokens" and offer three initializations: `TEXT`, `SAMPLE_VOCAB` and `RANDOM` (the default) ([PEFT prompt tuning docs](https://huggingface.co/docs/peft/package_reference/prompt_tuning)).

The paper's experiments ran in JAX with Flax (Sec. 3); the authors' code is at [google-research/prompt-tuning](https://github.com/google-research/prompt-tuning). The LM-adapted T5 1.1 checkpoints the paper recommends are on Hugging Face, for example [google/t5-large-lm-adapt](https://huggingface.co/google/t5-large-lm-adapt).

## How do you use prompt tuning in code?

This sets up prompt tuning on an LM-adapted T5 checkpoint, initializing the prompt from text as the PEFT docs show. Class and argument names are from the PEFT v0.22.0 reference ([PromptTuningConfig](https://huggingface.co/docs/peft/package_reference/prompt_tuning), [PeftModel](https://huggingface.co/docs/peft/package_reference/peft_model)).

```python
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
from peft import PromptTuningConfig, PromptTuningInit, get_peft_model

model_id = "google/t5-large-lm-adapt"   # LM-adapted T5 1.1, as the paper recommends
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)

init_text = "Classify the sentiment of this review as positive or negative:"
config = PromptTuningConfig(
    task_type="SEQ_2_SEQ_LM",
    prompt_tuning_init=PromptTuningInit.TEXT,
    prompt_tuning_init_text=init_text,
    num_virtual_tokens=len(tokenizer(init_text)["input_ids"]),
    tokenizer_name_or_path=model_id,
)
model = get_peft_model(model, config)
model.print_trainable_parameters()
# Train with a standard transformers Trainer or your own loop.
```

The paper itself trained with a learning rate of 0.3 (Sec. 3), far higher than typical full fine-tuning rates.

## Common pitfalls

- **Small models.** Prompt tuning is competitive "as models exceed billions of parameters" ([Lester et al., Abstract](https://arxiv.org/abs/2104.08691)). On models of 100M to 1B parameters, the P-Tuning v2 authors found it "performs much worse than fine-tuning" ([Liu et al. 2022, Sec. 3.1](https://arxiv.org/abs/2110.07602)).
- **Span-corruption-only checkpoints.** With off-the-shelf T5 1.1, "only 2 out of 5 models" worked well; mid-sized models often never produced a legal label. LM-adapted checkpoints worked across sizes (Sec. 3.2).
- **Random initialization at small sizes.** Random uniform initialization lagged sampled-vocabulary and class-label initialization, though the difference vanished at XXL (Sec. 3.2, Figure 3). PEFT's docs warn that `RANDOM` soft tokens "may fall outside of embedding manifold" ([PEFT docs](https://huggingface.co/docs/peft/package_reference/prompt_tuning)).
- **Very long prompts.** Gains beyond 20 tokens were marginal, and going past 100 "appears mildly detrimental for larger models" (Sec. 3.2, footnote 6).
- **Sequence labeling and extractive QA.** In the P-Tuning v2 paper, input-only prompts scored 1.0 EM on SQuAD 1.1 with BERT-large, against 84.2 for fine-tuning ([Liu et al. 2022, Table 3](https://arxiv.org/abs/2110.07602)).

> **How we checked this**
> We read the full arXiv paper (2104.08691 v2, Sept. 2, 2021) and took every result from the named section, figure or table. The parameter table is our arithmetic using the paper's E × P formula and the model dimension in the published T5-XXL LM-adapt config; the 5-token row matches the paper's 20,480. Venue is from the ACL Anthology. Library details and the code are checked against the PEFT v0.22.0 reference. All sources opened Dec. 4, 2026; we did not run the code.

## FAQ

### What is a soft prompt?
A soft prompt is a sequence of trainable vectors prepended to a model's input embeddings. Unlike a written prompt, its vectors are learned by backpropagation and need not correspond to real words ([Lester et al., Sec. 2](https://arxiv.org/abs/2104.08691)).

### Is prompt tuning as good as fine-tuning?
In the original paper it matched model tuning on SuperGLUE at T5-XXL (11B parameters) but trailed it at smaller sizes ([Lester et al., Sec. 3.1, Figure 1](https://arxiv.org/abs/2104.08691)). It beat model tuning on four of six out-of-domain QA sets (Table 1).

### How many parameters does prompt tuning train?
Prompt length times embedding size. On T5-XXL a 5-token prompt is 20,480 parameters, and the paper's 100-token default is 409,600, under 0.01% of the model (Sec. 2.1, Figure 2).

### What is the difference between prompt tuning and prefix tuning?
Prompt tuning trains vectors at the input layer only; prefix tuning trains them at every layer and uses an MLP during training. Lester et al. call prompt tuning a simplification of prefix tuning (Sec. 4).

### What is the difference between prompt tuning and prompt engineering?
Prompt engineering picks words by hand from a fixed vocabulary. Prompt tuning learns continuous vectors from labeled data. In the paper, prompt-tuned T5-Large beat few-shot prompted GPT-3 175B on SuperGLUE (Sec. 3.1).

### Can one model serve several prompt-tuned tasks at once?
Yes. Each task stores only its prompt, and examples from different tasks can share one batch through the same frozen model (Figure 2).

### Does Hugging Face PEFT support prompt tuning?
Yes, through `PromptTuningConfig` with `TEXT`, `SAMPLE_VOCAB` or `RANDOM` initialization ([PEFT docs](https://huggingface.co/docs/peft/package_reference/prompt_tuning)).

## Related techniques

- [Prefix tuning](https://launchkudos.com/news/llm-fine-tuning-prefix-tuning): trainable prefixes at every layer of a frozen model
- [P-Tuning and P-Tuning v2](https://launchkudos.com/news/llm-fine-tuning-p-tuning): prompt embeddings from an LSTM/MLP encoder; v2 adds them at every layer
- [All 15 LLM fine-tuning techniques](https://launchkudos.com/news/llm-fine-tuning-techniques)

## Sources

- Brian Lester, Rami Al-Rfou, Noah Constant. "The Power of Scale for Parameter-Efficient Prompt Tuning." arXiv:2104.08691, Apr. 18, 2021 (v2 Sept. 2, 2021); EMNLP 2021. [arXiv](https://arxiv.org/abs/2104.08691), [ACL Anthology](https://aclanthology.org/2021.emnlp-main.243/). Read Dec. 4, 2026.
- Hugging Face PEFT v0.22.0, [Prompt tuning reference](https://huggingface.co/docs/peft/package_reference/prompt_tuning) and [PeftModel reference](https://huggingface.co/docs/peft/package_reference/peft_model). Read Dec. 4, 2026.
- T5 1.1 LM-adapted checkpoints on Hugging Face: [google/t5-large-lm-adapt](https://huggingface.co/google/t5-large-lm-adapt), [google/t5-xxl-lm-adapt config](https://huggingface.co/google/t5-xxl-lm-adapt/blob/main/config.json). Read Dec. 4, 2026.
- Authors' code: [google-research/prompt-tuning](https://github.com/google-research/prompt-tuning). Opened Dec. 4, 2026.
- Xiang Lisa Li, Percy Liang. "Prefix-Tuning: Optimizing Continuous Prompts for Generation." arXiv:2101.00190, 2021. [arXiv](https://arxiv.org/abs/2101.00190). Read Dec. 4, 2026.
- Xiao Liu et al. "P-Tuning v2: Prompt Tuning Can Be Comparable to Fine-tuning Universally Across Scales and Tasks." arXiv:2110.07602, 2021; ACL 2022. [arXiv](https://arxiv.org/abs/2110.07602). Read Dec. 4, 2026.

**Series:** [← Prev: P-Tuning](https://launchkudos.com/news/llm-fine-tuning-p-tuning) · [All 15 techniques](https://launchkudos.com/news/llm-fine-tuning-techniques) · [Next: Instruction Tuning →](https://launchkudos.com/news/llm-fine-tuning-instruction-tuning)
