Prefix Tuning & Prompt Tuning - Steering LLMs with Learnable Prefixes

LESSON

LLM Training, Alignment, and Serving

006 30 min intermediate

Day 310: Prefix Tuning & Prompt Tuning - Steering LLMs with Learnable Prefixes

The core idea: prefix tuning and prompt tuning are parameter-efficient adaptation methods that try to steer a frozen model not by changing its large weight matrices, but by learning small task-specific vectors that influence how the model processes the input and internal context.


Today's "Aha!" Moment

The insight: After LoRA, we have one clear way to adapt a model cheaply:

Prefix tuning and prompt tuning explore a different idea:

That means adaptation does not always have to look like "edit the model." It can also look like "prepend learned task information that teaches the frozen model how to behave."

Why this matters: This is the conceptual shift from modifying parameters inside the network to modifying the context the network sees, either literally at the embedding level or effectively inside the attention stack.

Concrete anchor: A natural-language prompt already changes model behavior at inference time. Prompt tuning and prefix tuning take that intuition and make part of the prompt trainable.

Keep this mental hook in view: These methods adapt the model by learning how to talk to it internally, not by rewriting most of its weights.


Why This Matters

20/05.md established that LoRA makes adaptation cheap by shrinking the trainable update in weight space.

This lesson adds an important contrast:

That matters because PEFT is not one technique. It is a design space about where the adaptation boundary should live:

Understanding that boundary is what makes the next comparison lesson useful instead of just taxonomic.


Learning Objectives

By the end of this session, you should be able to:

  1. Explain the difference between prompt tuning and prefix tuning at a high level.
  2. Describe how these methods steer a frozen model through learned prompt-like parameters instead of full weight updates.
  3. Evaluate when input-side steering is a better fit than weight-side adaptation like LoRA.

Core Concepts Explained

Concept 1: Prompt-Like Adaptation Exists Because Sometimes Steering the Model Is Cheaper Than Editing It

For example, a team has a very large frozen language model and wants task-specific behavior for summarization, sentiment classification, or structured generation, but wants to avoid maintaining separate fully tuned copies.

At a high level, If the base model is already highly capable, maybe we do not need to change the whole network or even insert adapters deep inside it. Maybe we only need to teach it a better starting context for a task.

Mechanically: The family intuition is:

This is attractive because:

The shared bet is that the model's latent capability is already present and just needs to be activated or organized correctly.

In practice:

The trade-off is clear: You gain extreme parameter efficiency, but you also reduce how directly you can reshape the model's internals compared with LoRA or full fine-tuning.

A useful mental model is: Instead of modifying the machine, you are configuring the initial conditions under which the machine starts thinking.

Use this lens when:

Concept 2: Prompt Tuning and Prefix Tuning Move the Adaptation Boundary to Different Places

For example, Two teams both want cheap adaptation. One learns a small set of soft prompt embeddings prepended to the input. The other learns prefixes that affect attention behavior more deeply inside the model.

At a high level, Both methods are "learned prompts," but they are not identical in where they intervene.

Mechanically: Prompt tuning usually means:

The model experiences those learned vectors like a specialized prompt that humans never had to write manually.

Prefix tuning usually means:

This can give the adaptation more leverage than a simple input-embedding prompt, because the learned task signal reaches the attention mechanism more directly across layers.

So the rough distinction is:

In practice:

The trade-off is clear: The deeper the steering signal reaches, the more expressive it can become, but the further you move from a minimal "input-only" adaptation story.

A useful mental model is: Prompt tuning is like writing a better introduction before the conversation begins. Prefix tuning is like injecting hidden briefing notes directly into the model's attention process.

Use this lens when:

Concept 3: These Methods Win When the Base Model Is Strong and the Task Mainly Needs Steering, Not Reconstruction

For example, a high-quality pretrained model already understands general language and task formats. What a team needs is to make it reliably adopt a specific output style or task-specific conditioning pattern.

At a high level, Prefix and prompt tuning are strongest when the capability is latent and the main problem is elicitation plus lightweight specialization.

Mechanically: These methods tend to work best when:

They are often weaker when:

That is why they belong in the PEFT family but do not replace every other method.

In practice:

The trade-off is clear: You gain minimal trainable state and strong modularity, but you accept a narrower channel for changing behavior.

A useful mental model is: These methods are like a very lightweight steering wheel. If the car already has a good engine and good traction, that may be enough. If the engine itself is wrong for the road, steering alone will not solve the problem.

Use this lens when:


Troubleshooting

Issue: "Why use learned prompts instead of just writing a better manual prompt?"

Why it happens / is confusing: Natural-language prompts already steer behavior, so learned prompts can sound redundant.

Clarification / Fix: Manual prompts are useful, but learned prompts are optimized directly for the task objective. They can discover task-specific conditioning patterns that are awkward or impossible to express reliably in plain language.

Issue: "We tried prompt tuning and got weaker results than LoRA."

Why it happens / is confusing: Prompt-like methods are lighter, but they also have a narrower adaptation channel.

Clarification / Fix: That often means the task needs more expressive adaptation than input-side steering can provide. Re-check task difficulty, base-model strength, and whether a deeper method such as LoRA is more appropriate.

Issue: "These methods are tiny, so they should always be best."

Why it happens / is confusing: Small trainable state is attractive and easy to celebrate.

Clarification / Fix: Tiny parameter count is only one objective. Compare quality, stability, serving simplicity, and task coverage too. The smallest adaptation is not automatically the best adaptation.


Advanced Connections

Connection 1: Prefix/Prompt Tuning <-> In-Context Learning

These methods sit near the boundary between training-time adaptation and inference-time prompting. They turn the intuition of prompting into something trainable and repeatable.

Connection 2: Prefix/Prompt Tuning <-> PEFT Comparison

This lesson sets up the comparison in 20/08.md: the main design question across PEFT methods is where the task signal enters the frozen backbone and how much expressive capacity that gives you.


Resources

Optional Deepening Resources


Key Insights

  1. These methods adapt from the context side rather than the weight side - the backbone stays frozen and the task signal is learned as prompt-like state.
  2. Prompt tuning and prefix tuning are related but not identical - they differ in where the learned task vectors enter the model and how much leverage they get.
  3. They work best when the capability is already latent in the base model - steering is powerful, but it cannot easily invent deep missing competence from nothing.

PREVIOUS LoRA (Low-Rank Adaptation) - Fine-tune 175B Models on Consumer GPUs NEXT Instruction Tuning - Teaching LLMs to Follow Instructions

← Back to LLM Training, Alignment, and Serving

← Back to Learning Hub