Notes

P-Tuning

A prompt does not have to be made of words. Once the model's input is a sequence of vectors, you can learn vectors that no word maps to and train only those, leaving the billions of weights untouched. P-Tuning was among the first methods to do that well.

Learned vectors instead of phrasing

The method inserts a handful of trainable continuous prompt embeddings into the input alongside the real tokens, and backpropagates the task loss into those embeddings only. Two choices distinguish it. The pseudo-tokens can be placed anywhere in the template, not only at the front. And they are produced by a small prompt encoder, an LSTM or MLP, rather than being independent free vectors, so neighbouring pseudo-tokens stay correlated instead of drifting apart during training. The paper that introduced it showed GPT-style models matching BERT on language-understanding tasks once the prompt was learned rather than hand-written.

Where it fits
  • Training touches well under 1% of the parameters, so a task costs megabytes of storage and a single GPU rather than a full fine-tuning run.
  • Input-level prompts alone only work well on very large models. P-Tuning v2 fixes that by inserting prompts at every layer, which makes the approach usable from a few hundred million parameters upward and competitive on sequence labelling.
  • It ships as a one-line configuration in Hugging Face PEFT, alongside LoRA and prefix tuning.

LoRA has since become the default parameter-efficient choice, but P-Tuning remains the clearest demonstration of the underlying idea: prompt engineering taken off the keyboard and handed to gradient descent.

P-Tuning adapts a frozen language model by inserting a few trainable continuous prompt embeddings into its input and learning only those, using a small prompt encoder so the inserted vectors stay coherent; the pseudo-tokens may sit anywhere in the template, not just at the front. It matters because a task can be adapted by training well under 1% of the parameters, giving per-task adapters that cost megabytes instead of a full model copy.

When you want an AI assistant to do one specific job, you can rewrite your instructions over and over until something finally clicks. P-Tuning takes the guesswork out of that. Instead of words, it learns a short sequence of invisible cue signals that get slipped into the input, and it adjusts them by trial and error until the model does the job well. The assistant itself is never changed — only the cue. It is like discovering the exact phrasing that makes a colleague understand you instantly, except the computer searches for that phrasing automatically, and the result is too compact to read as language.