Rakshith Subramanyam
← all writing
Paper Jan 3, 2023 2 min read

CAML: contrastive knowledge-augmented meta-learning for few-shot classification

WACV 2023 · Paper · arXiv · Code

Rakshith Subramanyam, Mark Heimann, T.S. Jayram, Rushil Anirudh, Jayaraman J. Thiagarajan

Few-shot learning asks a model to recognize new classes from one to five examples. Meta-learners like MAML learn an initialization that adapts quickly, but real task streams are heterogeneous: birds one day, aircraft or textures the next. A single initialization struggles, and newer methods that add task-specific structure still adapt each task largely in isolation.

CAML gives the meta-learner a memory. It maintains a knowledge graph that summarizes the tasks it has seen, and uses it to decide how to modulate the base learner for each new task.

How it works

  1. Encode the task. Class prototypes (averaged ResNet-18 embeddings of the support examples) form a small graph for the current task.
  2. Consult the knowledge graph. The task graph is connected to a meta knowledge graph of past experience, and a contrastive distillation loss pulls relevant knowledge into the task encoding.
  3. Modulate the learner. The knowledge-enhanced encoding gates the shared initialization, giving each task its own starting point before MAML’s inner-loop adaptation.
  4. Update the memory. The knowledge graph is updated with a moving average after each task, so it accumulates history without being overwritten.

Results

Evaluated on Meta-Dataset (birds, textures, aircraft, fungi, flowers, traffic signs) and DomainNet, against MAML, MuMo-MAML and ARML (mean accuracy, 5-way):

Setting ARML CAML
Standard few-shot, 1-shot (avg of 4 datasets) 48.70 49.43
Standard few-shot, 5-shot 62.00 62.68
Multi-domain (DomainNet), 1-shot 46.01 48.01
Multi-domain (DomainNet), 5-shot 63.19 65.80
Unseen dataset (leave-one-out), 1-shot 36.65 38.93
Unseen dataset (leave-one-out), 5-shot 49.50 53.10

The gains grow as tasks get more different from training. On standard few-shot they’re marginal; when the test task comes from a dataset never seen in training they reach up to 5 points (1-shot) and 10 points (5-shot), for example on traffic signs.

Why it matters

Using structured outside knowledge to adapt better with little data is the same move I later made with language: in CREPE with CLIP prompts, and in DECIDER with LLM-generated attributes.