Bayesian Few-Shot Learning

Machine Learning
Introduced by
Gordon et al.; Finn, Xu & Levine
Year
2018-2019
Type
Probabilistic meta-learning
Family
Machine learning

What does it do?

Bayesian few-shot learning combines Bayesian inference with meta-learning so that a model can generalize from only a few labeled examples per class.

It treats task-specific parameters as random variables and learns an informative prior across many training tasks, so each prediction comes with a predictive distribution rather than a single point estimate. This is the main difference from deterministic few-shot learners.

The intuition behind the method

Ordinary machine learning needs many examples to confidently learn a new concept. Bayesian few-shot learning instead meta-trains on many small tasks so the model builds a rich prior about what good parameters look like. When a genuinely new task arrives with only a handful of labeled examples, Bayesian updating adjusts the prior with that small evidence, producing a posterior over parameters. Predictions are then marginalized over this posterior, so the model simultaneously predicts a label and tells you how uncertain it is — which is critical whenever errors are costly or data is scarce.

History

Few-shot learning gained momentum with deterministic meta-learners such as Prototypical Networks and Model-Agnostic Meta-Learning (MAML). The Bayesian strand emerged around 2018–2019: Finn, Xu & Levine introduced probabilistic MAML (PLATIPUS), and Gordon et al. proposed amortized Bayesian meta-learning (VERSA), framing meta-learning explicitly as posterior inference.

When to use it

Use Bayesian few-shot learning when each new class or task has only a few labeled examples (often one to five per class in benchmark settings) and the uncertainty of each prediction matters for the decision, for example rare-condition diagnosis, compound activity prediction from few assay results, or cold-start personalization. The method also requires a set of related meta-training tasks or classes: the learned prior is only useful to the extent that those tasks resemble the target task, so without such data its main advantage is lost. Do not choose it when ample labeled data exists for the target task; standard supervised models are then simpler to train and do not need a meta-training set. If calibrated uncertainty is not needed, a deterministic few-shot learner such as Prototypical Networks is a simpler starting point.

Limitations and considerations

  • Requires a large and diverse meta-training set of related tasks; performance can degrade when meta-training tasks do not resemble the target task.
  • Architectural complexity is higher than standard few-shot learners; amortized inference networks add design and tuning burden.
  • Approximation methods (variational inference, MCMC) introduce their own biases and may not converge to the true posterior.
  • Computational cost at meta-training time is substantially higher than deterministic counterparts such as Prototypical Networks.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Each prediction is a predictive distribution over labels rather than a single point estimate, so an uncertainty estimate can be read off with every output; whether that uncertainty is well calibrated has to be checked (see pitfalls).
  • Adapts to new classes from a few labeled examples per class, typically one to five in benchmark settings.
  • Learns an informative prior from related meta-training tasks, so structure shared across tasks is reused when a new task arrives.
  • Amortized inference networks map the support set to posterior parameters in one forward pass, so Bayesian updating at test time avoids per-task iterative optimization.
  • Frames meta-learning explicitly as posterior inference, giving a probabilistic account of few-shot generalization.

Applications

  • Medical image classification from rare disease examples with uncertainty-aware predictions.
  • Drug activity prediction where only a handful of assay measurements are available per compound.
  • Cold-start recommendation: personalizing models for new users with minimal interaction history.
  • Robotics and control: quickly adapting a policy to a new environment from few trials.
  • Natural language processing tasks with extremely limited labeled data per new label category.

How it works

How it works

1

Training is structured as a series of episodes, each mimicking the few-shot scenario: a support set with K labeled examples per class is presented, and the model must predict a query set. This episodic regime forces the model to learn to learn rather than merely memorize, preparing it for genuinely new classes at test time.

2

Across all meta-training episodes, the model learns a prior distribution over task-specific parameters (or latent codes). This prior captures the shared structure across tasks — effectively encoding what a good initial representation looks like before any new-task evidence is observed.

Formula
p(\theta) \text{ learned across meta-training tasks}
3

Given the support set S of the new task, Bayes' rule is applied to update the prior: the posterior p(theta | S) is proportional to the likelihood of the observed labels times the prior. In practice this update is often amortized through a learned inference network that maps the support set directly to posterior parameters, keeping the procedure tractable.

Formula
p(\theta \mid S) \propto p(S \mid \theta)\, p(\theta)
4

Predictions for query points are obtained by marginalizing over the posterior — integrating out parameter uncertainty — rather than committing to a single point estimate. This yields a predictive distribution that reflects both the information in the support set and the remaining uncertainty.

Formula
p(y^* \mid x^*, S) = \int p(y^* \mid x^*, \theta)\, p(\theta \mid S)\, d\theta
5

After each episode, the meta-learner's global parameters (the prior and inference network) are updated via gradient descent on the episode-level loss, aggregated over many episodes. Over time the prior becomes increasingly informative, allowing fast and reliable updating on new tasks with very few examples.

Common pitfalls

  • Assuming that all meta-training tasks come from one task distribution when they are drawn from very different domains; the learned prior then matches the target task poorly and predictive calibration can suffer.
  • Confusing the few-shot evaluation metric (N-way K-shot accuracy) with standard held-out accuracy — always report episode-averaged accuracy with confidence intervals.
  • Choosing an overly restrictive approximate posterior family (e.g., fully factorized Gaussian) when task parameters are strongly correlated.
  • Skipping calibration evaluation (e.g., expected calibration error) and reporting only accuracy, which misses the core benefit of the Bayesian approach.
  • Applying this framework to settings with ample labeled data where simpler supervised methods are faster and equally accurate.

Frequently asked questions

How is Bayesian few-shot learning different from standard few-shot learning?

Standard few-shot methods like Prototypical Networks produce a single point prediction. Bayesian few-shot learning additionally models uncertainty over task parameters, yielding a predictive distribution: you get a label plus a confidence estimate, whose calibration must be checked on held-out episodes (for example with Expected Calibration Error) before it is relied on.

What is amortized inference in this context?

Rather than running iterative MCMC or variational optimization for each new task, an inference network is trained to map the support set directly to posterior parameters in one forward pass. This makes Bayesian updating fast enough to use at test time.

How many meta-training tasks are typically needed?

No fixed number applies, since the requirement depends on task diversity and model capacity. The meta-training set should contain many episodes drawn from a broad pool of base classes, and it should be substantially larger than the target task pool.

Can I apply this without a GPU?

Hardware requirements depend on model size and episode count, and meta-training is more computationally demanding than for deterministic few-shot learners (see Limitations), so estimate the compute budget for your setup before starting. If resources are tight, a simpler deterministic baseline such as a prototypical or matching-network model is a reasonable comparison.

How do I evaluate calibration?

Compute the Expected Calibration Error (ECE) alongside accuracy: bin predictions by confidence, then measure the gap between average confidence and average accuracy within each bin. A well-calibrated Bayesian few-shot model should show small ECE.

Related methods

Sources

  1. Gordon, J., Bronskill, J., Bauer, M., Nowozin, S. & Turner, R. E. (2019). Meta-Learning Probabilistic Inference for Prediction. International Conference on Learning Representations (ICLR 2019).

    Open publication reference
  2. Finn, C., Xu, K. & Levine, S. (2018). Probabilistic Model-Agnostic Meta-Learning. Advances in Neural Information Processing Systems (NeurIPS 2018), 31.

    Open publication reference