Prefix tuning injects soft tokens deep in every layer. Prompt tuning is the lighter cousin: only a few trainable embeddings prepended at the input embedding layer. It is among the cheapest PEFT methods and a bridge to classic prompt design before the module capstone on adapters.
Learning Objectives
By the end of this lesson, students should be able to:
- Define prompt tuning (soft prompts at the input).
- Contrast soft prompts with discrete hand-written prompts.
- Compare prompt vs prefix tuning on depth and parameter count.
- Configure PromptTuningConfig in PEFT.
- Discuss init strategies (random vs vocab-based).
- Know when soft prompts underfit relative to LoRA.
Prompt tuning freezes the entire pretrained model and learns a small matrix of continuous prompt embeddings P ∈ &mathbb;Rn×d that are prepended to the embedded input tokens. Only P is trained (n soft tokens). The model reads them like ordinary embeddings but they need not correspond to real vocabulary strings.
Soft vs Discrete vs Prefix
| Approach | Trainable? | Where | Params |
|---|---|---|---|
| Discrete prompting | No (human text) | Input tokens | 0 |
| Prompt tuning | Yes (embeddings) | Input only | n × d |
| Prefix tuning | Yes (prefixes) | Every layer KV | Larger |
| LoRA | Yes (A, B) | Selected weights | Depends on r |
Token → vectors
n soft embeddings
Standard forward
Backprop only prompts
PEFT Prompt Tuning
When Prompt Tuning Shines
Good fit
- Huge frozen models.
- Many tasks, tiny storage.
- Classification-style heads.
Weak fit
- Heavy style/domain shift.
- Needs weight-space capacity.
- Very long soft n (context tax).
Init tip
- TEXT init often helps.
- Random can work with care.
- Match tokenizer carefully.
Strengths and Tradeoffs
Strengths
- Extremely small trainable sets.
- Simple serving: cache base, swap P.
- Elegant link to prompting intuition.
Tradeoffs
- Less expressive than LoRA on hard SFT.
- Consumes context window.
- Soft tokens are not interpretable text.
“Prompt tuning means hiring better prompt engineers.” Engineering discrete prompts is complementary. Prompt tuning is gradient-based learning of soft embeddings—an optimization method, not a writing workshop.
Knowledge Check
- Short Answer: What is trained in prompt tuning? Answer: A small set of continuous input embeddings (soft prompts).
- True/False: The backbone weights update freely in prompt tuning. Answer: False—they stay frozen.
- Multiple Choice: Soft prompts live primarily: (a) at the input embedding layer, (b) in the optimizer only, (c) in CSS. Answer: (a).
- Short Answer: How does prompt tuning differ from prefix tuning? Answer: Input-only vs per-layer prefixes (shallower vs deeper).
- True/False: Soft prompts always decode to readable English words. Answer: False.
- Multiple Choice: TEXT initialization: (a) seeds prompts from a string, (b) deletes the tokenizer, (c) trains CNNs. Answer: (a).
- Short Answer: Name one downside versus LoRA for hard domain SFT. Answer: Less capacity / may underfit.
- True/False: Virtual tokens reduce remaining context for the user text. Answer: True.
- Multiple Choice: PEFT class: (a) PromptTuningConfig, (b) AvgPool1d, (c) DynamicBatchCSS. Answer: (a).
- Short Answer: What Vol. 12 capstone lecture is next? Answer: Adapters.
Key Takeaways
- Prompt tuning learns soft input embeddings only.
- Cheapest PEFT tier; great multi-task storage story.
- Shallower than prefix tuning; weaker than LoRA on hard shifts.
- Distinct from discrete prompt engineering.
- Next (capstone): Adapters.
Hands-on idea: Compare accuracy of discrete few-shot prompts vs 8-token prompt tuning on a classification LM.
Discussion prompt: Should product teams expose soft prompts to end users, or keep them internal artifacts?
Recap: Prompt tuning adapts frozen models with a handful of learned input embeddings. Finish the module with Adapters.