Prompt-based learning is a machine learning paradigm in which a downstream task is reformulated as a text completion problem that a pretrained language model already knows how to solve, instead of training a new task-specific output layer. In prompting, it describes the shift from “pre-train, then fine-tune” to “pre-train, prompt, and predict”: a template wraps the input, the model fills a gap or continues the text, and a mapping converts that output into a label or answer.
The approach matters in artificial intelligence because it lets one model handle many tasks with few or no labeled examples. It covers both pure prompting of a frozen model and prompt-based fine-tuning, where the model or a small set of prompt parameters is trained while keeping the cloze-style task format.
How prompt-based learning reformulates a task
Prompt-based learning converts an input into a prompt using a template, lets the language model predict the missing or next tokens, and maps those tokens back to the target output with a verbalizer. For sentiment classification, the review “The battery died in an hour” becomes “The battery died in an hour. It was [MASK].” The model scores candidate words such as “great” and “terrible”, and the verbalizer maps them to positive and negative.
The benefit is that the task now matches the pretraining objective. A masked language model was trained to fill blanks, so a cloze prompt reuses knowledge it already has, whereas a randomly initialized classification head must learn everything from the labeled data. This is why prompt-based methods outperform standard fine-tuning when only a few dozen examples are available.
The table below summarizes the building blocks of a prompt-based pipeline.
| Element | Purpose | Example |
|---|---|---|
| Template | Wraps the input in natural-language context | “[X] Overall, it was [MASK].” |
| Answer space | Defines the allowed model outputs | {great, terrible} |
| Verbalizer | Maps answers to task labels | great to positive, terrible to negative |
| Pretrained model | Scores or generates the answer | Masked or autoregressive language model |
| Tuning strategy | Decides which parameters change | None, prompt only, or full model |
Prompt shapes and template design
Templates come in two shapes: cloze prompts, where the answer fills a gap inside the text, and prefix prompts, where the answer continues the text. Cloze prompts suit masked models such as BERT and RoBERTa, while prefix prompts suit autoregressive models such as GPT-style decoders.
Templates can also be manual or automatically searched. A hard prompt consists of real vocabulary tokens chosen by a person or a discrete search algorithm. A soft prompt consists of continuous embedding vectors optimized by gradient descent, which need not correspond to any readable words.
| Prompt type | Form | Best fit |
|---|---|---|
| Manual hard prompt | Handwritten natural-language template | Quick experiments, interpretable systems |
| Discrete searched prompt | Tokens found by search or paraphrasing | Squeezing accuracy from frozen models |
| Soft prompt | Trainable continuous vectors | Parameter-efficient adaptation |
| Hybrid prompt | Readable anchor words plus trainable tokens | Balancing control and accuracy |
Good templates share several properties. They place the gap where a natural continuation would appear, use label words the model has seen often in similar contexts, and keep the input text intact. Practitioners usually test three to five candidate templates and several label-word sets, because the best combination is difficult to predict from intuition alone and can change between model families.
Answer engineering deserves the same attention as template design. A verbalizer may map several words to one class, for example “great”, “excellent” and “good” to positive, which smooths out the prior bias of any single token and usually improves stability.
Tuning strategies within the paradigm
Prompt-based learning is not one algorithm but a family of tuning strategies that differ in which parameters are updated. The choice drives storage cost, data requirements and accuracy.
| Strategy | What is trained | Main trade-off |
|---|---|---|
| Tuning-free prompting | Nothing | No training cost, but sensitive to wording |
| Fixed-prompt model tuning | All model weights, template fixed | Strong few-shot accuracy, full model per task |
| Prompt tuning | Only soft prompt vectors | Tiny per-task storage, needs large models |
| Prefix tuning | Key and value vectors at each layer | More capacity than input-level prompts |
| Prompt plus model tuning | Prompt and model weights | Highest flexibility, highest compute cost |
Pattern-Exploiting Training, known as PET, and LM-BFF are representative fixed-prompt model tuning methods. Prompt tuning, prefix tuning and P-tuning are parameter-efficient methods: research has shown that prompt tuning approaches full fine-tuning quality once models reach roughly ten billion parameters, while gaps remain at smaller scales.
Relation to in-context learning and instruction tuning
In-context learning is a special case of tuning-free prompt-based learning in which demonstrations are placed inside the prompt and no weights change. Few-shot prompting of large chat models therefore belongs to the same paradigm, even though the vocabulary differs.
Instruction tuning generalizes the idea in the opposite direction: a model is fine-tuned on many tasks phrased as natural-language instructions, which makes later prompts more reliable. Modern prompt engineering largely builds on models that were prepared through instruction tuning, so the original cloze-template techniques now matter most for smaller encoders and classification pipelines.
Limitations and practical pitfalls
The central weakness is prompt sensitivity: small changes in template wording, label words or demonstration order can shift accuracy by many percentage points. Results reported with a single template are therefore unreliable unless they are averaged over several prompts and random seeds.
- Verbalizer bias: label words with higher prior frequency are predicted more often, which calls for calibration or multiple label words per class.
- Multi-token answers: cloze prompts handle single-token labels easily but need extra decoding logic for longer answers.
- Evaluation leakage: tuning templates on the test set inflates scores, so template selection needs a held-out split.
- Interpretability of soft prompts: learned vectors rarely map to meaningful words, which complicates auditing.
Explained without jargon
A language model has read huge amounts of text. It is very good at filling in missing words. Prompt-based learning turns a new job into a fill-in-the-blank exercise. That way, the model can use what it already knows.
Suppose you want to know whether a review is happy or angry. You add the sentence “It was ___.” The model fills the gap with “great” or “awful”. A simple rule turns that word into an answer. Very little extra training is needed.
A typical use case
A support team at a mid-sized software company wants to route incoming tickets into five categories, but it has only about 80 labeled tickets. Standard fine-tuning of a classification head on a 350-million-parameter encoder reaches mediocre accuracy because the data is too small to train the new layer reliably.
The team instead applies prompt-based fine-tuning. Each ticket is wrapped in the template “[ticket] This request is about [MASK].” and the verbalizer maps the words “billing”, “login”, “bug”, “feature” and “account” to the five queues. They compare three templates on a held-out split and keep the most stable one. The outcome is a clear accuracy gain over the plain classifier, achieved with the same small dataset and a model that runs cheaply on existing servers.