One-shot Learning

Learning a new class from exactly one example — and the split that matters: one-shot prompting updates no weights; classical one-shot training does.

Published Updated

On this page

Definition

One-shot learning means getting a model to recognise a new class, or perform a new task, from exactly one labelled example. The phrase covers two genuinely different things, and separating them is the whole game: one-shot prompting, where you paste a single worked example into a large language model's prompt and no weights change at all, and classical one-shot training, an older computer-vision regime where the model really does update its weights to learn from single examples — just not in the way you would guess.

The two senses even come from different eras. One-shot prompting is the newer meaning, popularised by the GPT-3 paper's zero-/one-/few-shot framing; "one-shot learning" as a research term comes from vision and predates it by a decade, running from Fei-Fei's early work through Lake's Omniglot benchmark. They share a name and almost nothing else.

Confusing them costs real money and real bugs. Treat a single prompt example as if it trained the model and you will eventually delete it, expecting the lesson to stick — and watch quality collapse, because it was doing work on every call, not once. Go the other way and treat the classical regime as ordinary fine-tuning on one image, and you will fine-tune on one image, overfit it instantly, and ship a model that recognises that one photo and nothing else.

How It Works

The two senses run on completely different machinery, which is the real reason to keep them apart.

One-shot prompting: one demonstration, no weight change

You place a single worked example in front of the real request:

Text: "the wifi kept dropping all weekend"    Category: connectivity
Text: "charger stopped working after a month"  Category:

That one example fixes the format and the label space — it tells the model the answer is a short category word, not a sentence — and the model supplies the rest from what it already learned in pre-training. No gradient is computed and nothing about the model changes; the example is just tokens that are read and thrown away when the request ends. It is exactly few-shot prompting with the example count turned down to one, and the same cost model applies: that single example is re-sent, and re-billed, on every request, so the token arithmetic worked out on the few-shot page carries over unchanged. One example is the floor at which in-context learning still pins a format — go one lower, to zero-shot, and you are leaning on the instruction alone.

The GPT-3 paper (Brown et al., 2020) drew the line precisely: one-shot is "the same as few-shot except that only one demonstration is allowed," and across the zero-, one- and few-shot settings alike, "no [weight] updates are allowed." The whole family is inference-time behaviour, not training.

Classical one-shot training: learn a similarity, not the class

The classical regime faces a problem the prompting one never does: you genuinely want a model that can recognise a brand-new category it was not built to know. The naive move — take the one labelled image and run gradient descent on it — fails immediately. A single example gives the optimiser nothing to generalise from, so it memorises the pixels and learns a detector for that exact photo.

The trick that makes one-shot training work is to not train on the one example at all. Instead you train, over many other classes, a function that measures how similar two inputs are — an embedding space in which same-class things land close together and different-class things land far apart. Once that space exists, classifying an unseen class from its single example is just nearest-neighbour: embed the one labelled example, embed the query, and pick whichever labelled example the query lands closest to. This is a meta-learning move — you are learning how to learn from one example, not learning any particular class.

Two architectures define the approach. Siamese networks (Koch, Zemel & Salakhutdinov, 2015) use twin networks with shared weights to output a similarity score for a pair of images, then solve a one-shot task by scoring the query against each single support example and taking the best match. Matching Networks (Vinyals et al., 2016) fold the embedding and the nearest-neighbour rule into one end-to-end model. In both, weights are updated heavily — but during meta-training on the other classes, never on the one example you are ultimately asked to recognise.

The benchmark built for this is Omniglot (Lake, Salakhutdinov & Tenenbaum, 2015): 1,623 handwritten characters drawn from 50 different alphabets, each character produced by just 20 different people. It is deliberately the mirror image of a dataset like ImageNet — thousands of classes, only 20 examples each — so that you cannot cheat by training a normal classifier and have to learn from almost nothing per class. Evaluation is posed as an N-way 1-shot task: show the model one example of each of N unseen characters, then hand it a fresh character and ask which of the N it is.

That N is where most one-shot numbers go wrong, because it sets the chance floor. In a 5-way 1-shot task, a model guessing at random is right 1 time in 5 — 20%. In a 20-way task the same random guesser scores 1 in 20 — just 5%. So "90% one-shot accuracy" means almost nothing until you know N: 90% at 5-way is only a little above a coin-flippy version of the task, while 90% at 20-way, where chance is 5%, is a hard result. A shot count quoted without its N is not interpretable, and this is the single most common way one-shot figures mislead.

Types

The two regimes are worth holding side by side, because the differences are total.

