Medium6 min readUpdated 2026-08-12

Explain Prefix Tuning and Prompt Tuning. How are they different from LoRA?

Prefix Tuning and Prompt Tuning focus on parameter-efficient fine-tuning by adding tunable virtual tokens to a frozen model. This question asks how those methods work, how they compare to LoRA, and when you would pick each approach.

diagram showing virtual prefixes, soft prompts, and LoRA low-rank adapters in a transformer
TL;DR
  • Prefix Tuning and Prompt Tuning add tunable soft tokens to a frozen model instead of updating all model weights.
  • Both store extra parameters in the input space: prefix tokens are virtual key/value vectors, prompts are embedding vectors; LoRA injects low-rank updates into weight matrices.
  • They dramatically reduce trainable parameter count but differ in expressive power, where you apply them, and inference cost. Key tradeoffs: parameter count, where parameters live (input vs weights), and how well they adapt internal computation.

In this question, we will learn what Prefix Tuning and Prompt Tuning do, why they are considered parameter-efficient, and how they differ from LoRA. We will keep the explanation hands-on so you can describe mechanics and pick the right tool in interviews.

We will cover the following:

  • The intuition
  • How it actually works
  • When to use each
  • Tradeoffs and failure modes
  • Questions the interviewer might ask
  • What the interviewer is really testing

Direct answer: Prefix Tuning and Prompt Tuning both attach tunable soft tokens to the model input while keeping the base model frozen, whereas LoRA injects learnable low-rank updates directly into specific weight matrices. Prefix and prompt methods act on the input/attention side and are compact and simple to store, while LoRA modifies the linear layers inside the model and often achieves higher adaptation capacity for similar or slightly larger parameter budgets.

The intuition (an analogy that makes it click)

Think of the frozen model as a skilled musician who can play many tunes. Prompt Tuning and Prefix Tuning give the musician a small sheet of hints placed at the front of the music stand. The musician reads the hints and subtly changes performance without changing the instrument.

LoRA instead adds small adjustable gears inside the instrument so it produces different tones. Both approaches avoid replacing the whole instrument, but the gears change fundamental mechanics while the hint sheet nudges behavior at input time.

How it actually works (the real mechanics, with a concrete worked example)

Prompt Tuning stores a sequence of pp learnable embedding vectors and prepends them to the token embeddings each time you run the model. These vectors are optimized so the frozen model behaves as if it had seen a specialized prompt.

Prefix Tuning stores a sequence of mm virtual tokens that are mapped to attention key and value vectors at each attention layer. Instead of prepending embeddings that become normal tokens, the prefix provides extra key/value pairs that the attention mechanism can attend to. That lets the prefix influence internal attention patterns directly.

LoRA selects one or more weight matrices, for example a projection WW of shape din×doutd_{in}\times d_{out}, and models a low-rank additive update ΔW=BA\Delta W = BA with BRdin×rB\in\mathbb{R}^{d_{in}\times r} and ARr×doutA\in\mathbb{R}^{r\times d_{out}}. During training you freeze WW and only learn AA and BB.

The LoRA parameter count for one adapted matrix is roughly LoRA paramsr(din+dout).\text{LoRA params} \approx r(d_{in} + d_{out}).

Worked numeric example. Suppose a transformer with hidden size d=768d=768, we use prefix length m=50m=50, prompt length p=50p=50, and LoRA rank r=8r=8 applied to two matrices per layer across 12 layers. Extra parameter counts are:

MethodExtra params (approx)Notes
Prompt/Prefix (per token)m×d=50×768=38,400m\times d = 50\times768 = 38{,}400Prefix stores mm per-layer key/values may multiply this by layers if separate per layer
LoRA (one matrix)r(din+dout)=8×(768+768)=12,288r(d_{in}+d_{out}) = 8\times(768+768) = 12{,}288Per adapted matrix; multiply by number of adapted matrices
LoRA (24 matrices)12,288×24=294,91212{,}288\times24 = 294{,}912Example: 12 layers, 2 matrices each
Full fine-tune~125,000,000All weights updated, large storage and compute

