Technologies & Models

Learning from Few Examples, or None: Has the Machine Outgrown Data?

A model recognises a category it has never seen pictured; another does a new task from two examples. Is big data over? No: it has moved elsewhere.

4 min read This article is also available in Arabic

A person working on a laptop overlaid with cybersecurity icons

The Nano capsuleOne minute

Few-shot learning means a model performs a new task from one or a handful of examples; zero-shot learning means it relies on a verbal description alone. This does not mean the machine has dispensed with data. Large models carry vast knowledge acquired in pre-training on huge amounts of text and images, and they redeploy it for the new task. The zero here is zero examples for the task, not zero knowledge. It opens a door for fields and languages with few resources, but it is fragile: merely changing the order of examples in the prompt can move accuracy from near chance to near the best results. Value shifts from gathering much to choosing the few well.

Read the full article Collapse the article 4 min read

Tell someone who has never seen a zebra that it is "a striped horse", and they will recognise one when they meet it. This is what machines have been trying to imitate for years: to recognise what they were never explicitly trained on, relying on what they already know. And the question that keeps coming up is whether artificial intelligence no longer needs data.

Three terms that get mixed up

Few-shot learning is when a model is shown a handful of examples; one-shot learning is a single example; and zero-shot learning is when it sees no example of the task at all and is given only a description of it. The common confusion is that "zero examples" means "zero data". It does not, as will become clear.

An idea older than the hype

In a 2006 paper in the IEEE journal on pattern analysis, Li Fei-Fei and two colleagues showed that a new visual category can be learned from one or a few images if the system reuses what it learned from earlier categories, even dissimilar ones; they tested this on 101 categories. In 2009 Christoph Lampert and colleagues classified categories with no training images at all: each category was described by human-written attributes, such as shape and colour, that the system had learned beforehand from other images. For this they built the Animals with Attributes dataset: more than 30,000 images of 50 kinds of animal and 85 attributes. So the root is old; what has changed is the scale of prior knowledge.

What did large models change?

In the 2020 paper "Language Models are Few-Shot Learners", OpenAI researchers showed that GPT-3 performs new tasks from instructions and examples written in the prompt itself, with no update to its weights and no retraining. In 2021 the company presented CLIP, trained on 400 million image-text pairs, which matched the accuracy of the well-known ResNet-50 on ImageNet without using any of its 1.28 million training examples.

The lesson lies in those very figures: the big data did not vanish; it moved from the front of every task into a general foundation that is built once and used many times. Building that foundation is probably costly, so "few" should not be read as "cheaper" for the system as a whole.

A fragility the headline hides

It is said that choosing the examples is a secondary detail; the research says otherwise. Tony Zhao and colleagues found in 2021 that GPT-3's few-shot performance is "unstable": changing the wording of the prompt, the choice of examples or their order can move accuracy from near chance to near the best results of other methods. Yao Lu and colleagues found that example order alone is enough to produce this spread, and that a good order for one model does not necessarily carry over to another. Reducing the examples raises the weight of each: a single biased or ambiguous example can mislead the whole model.

What is useful here?

  • Evaluate on your own cases before relying on it: laboratory results are not enough.
  • Choose examples carefully and try different wordings and orders; this is a craft that can be learned.
  • Small, high-quality collections in sensitive fields, especially for languages and topics with few resources. This is likely to help Arabic and its contexts, but it needs measuring, not assuming; see the article "Arabic Artificial Intelligence: Do We Make or Consume? Sovereignty and Arabic Language Models".
  • Keep a human as judge where mistakes are costly, as in the article "Responsible Artificial Intelligence: Four Principles for Governance and Trust".

Our relationship with the model has shifted a little as a result: from programming it with thousands of silent examples to conversing with it much as one teaches a bright pupil. Choosing the example well remains worth more than having many examples. Do we know how to give the machine the one word that replaces a thousand examples?

References

  1. C. Lampert, H. Nickisch, S. Harmeling, Learning to Detect Unseen Object Classes by Between-Class Attribute Transfer, CVPR (2009)
  2. L. Fei-Fei, R. Fergus, P. Perona, One-shot Learning of Object Categories, IEEE Transactions on Pattern Analysis and Machine Intelligence 28(4): 594–611 (2006)
  3. T. Brown et al., Language Models are Few-Shot Learners, arXiv:2005.14165 (2020)
  4. A. Radford et al., Learning Transferable Visual Models From Natural Language Supervision, arXiv:2103.00020 (2021)
  5. T. Zhao, E. Wallace, S. Feng, D. Klein, S. Singh, Calibrate Before Use: Improving Few-Shot Performance of Language Models, arXiv:2102.09690 (2021)
  6. Y. Lu, M. Bartolo, A. Moore, S. Riedel, P. Stenetorp, Fantastically Ordered Prompts and Where to Find Them, arXiv:2104.08786 (2021)