One-shot prompting (in-context). The one example lives in the context window of an already-trained model. No weights change, no gradient is computed, and the effect lasts exactly one request. This is the language-model-era meaning, and the one most people now arrive searching for.

Episodic / metric one-shot training. The one example is a support set of size one inside an N-way 1-shot episode. Weights are updated — heavily — but on a training distribution of other classes, so that at test time a single example of an unseen class is enough to classify it. Siamese networks, Matching Networks and prototype-based methods all live here, and the setting is squarely a meta-learning problem.

Along the same axis sit the sibling regimes, each with its own page: zero-shot learning gives no example at all, and few-shot learning gives a handful — typically three to five. One-shot is the exact boundary between them: the fewest examples that is still more than none.

Real-World Applications

  • Face verification and recognition. This is the classical one-shot success story in production. You enrol one reference photo of a person; verifying them later is embedding that photo, embedding the live capture, and thresholding the distance between the two — the Siamese / metric-learning recipe exactly. Google's FaceNet (Schroff et al., 2015) is the canonical example: it learns a face embedding in which verification and recognition reduce to distances, which is why a phone can be set up to unlock from essentially a single enrolled face rather than a labelled training set of you.
  • Signature and handwriting verification. The same shape in a different domain: one genuine signature on file, and a Siamese network scores whether a freshly presented signature sits close enough to it in the learned space to be accepted. It is exactly the kind of task Omniglot's handwritten characters were chosen to stand in for.
  • Pinning output format with a single prompt example. The everyday one-shot-prompting use. One worked example is often all it takes to lock a language model into emitting exactly one JSON shape, one citation style, or one fixed set of category labels, where a bare instruction (zero-shot) leaves it drifting between formats. Add a second and third example only when one does not pin it — at which point you have crossed into few-shot.

Key Concepts

  • Support example — the single labelled example the model is allowed to see for the new class; the "1" in one-shot.
  • Embedding / metric space — the learned space in which one-shot classification becomes nearest-neighbour. It, not any individual class, is what the training regime actually optimises.
  • N-way 1-shot episode — the evaluation unit: N unseen classes, one example each, classify a query. N sets the chance floor of 1/N.
  • Siamese network — twin weight-shared networks that score how similar a pair of inputs are; the original one-shot-training architecture.

Challenges

The defining hazard is overfitting to the one example, and it bites the two regimes in different places. In training, gradient descent on a single image is close to pure memorisation — the entire reason metric learning exists is to route around it, by never optimising on the one example directly. In prompting, the single demonstration is a sample of size one from whatever distribution you happened to draw it from, so any accident of that example — an unusual phrasing, a rare label, a stray formatting quirk — becomes the only pattern the model has to copy, and it will copy the accident faithfully.

The N-ambiguity is the second trap, and it is a reporting problem as much as a modelling one. Because one-shot accuracy is meaningless without its N, comparing two methods on "one-shot performance" compares nothing unless both fix the same N and the same split of classes into seen and unseen. It is the same failure as quoting an Artificial Analysis Intelligence Index score without its version (v4.1): the number looks comparable and is not, because the thing underneath it moved.

The third challenge is the name collision itself. Because "one-shot learning" and "one-shot prompting" share a phrase, teams reach for the wrong tool. They try to "one-shot train" a language model by dropping one example in a prompt and expecting it to persist across sessions; or they try to solve a genuine cold-start vision problem — a new manufacturing-defect class with a single photograph of it — by prompting, when a metric-learning model is what that problem actually calls for. The collision is not pedantry: it routes you to the wrong half of the field, and the wrong half does not have the tool you need.

Frequently Asked Questions

Getting a model to recognise a new class or perform a new task from exactly one labelled example. The phrase covers two different things: one-shot prompting in a language model (which changes no weights) and classical one-shot training in computer vision (which does).
No. The single example is ordinary input tokens — read, used to condition the answer, and discarded when the request ends. The weights are byte-identical afterwards, so the example is re-sent and re-billed on every request rather than learned once.
They sit on one axis by example count: zero-shot gives none, one-shot gives exactly one, few-shot gives a handful. One-shot is the boundary — the fewest examples that is still more than none.
Twenty new classes, one example of each, then classify a fresh input into one of the twenty. N sets the chance floor: random guessing scores 1/N, so 5% at 20-way but 20% at 5-way. A one-shot accuracy quoted without its N is not interpretable.
It does not train on that one image. Methods like Siamese and Matching Networks first learn, from many other classes, an embedding where similar things land close together; classifying the new class from its single example is then just nearest-neighbour in that space.

Continue Learning

Explore our use-case guides and prompts to deepen your AI knowledge.