This table shows why prefix/prompt tuning can be extremely small in parameter count. Prefix tuning often stores different virtual tokens per layer which increases the count compared to a single prompt vector set.

Practical worked step: fine-tuning a classifier with Prefix Tuning

  1. Freeze the base model parameters.
  2. Initialize mm virtual prefix vectors per layer or shared across layers.
  3. Forward pass: compute attention using original keys/values plus prefix keys/values.
  4. Backpropagate and update only prefix parameters and classifier head.
  5. At inference, prepend same learned prefix and run the frozen model.

When to use each

  • Use Prompt Tuning when you want the smallest storage overhead and your model responds well to input-space soft prompts. It is very light but can be limited on complex tasks.
  • Use Prefix Tuning if you need more influence over internal attention and do not mind slightly more parameters because prefixes can be layerwise key/value vectors.
  • Use LoRA when you want stronger representational changes inside the model with still modest parameter costs. LoRA often performs better on tasks that require deeper changes to internal transforms.

Tradeoffs and failure modes

Prefix/Prompt advantages: tiny checkpoints, simple to implement, easy to share. Limitations: they act through input-side steering and may not be able to change internal linear algebra as effectively as weight-space methods.

LoRA advantages: can approximate full weight updates with low-rank structure, often competitive with full fine-tuning for many tasks. Limitations: you must choose which matrices to adapt and rank parameter rr, and storage grows with number of adapted matrices.

A common failure mode is expecting prompt or prefix tuning to match full fine-tuning on every task. For tasks that require large shifts in internal representations, prompt or prefix tuning can underperform. Also be careful about prefix length and LoRA rank because too small values underfit and too large values reduce the parameter-efficiency benefit.

Questions the interviewer might ask

Some follow-up questions you might get:

How do prefixes differ from prompts under the hood? Prompts are learned embeddings prepended to input tokens and then processed normally. Prefixes produce additional attention key/value vectors, which directly influence attention without behaving as regular tokens.

Can you combine LoRA with prompt or prefix tuning? Yes. Combining methods is common. For instance you can apply LoRA to attention projections and also prepend a learned prompt. They can complement each other because they act in different parts of the model.

How do you choose prefix length or LoRA rank in practice? Tune them as hyperparameters. Start small, for example m=20m=20 or r=4r=4, and increase until validation performance saturates. Consider compute and storage constraints when scaling.

What about inference cost differences? Prompt and prefix tuning add minimal compute because they only add extra tokens or small key/values. LoRA adds small matrix multiplications but can be implemented efficiently. Full fine-tuning does not add inference cost but increases deployment complexity because you must store full model weights per task.

Are there security or privacy implications? Parameter-efficient checkpoints are small and easier to share but do not expose full model weights. They do not remove risks like memorization from the base model.

Some things to note:

  • Prefix tuning may store different virtual tokens per layer, increasing parameter count.
  • LoRA needs careful selection of which matrices to adapt and is often applied to attention and feedforward projections.

What the interviewer is really testing

They want to see you understand where additional parameters live and how that affects expressivity, storage, and inference. They also expect you to reason about when input-space steering is enough versus when weight-space updates are needed. Being able to compare parameter counts, describe training and inference changes, and recommend a method for a given constraint shows practical depth.

Further reading in the curriculum

Go deeper on the fundamentals behind this question.

  • Fine-Tuning and Adaptation How to adapt pretrained language models to specific tasks using full fine-tuning, LoRA, instruction tuning, and preference alignment, and when each approach is the right tool.

Related questions

#prefix-tuning#prompt-tuning#lora#fine-tuning#parameter-efficient

How would you rate the quality of this article?

Prepare for your AI engineering interview

This is one of many detailed questions and explainers on StudyAIDesign. Browse the full set, work through the curriculum, and walk into your interview ready.

Follow along for new questions and explainers:Instagram