---
title: "Learning to Few-Shot Learn Across Diverse Natural Language"
description: "LEOPARD learns to build and adapt a text classifier for a new task from a few labeled examples, even when the number of classes changes."
canonical: "https://research.elamur.ai/free/en/papers/bansal-2020-learning-few-shot-learn-across/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/bansal-2020-learning-few-shot-learn-across/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2020](https://md.research.elamur.ai/free/en/papers/2020/) / Learning to Few-Shot Learn Across Diverse Natural Language Classification Tasks

# Learning to Few-Shot Learn Across Diverse Natural Language Classification Tasks

Paper · 2020 · Trapit Bansal, Rishikesh Jha and Andrew McCallum

**Authors:** [Trapit Bansal](https://md.research.elamur.ai/free/en/authors/trapit-bansal/), Rishikesh Jha and [Andrew McCallum](https://md.research.elamur.ai/free/en/authors/andrew-mccallum/) · **Year:** 2020 · **Venue:** Proceedings of the 28th International Conference on Computational Linguistics · **Licence:** [CC BY 4.0 (ACL Anthology)](https://creativecommons.org/licenses/by/4.0/)

[**98** citations OpenAlex, 2026-10-14](https://openalex.org/works?filter=cites:W2987878148) · [Cited by **41** papers in our library of more than 163,000 papers whose bibliographies we read](https://md.research.elamur.ai/free/en/papers/bansal-2020-learning-few-shot-learn-across/cited-by/) · [Proceedings of the 28th International Conference on Computational Linguistics](https://aclanthology.org/volumes/2020.coling-main/) · [licence](https://creativecommons.org/licenses/by/4.0/)

- [Publisher's page](https://aclanthology.org/2020.coling-main.448/)
- [PDF](https://aclanthology.org/2020.coling-main.448.pdf)
- [DOI 10.18653/v1/2020.coling-main.448](https://doi.org/10.18653/v1/2020.coling-main.448)
- [OpenAlex](https://openalex.org/W2987878148)

Citations: OpenAlex, 2026-10-14.

## Summary

A system trained to recognize whether one sentence follows from another may have useful knowledge about language when it encounters a restaurant query. It still needs to learn what counts as a cuisine or a location. Having just a few labeled examples makes the task harder. This paper asks whether earlier supervised tasks can prepare a system to learn a genuinely different task under those conditions. Its setting is [few-shot learning](https://md.research.elamur.ai/free/en/concepts/few-shot-learning/), with the number of available examples counted separately for each label.

The authors propose LEOPARD, a method that starts from pretrained [BERT](https://md.research.elamur.ai/free/en/papers/devlin-2019-bert-pre-training-deep-bidirectional/) and learns how to initialize a classifier for a task from its labeled examples. It groups those examples by label, converts each group into the starting weights and bias for that class, and then uses gradient updates to refine the classifier and the text representations it draws on. A task with a larger label set gets a larger classifier through the same procedure. During training, the authors repeatedly simulate this process and judge the resulting classifier on separate examples from the same task. This teaches the shared system to produce starting points that are useful after adaptation.

The study evaluates transfer across 17 target tasks, including entity typing, review rating prediction, social-media classification, sentiment classification and natural language inference. The paper separates transfer to different classification tasks from transfer to new domains of familiar tasks. In the first group, with 4 labeled examples per class, LEOPARD reaches 45.99% average test accuracy, compared with 40.13% for the strongest baseline average at that budget. The authors report average relative accuracy gains of 14.60%, 10.83% and 11.16% at budgets of 4, 8 and 16 examples per label, respectively. In domain transfer, LEOPARD leads on the Amazon sentiment evaluations, while the multitask BERT variants offer stronger results on SciTail, a scientific entailment dataset.

The controlled comparisons help explain where the method earns its advantage. Removing the learned classifier initializer hurts entity typing in particular. The best choice of which encoder layers to adapt also depends on the target. Updating all layers works best in the reported entity-typing comparison, while keeping more layers fixed works better on SciTail. The results show that preparation for learning from a tiny labeled set can improve transfer, with substantial variation in accuracy and in the value of adaptation across tasks.

## Deep dive: Learning to Few-Shot Learn Across Diverse Natural Language Classification Tasks

LEOPARD learns to build and adapt a text classifier for a new task from a few labeled examples, even when the number of classes changes. · about 35 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### When the decision changes along with the data

The paper studies a form of transfer in which the source and destination can ask different questions of text. A sentiment classifier decides how a passage evaluates something. An entailment classifier decides whether one sentence supports a conclusion expressed in another. An entity-typing system assigns a category to a particular phrase in context. These tasks share a need to represent language, but each uses different evidence to make a decision. The learner must acquire the destination’s decision rule from the examples it receives.

For [text classification](https://md.research.elamur.ai/free/en/concepts/text-classification/), the usual architecture makes the distinction concrete. An encoder turns an input into a vector. A classification layer uses that vector to assign scores to the available classes. Each class needs a set of weights that specifies which features influence its score, together with a bias that can shift that score. A classifier learned for entailment gives its output positions meanings acquired from entailment supervision. A classifier for restaurant queries needs output positions with meanings acquired from restaurant-query supervision. The weight vectors can have compatible dimensions on the input side and still be unsuitable on the output side.

The number of classes can change as well. A shared encoder can process sentence pairs, individual sentences and sentences with a selected phrase. Its output can have a fixed width across all of those inputs. The size of the classifier, however, follows the number of answers the task permits. This creates two questions for transfer. One is which features of language can carry over. The other is how a learner can turn those features into scores for a new set of classes when the available labels are scarce.

The authors treat those questions together because the quality of a starting point matters most when there is little evidence with which to correct it. In ordinary [fine-tuning](https://md.research.elamur.ai/free/en/concepts/fine-tuning/), labeled target examples provide gradients that adjust an existing network to the task. With a tiny training set, those gradients reflect the wording, topics and class examples that happened to be sampled. Good incoming text features help, but the learner also needs a way to use the limited supervision to set up the new decision. The paper asks whether supervised experience with other tasks can prepare both parts of that process.

#### What earlier approaches bring to the setting

The paper describes self-supervised pretraining as a way to acquire parameters that are useful across downstream tasks. Training with a language objective supplies supervision from text itself, after which a downstream task supplies its own labels. The authors situate BERT alongside earlier transfer work on [deep contextualized word representations](https://md.research.elamur.ai/free/en/papers/peters-2018-deep-contextualized-word-representations/) and other pretrained systems. Their concern is the objective used during preparation. A language objective can yield useful representations, while performance after adaptation on a very small labeled set is a separate criterion.

Multitask learning brings labeled source tasks into the preparation. A common encoder can benefit from supervision across tasks while separate classification layers account for their different labels. The authors describe prior work in which multitask training with BERT improved transfer among related problems. The arrangement has a clear advantage when source tasks already differ in their outputs. Each can keep its own classifier. At transfer time, an unfamiliar destination still calls for a classifier of its own, and the small target set has to supply the supervision for that classifier.

Another approach is to form a representation of each class from the labeled examples at hand. Prototypical networks do this by building a representative point, or prototype, for each class and comparing a new input with those representatives. The class inventory can therefore change from one task to the next. A system can build as many representatives as the support examples require. The authors point to a different strength of optimization-based methods. With gradient-based adaptation, a learner can change the way it represents inputs and makes decisions as it receives more supervision. This motivates keeping a support-based way to form a classifier and giving that classifier a route to further adjustment.

The optimization approach that the paper extends is [Model-Agnostic Meta-Learning](https://md.research.elamur.ai/free/en/papers/finn-2017-model-agnostic-meta-learning-fast/), or MAML. It seeks initial parameters from which a learner can make productive progress through gradient descent. An inner loop learns from examples of a particular task. An outer loop improves the starting parameters by measuring how well the inner loop’s result works on other examples. In the standard classification setup discussed by the authors, the parameters include a classifier of a shared shape. A single initial classification layer of that kind is hard to reuse directly when tasks allow different numbers of answers.

#### What counts as a new task

The related work described in the paper includes few-shot experiments that create many episodes by selecting different labels within a single dataset or problem family. A learner can face classes it has never seen while still performing the same general operation. The paper discusses that pattern in vision and in language research on tasks such as relation classification, for which [FewRel](https://md.research.elamur.ai/free/en/papers/han-2018-fewrel-large-scale-supervised-few/) is one example it cites. It also describes applications of meta-learning to low-resource translation and earlier experiments involving subsets of [GLUE](https://md.research.elamur.ai/free/en/papers/wang-2018-glue-multi-task-benchmark-analysis/).

LEOPARD’s evaluation asks how far preparation can travel outside the source task. In particular, it distinguishes a change in domain from a change in what the labels describe. Scientific entailment uses the familiar idea of inference between texts in a new setting. Amazon sentiment applies a familiar kind of judgment to product reviews. Entity typing or identifying what a political message is about introduces a different kind of output. A transfer procedure can have different strengths in these settings, so the paper keeps their results separate.

This distinction also governs the authors’ choice of evaluation data. A few examples per label are meant to limit the learner’s access to the destination during adaptation. The trained classifier can then be judged against a much larger set of examples from that destination. That arrangement puts the emphasis on what a small training sample can support across an actual dataset. It also lets the experiment capture the effect of which labeled examples happen to be available, an important distinction when a rare phrasing or a narrow topic can occupy much of a task’s support.

### The method, step by step

#### From examples to a classifier

LEOPARD begins an episode with a labeled batch for one task. Imagine a task that assigns types to phrases in restaurant queries. The system encodes each example so that its vector represents the phrase together with the query that contains it. It then sorts the examples into groups according to the labels supplied with them. The examples marked as cuisine contribute to the cuisine parameters. Examples marked as location contribute to the location parameters. The same computation applies to each group.

The parameter generator transforms each example vector into quantities that can contribute directly to a classification layer. It averages those quantities within a class. The result is a weight vector and a bias for that class. Placing the class vectors in rows yields a classifier whose size follows the label inventory in the batch. The generator can operate on a label it has never encountered during training because it takes the examples carrying the label as input. The identity of the label serves to group examples and to associate a classifier output with the right answer.

To classify an input, LEOPARD runs the input through the text encoder and a feature projection. The classifier uses the projected features to produce a score for each class. A softmax turns those scores into probabilities across the current task’s alternatives. The generator supplies the starting classifier, and gradient descent can subsequently change both its parameters and the representation used to score new examples. Keeping those stages separate gives the learner a way to use support examples before taking its first update, then to revise its decision based on classification errors.

During meta-training, the authors use separate sampled training batches for generating the classifier and for updating it. They then assess the adapted parameters on a validation batch of the same task. The outer update changes the common starting system so that future episodes begin from parameters better suited to that sequence of operations. The estimate of success comes from examples that the episode has reserved for that assessment.

How LEOPARD learns through a training episode The steps in order.

#### How an episode teaches adaptation

The authors use the episodic framework associated with [Matching Networks](https://md.research.elamur.ai/free/en/papers/vinyals-2016-matching-networks-one-shot-learning/). An episode is a small supervised learning problem built from a task available during training. It contains a support set for adaptation and a validation set for judging the result. A source dataset can contain many labeled examples, while the learner works with small batches inside each episode. Repeating the exercise across tasks gives the outer optimization many examples of what adaptation looks like.

The paper formalizes the task-sampling assumption as follows.

```
Tᵢ ∼ P(T)
```

Here Tᵢ is the task indexed by i. P(T) denotes a distribution over tasks, with T standing for a task drawn from that distribution. The symbol ∼ says that the task is sampled according to the distribution. In the experiment, the source datasets and the authors’ sampling procedure determine which tasks are available for this operation.

For ordinary MAML, the paper writes a single inner update before discussing repeated steps.

```
θᵢ′ = θ − α∇θ Lᵢ(θ, Dᵢᵗʳ)
```

Here θ is the set of starting parameters and θᵢ′ is their value after adapting to task i. The learning rate α controls the size of the step. Lᵢ is the task’s loss, evaluated at θ on its episode training set Dᵢᵗʳ. The superscript ᵗʳ identifies the training data. The operator ∇θ takes the gradient with respect to θ. Subtracting the scaled gradient moves the parameters in the direction that locally reduces the loss. Further inner updates would start from the parameters produced by the preceding step.

The corresponding outer update uses the result of adaptation and a separate batch.

```
θ ← θ − β∇θ ∑_{Tᵢ ∼ P(T)} Lᵢ(θᵢ′, Dᵢᵛᵃˡ)
```

The arrow assigns an updated value to the shared parameters θ. The rate β controls the outer step. The sum ∑ combines the losses from sampled tasks Tᵢ drawn from P(T), with i identifying each task in the sum. The loss Lᵢ uses the task-adapted parameters θᵢ′ and the episode validation data Dᵢᵛᵃˡ, where ᵛᵃˡ identifies the held-aside batch. The gradient ∇θ is taken with respect to the starting parameters because the adapted values depend on that start. The outer step thus rewards starting parameters for how well they let the learner use the support data.

Validation here has a particular meaning. The validation batch belongs to the source task of the current episode. Its loss supplies a training signal to the outer loop. Later, the paper also uses validation data to select settings, and test data to report performance on target tasks. Those operations have distinct roles. The outer update learns from repeated source episodes. Settings selection chooses how to run adaptation. Final evaluation scores the adapted classifier on target examples.

#### What goes into the text encoder

The shared encoder uses the BERT-base implementation of the [Transformer](https://md.research.elamur.ai/free/en/concepts/transformer/). Its input is a sequence, so the authors represent the different task formats in a compatible way. A task can classify a sentence, compare a pair of sentences, or identify a category for a phrase. For phrase classification, the authors put the containing sentence first, insert BERT’s separator token, and append the phrase. The complete input identifies both the span that needs a label and the context in which it occurred.

The restaurant corpus illustrates the reason for keeping both. A restaurant query can mention the kind of food the speaker wants and the area where they want to find it. The authors turn such a query into a separate classifier input for each labeled mention. For the cuisine example they append the words describing the food. For the location example they append the words referring to the area. The original query remains available to the encoder in both cases. The unit to be classified is a mention, even though the input contains a sentence.

The paper writes the shared encoder and its layers using the following notation.

```
θ = {θ₁, …, θ₁₂}
```

Here θ denotes the encoder parameters and θᵥ denotes the parameters of encoder layer v. The subscripts ₁ and ₁₂ mark the endpoints of the BERT-base layer sequence in this notation. The braces collect the layer parameter sets, and the ellipsis stands for the intervening layers. The paper also discusses separately whether to adapt the word embeddings used at the input.

BERT places a special classification token, [CLS], at the beginning of an input. The representation at that position depends on the rest of the sequence through the encoder. LEOPARD uses the final representation there as its fixed-width vector for the complete input.

```
x̃ⱼ = fθ([xⱼ₁, …, xⱼₜ])
```

The vector x̃ⱼ represents example j. The function fθ is the encoder with parameters θ, understood here to return the final [CLS] representation. The square brackets enclose the input sequence. Its element xⱼᵣ is at position r in example j, and t is the sequence length. The ellipsis covers the intervening positions. The encoder produces a contextual vector of dimension d, where d is the width of the representation used at this stage. The same width is available whether the sequence encodes a single sentence, a pair or a sentence with a selected phrase.

#### How label groups become weight vectors

For task Tᵢ, the first sampled training batch contains inputs and class labels. LEOPARD partitions it by label before running the averaging operation.

```
Cᵢₙ = {xⱼ | yⱼ = n}
```

The set Cᵢₙ contains the training inputs assigned to class n for task i. The symbol xⱼ denotes input j in the batch and yⱼ denotes its label. The vertical bar means that the condition to its right determines membership. The index n ranges over the Nᵢ classes used in task i. Each group used to generate a class must have examples, since the procedure will divide by its size.

Within a group, an example’s encoded vector is passed through a multilayer perceptron, a small network that applies learned transformations and nonlinearities. The generator uses two layers and tanh nonlinearities. A nonlinear transformation gives it a way to combine information from the encoder before producing quantities to average. The average yields one vector and one scalar for the entire class.

```
(wᵢₙ, bᵢₙ) = (1 / |Cᵢₙ|) ∑_{xⱼ ∈ Cᵢₙ} gψ(fθ(xⱼ))
```

The vector wᵢₙ contains the initial linear weights for class n in task i, and bᵢₙ is its initial scalar bias. The expression |Cᵢₙ| is the number of examples in the class group. The symbol ∑ adds the outputs across the inputs xⱼ belonging to that group, as indicated by ∈. The encoder fθ maps an input to its contextual representation using parameters θ. The generator gψ, with learned parameters ψ, maps that representation to the quantities averaged into wᵢₙ and bᵢₙ. The weight vector has dimension l, the width needed by the task’s linear classifier.

The order in which the examples enter the average has no effect on the generated parameters. What matters is which examples belong to the group and what features the generator extracts from them. The procedure shares the same generator across classes and tasks. The assembled classifier therefore depends on the content of the support batch and on the associations established by its labels.

The paper expresses the assembly of the classifier as follows.

```
Wᵢ = [wᵢ₁; …; wᵢₙᵢ],  bᵢ = [bᵢ₁; …; bᵢₙᵢ]
```

Here Wᵢ is the weight matrix and bᵢ is the bias vector for task i. The last class subscript, written here as ₙᵢ, denotes Nᵢ, the number of classes in that task. The brackets and row separators stack the individual class weight vectors w and the individual biases b in the same class order. The ellipses indicate the intervening classes. Wᵢ has Nᵢ rows of width l, and bᵢ has an entry for each of the Nᵢ classes. The use of a separate feature width and class count is what allows the same encoder and generator to serve classifiers of different sizes.

For a new input, the prediction computation uses another learned projection before applying the classifier.

```
p(y | x∗) = softmax(Wᵢ hφ(fθ(x∗)) + bᵢ)
```

The expression p(y | x∗) gives the probabilities over candidate labels y for the input x∗. The vertical bar indicates conditioning on that input. The function fθ gives its encoder representation, and hφ is the feature projection with parameters φ and output width l. Multiplication by Wᵢ gives a score for each class, and addition of bᵢ applies the class biases. The softmax converts the resulting scores into probabilities over the classes of task i.

The distinct projections have distinct jobs. The generator gψ looks at a labeled example to help produce the parameters for its class. The projection hφ looks at an input to produce the features on which those class parameters operate. In the paper’s comparison with prototypical networks, the classifier at its generated starting point already represents a learned comparison between a new example and the labeled classes. LEOPARD then makes class weights, biases and selected representation parameters available for task-specific updates.

#### What the inner and outer loops update

Updating every parameter during adaptation can be expensive. The paper describes BERT as having roughly 110 million parameters and considers adapting a subset. A threshold ν divides the encoder by depth. Layers near the input can remain fixed during the inner loop, while layers above the threshold can adapt. The generator is also held fixed within the inner adaptation. Its job in an episode is to supply the initial classifier from the first support batch.

```
θ≤ν = {θᵥ | v ≤ ν}
```

The symbol θ≤ν denotes the encoder parameters at or below the cutoff ν. The layer index is v, and θᵥ is the parameter set for that layer. The braces collect the layers satisfying the condition after the vertical bar. The paper writes θ>ν for the parameters above the threshold, with > indicating the higher-layer group.

```
Θ = θ≤ν ∪ {ψ}
```

In the description of the parameter split, Θ denotes the parameters held constant within an episode’s inner loop. The symbol ∪ combines the lower encoder layers θ≤ν with the generator parameters ψ. These parameters can still learn across episodes. In its training algorithm the paper also uses Θ for the broader collection of shared quantities governed by the outer optimization, including the encoder starting parameters and adaptation rates. The distinction is between the parameters updated within a task and the starting quantities optimized across tasks.

```
Φᵢ = θ>ν ∪ {φ, Wᵢ, bᵢ}
```

The symbol Φᵢ collects the parameters adapted for task i. It combines the upper encoder parameters θ>ν, the feature projection parameters φ, and the generated classifier weights Wᵢ and biases bᵢ. The braces group the projection and classifier parameters. The contents of Φᵢ begin from shared starting values for the applicable text-processing layers and from example-dependent starting values for the task’s classifier.

The authors use subsequent support batches for adaptation. A single batch could in principle supply the initial classifier and all of its early corrections, but the authors identify overfitting to that batch as a reason to sample training data again during meta-training. A later batch can expose a way in which the classifier built from the initial examples fails to generalize within the task. The loss on that batch then drives an inner update. The paper expresses that update using an expectation over sampled batches.

```
Φᵢ⁽ˢ⁺¹⁾ = Φᵢ⁽ˢ⁾ − αₛ E_{Dᵢᵗʳ ∼ Tᵢ}[∇Φ Lᵢ({Θ, Φᵢ⁽ˢ⁾}, Dᵢᵗʳ)]
```

Here s is the index of the inner step, Φᵢ⁽ˢ⁾ is the adaptable parameter set before the step, and Φᵢ⁽ˢ⁺¹⁾ is its updated value. The learning rate αₛ controls the size of the update, using the learned layer-specific rates for the relevant parameters. The expectation E is over training batches Dᵢᵗʳ sampled from task Tᵢ. The loss Lᵢ uses both the parameters Θ kept fixed within the episode and the current adaptable parameters. The operator ∇Φ differentiates the loss with respect to the adaptable part alone. The implementation samples a batch for each step and uses the gradient obtained from that batch. The paper denotes the number of steps by G, with s running from 0 through G − 1.

After the inner steps, the learner’s validation loss is evaluated using the adapted values. The outer objective changes the common starting parameters, including those that the inner loop can temporarily update. In the full differentiation of that objective, the dependence of the adapted parameters on their initialization passes through the inner gradient steps. This can require higher-order derivatives. The authors use a first-order approximation for computational efficiency. They also observe that restricting the set adapted in the inner loop could make higher-order calculations more practical.

LEOPARD learns rates by layer because different layers can benefit from changes of different sizes. The paper contrasts that choice with learning a rate for every individual parameter, which would add a corresponding set of learned quantities. It also adapts the parameters of [layer normalization](https://md.research.elamur.ai/free/en/papers/ba-2016-layer-normalization/) in the inner loop. The selected meta-training configuration uses 7 adaptation steps, a minimum adapted-layer setting of 0 and trainable input embeddings in the inner loop. The authors initialize the encoder with pretrained BERT-base to stabilize meta-training.

At the target task, the few-shot set supplies the examples from which to form the classifier and adapt it. The target test set supplies the evaluation. The reported fine-tuning schedules for LEOPARD are 150 epochs with 4 examples per label and 100 epochs with either 8 or 16. An epoch is a pass over the available training set, so these schedules describe repeated optimization on a small body of evidence. The paper makes code, trained parameters and datasets available with LEOPARD.

### Experiments and results

#### Supervised preparation and target evaluation

The source tasks come primarily from GLUE, with the Stanford Natural Language Inference dataset added. The paper names MNLI in its matched and mismatched forms, QNLI and RTE among the source tasks. It also names QQP, MRPC and SST-2. The added [Stanford Natural Language Inference dataset](https://md.research.elamur.ai/free/en/papers/bowman-2015-large-annotated-corpus-learning-natural/) contributes further inference supervision. The appendix’s training development results also list CoLA. The authors describe excluding WNLI because of its small training set and STS-B because it is a regression task, which calls for predicting a numerical value in place of a discrete class.

For episodic methods, the authors derive additional training tasks by taking each possible pair of labels from a source dataset that has more than 2 classes. A task derived this way asks the learner to distinguish the selected labels. This gives the meta-training procedure more choices of tasks and allows batches with more examples per label. It also means that part of the variety within meta-training comes from different views of the same source data. The evaluation on target datasets tests transfer beyond those constructed episodes.

To practice classifying a phrase using its context, the authors reshape examples from the [Stanford Sentiment Treebank](https://md.research.elamur.ai/free/en/papers/socher-2013-recursive-deep-models-semantic-compositionality/). They provide the sentence and the particular phrase in the same format used later for entity mentions. The prepared system thus has experience in attending to a chosen part of a sentence. The target entity labels still have to be learned from entity-typing examples. For sampling among the source tasks, the authors tried uniform probabilities, probabilities proportional to dataset size and probabilities proportional to its square root. They report that square-root weighting worked well across the trained systems. The training runs used 4 GPUs to support larger batches.

The target protocol makes k the number of labeled examples per class. The paper tests k at 4, 8 and 16. For each target and budget the authors sample 10 training sets. They adapt a classifier on each sample and run it on the entire target test set. Accuracy is the proportion of test predictions that match the dataset labels. The tables report the mean accuracy across the sampled training sets and its standard deviation. A high deviation indicates that different draws of the small training set lead to materially different test scores under that method.

There is also a separate question of how to choose adaptation settings. Tuning on a large labeled development set for each destination would give the learner more task-specific evidence than the few-shot training budget suggests. The authors therefore use SciTail and Amazon Electronics sentiment for selecting fine-tuning settings, choosing configurations by their average validation performance on those tasks at each budget. For the baselines they tune settings including the number of training iterations and batch size. For LEOPARD they select the fine-tuning duration and use the learned layer-specific rates and the remaining inherited settings. SciTail and Electronics sentiment also appear in the reported domain-transfer results, so their role in settings selection matters when interpreting those rows.

#### What the baselines test

BERT-base starts from the cased pretrained encoder and fine-tunes it directly on the target examples. The authors update all its parameters during fine-tuning because that variant performed better in their validation comparisons. The experiment asks how far ordinary language pretraining and target adaptation can go without source-task supervised training.

MT-BERT starts with the same pretrained encoder and receives supervised multitask training on the source tasks. When it reaches a new target, it fine-tunes the encoder as well as the target classifier. MT-BERTsoftmax starts from the same multitask preparation and updates just the target softmax layer. The pair helps distinguish transfer through a reusable representation from transfer that benefits from changing the representation for the destination. The paper compares its multitask setup with [MT-DNN](https://md.research.elamur.ai/free/en/papers/liu-2019-multi-task-deep-neural-networks/) and explains that it omits that work’s specialized answer network for inference.

Proto-BERT uses a pretrained BERT-base encoder and learns to form class prototypes in an episodic setting. It compares representations by Euclidean distance. This baseline can handle targets with different label counts because its class representations come from the support set. It tests a different use of episodic preparation, where prediction relies on the metric and the prototypes. LEOPARD adds gradient adaptation to its example-dependent classifier and learns a different relationship between the examples and the class scores.

For domain transfer the authors add MT-BERTreuse. When a source task has a classifier suited to the destination’s kind of prediction, this baseline starts target fine-tuning from those trained classification parameters. The comparison matters because a familiar task may already have a useful decision layer, even when the destination’s text comes from a new domain. The baseline has a natural role for entailment and sentiment. The main variable-label evaluation uses an output layer appropriate to the target because a related trained classifier is unavailable as a general solution.

#### Generalization to different tasks

One part of the evaluation focuses on targets the authors treat as new tasks. Entity typing uses [CoNLL-2003](https://md.research.elamur.ai/free/en/papers/sang-2003-introduction-conll-2003-shared-task/) news text and MIT-Restaurant queries. The appendix lists 4 labels for CoNLL and 8 for MIT-Restaurant. Each labeled mention becomes a prediction example. The test-set sizes reported for these tasks are 5648 examples for CoNLL and 2591 for MIT-Restaurant. This gives the study an entity-level target in both news and query text.

The paper also constructs rating-prediction targets from [Amazon Reviews](https://md.research.elamur.ai/free/en/papers/blitzer-2007-biographies-bollywood-boom-boxes-blenders/). It uses 3 classes defined by ratings of at most 2, ratings equal to 4, and ratings equal to 5. These are rating targets in the Books, DVD, Electronics and Kitchen domains. Their labels come from the recorded rating. The domain-transfer experiments later use sentiment annotations, a separate prediction target even when the product domain has the same name.

The social-media datasets ask about airline sentiment, disaster references, emotional content and attributes of political messages. The political evaluations distinguish bias, audience and message as separate destinations. The appendix lists 13 labels for the Emotion task and 9 for Political Message, while Political Audience and Disaster each use 2. The authors balance the severely imbalanced Political Bias and Political Audience datasets because their adaptation samples are balanced by class. That changes the evaluation setting for those datasets, since the reported behavior is measured on the paper’s balanced versions.

Across the unseen-task group, LEOPARD has the highest average test accuracy at each budget. At 4 examples per label its mean is 45.99%. The strongest baseline average at that budget is 40.13%, from adapting just the classification layer of multitask BERT. The comparison against bare BERT-base also shows that supervised preparation matters to the results, with gains available from multitask training as well as from meta-training.

Mean test accuracy across unseen tasks with 4 examples per label LEOPARD leads the average while the multi-task variants also improve on direct BERT adaptation.

**The numbers**

| System or setting | accuracy % |
| --- | --- |
| BERT-base | 38.13 |
| MT-BERTsoftmax | 40.13 |
| MT-BERT | 40.10 |
| Proto-BERT | 36.29 |
| LEOPARD (this paper) | 45.99 |

At 8 examples per label, LEOPARD averages 50.86% test accuracy on those targets, and MT-BERTsoftmax, again the strongest baseline average, reaches 45.89%. At 16 examples per label, the corresponding averages are 55.50% and 49.93%. The paper reports relative gains of 14.60%, 10.83% and 11.16% for the three budgets. These are relative accuracy improvements. The average accuracies and the relative gains describe different quantities, and both depend on the task group over which the comparison is made.

Individual datasets illustrate why the average is only part of the story. On Amazon Books rating prediction at 4 examples per label, LEOPARD reaches 54.92% mean test accuracy. Proto-BERT, the highest baseline mean in that row, reaches 48.44%. The corresponding standard deviations are 6.18 and 7.43. At the same budget for Political Bias, LEOPARD has a mean accuracy of 60.49% and a standard deviation of 6.66, while Proto-BERT has a mean of 56.33% and a standard deviation of 4.37. These comparisons show gains on both a review-derived rating task and a social-media classification task, with meaningful variation across draws of training data.

There are also targets on which the pretrained starting point is more effective. On Disaster classification with 16 examples per label, BERT-base reaches 64.52% mean test accuracy, while LEOPARD reaches 61.32%. MT-BERTsoftmax reaches 65.83%. The authors identify this dataset as a case where supervised transfer can be unfavorable. The precise comparison depends on which supervised preparation and fine-tuning procedure are used. Some transfer choices help on average yet produce a weaker result than direct BERT adaptation on this task.

Political Message illustrates sensitivity to the data budget. LEOPARD reaches 18.02% mean test accuracy at 8 examples per label, while the best baseline mean in that row is Proto-BERT’s 15.67%. With 16 examples per label, BERT-base reaches 20.67% and LEOPARD reaches 18.07%. Emotion also remains difficult in absolute terms. With 4 examples per label the reported LEOPARD mean is 11.71% test accuracy, even though it leads the comparison at that budget. The same preparation can confer a relative advantage and leave a large share of the decisions unresolved.

Across this target group, the frozen-encoder variant of the multitask baseline does slightly better on average than updating the whole network. This suggests that the source training provides features worth preserving under a small target budget. Proto-BERT has a lower average than the multitask fine-tuning systems. The authors propose that it has difficulty constructing useful prototypes for a substantially different target and that refining the class representations may matter. The aggregate comparison supports examining that explanation, while the classifier-initialization and layer ablations provide more direct evidence about parts of LEOPARD itself.

#### Domain transfer for sentiment and entailment

The domain-transfer evaluation keeps the type of decision more familiar. In the Amazon experiments, the training experience relevant to sentiment comes from the phrase-level SST setup, while the destination requires a sentiment judgment at sentence level. The authors evaluate Books, DVD, Electronics and Kitchen & Housewares. In SciTail, a learner trained with several source inference datasets encounters textual entailment derived from science questions. The appendix lists 2 classes and 2,126 test examples for SciTail.

On Amazon Books sentiment with 4 examples per label, LEOPARD reaches 82.54% mean test accuracy. MT-BERTreuse reaches 74.79% and Proto-BERT reaches 73.15% under the same condition. LEOPARD’s standard deviation is 1.33, compared with 6.91 for MT-BERTreuse and 5.85 for Proto-BERT. The Books sentiment comparison is therefore a case where high average accuracy accompanies relatively little variation across sampled training sets.

Amazon Books sentiment test accuracy with 4 examples per label The classifier generated and adapted by LEOPARD leads the compared transfer methods.

**The numbers**

| System or setting | accuracy % |
| --- | --- |
| BERT-base | 54.81 |
| MT-BERTsoftmax | 68.69 |
| MT-BERT | 64.93 |
| MT-BERTreuse | 74.79 |
| Proto-BERT | 73.15 |
| LEOPARD (this paper) | 82.54 |

The supplementary results show LEOPARD ahead in the other Amazon sentiment domains as well. On DVD sentiment it records 80.32% mean test accuracy with 4 examples per label and 81.25% with 16. In Electronics, the corresponding values are 74.88% and 81.86%. The Electronics result at the smaller budget has a standard deviation of 16.59. On Kitchen sentiment, LEOPARD’s test mean is 78.35% with 4 examples per label and a standard deviation of 18.36. With 16 examples per label the mean is 85.27% and the standard deviation is 01.31. The low-budget outcomes for Electronics and Kitchen make it especially important to distinguish a strong mean from dependable performance on an individual draw.

SciTail has a different ordering. At 4 examples per label, MT-BERTreuse reports 76.65% mean test accuracy and LEOPARD reports 69.50%. At 8 examples per label, MT-BERTsoftmax has the highest reported mean at 79.11%, while LEOPARD reaches 75.00%. At 16 examples per label, the frozen-encoder variant reaches 79.60%, and LEOPARD reaches 77.03%. The authors suggest that training on multiple related inference datasets can make the representations from multitask training particularly useful on SciTail. Reusing a trained classifier also gives the multitask system access to prior supervision about the destination’s familiar type of decision.

SciTail entailment test accuracy with 4 examples per label Reusing a trained classifier gives the highest mean in this scientific entailment comparison.

**The numbers**

| System or setting | accuracy % |
| --- | --- |
| BERT-base | 58.53 |
| MT-BERTsoftmax | 74.35 |
| MT-BERT | 63.97 |
| MT-BERTreuse | 76.65 |
| Proto-BERT | 76.27 |
| LEOPARD (this paper) | 69.50 |

Proto-BERT is more competitive in these domain comparisons than it is on the group of different tasks. On SciTail its mean test accuracy at 4 examples per label is 76.27%. The authors connect this behavior to the ability to form prototypes for a kind of task the system has already encountered during training. Both the prototype comparison and the reuse baseline suggest that the relevance of source supervision can change what a learner needs to do with its few target examples.

### What the ablations show

#### Giving the classifier a starting point

The authors first ask whether the class generator contributes something that gradient adaptation alone would fail to recover from a small sample. They train LEOPARD-ZERO, a variant that initializes a classification layer of the correct size with zero weights and biases. The rest of its training follows the LEOPARD approach. It can still establish a separate output for each label and learn from the support data. At initialization all class scores are equal, so the first prediction gives each label the same probability. The learner starts to differentiate classes through its gradient steps.

The comparison is particularly clear on the CoNLL-2003 entity-typing development evaluation. At 16 examples per label, LEOPARD reaches 69.00% mean accuracy and LEOPARD-ZERO reaches 44.79%. Their reported standard deviations are 4.76 and 9.34, respectively. Generating a separate starting vector and bias from each labeled group therefore has a sizable effect in this setting. A classifier of the right shape plus a meta-trained encoder gives the zero variant the mechanics of adapting to the task, but it performs substantially worse under this initialization.

The DVD sentiment development comparison at the same budget gives 76.65% for LEOPARD and 74.45% for LEOPARD-ZERO. On the SciTail development comparison, the respective means are 76.10% and 74.36%. The difference between the means is much less pronounced on these familiar task types than on entity typing. The study thus shows the greatest benefit from the generator in the reported case where the learner has to form a substantially different kind of class decision. The variant serves as a simple variable-output adaptation of the MAML idea, so the result addresses this particular way of starting such a classifier.

The initialization test also clarifies how to read the prototype comparison. The zero variant retains adaptation and removes the learned, example-conditioned start. Proto-BERT retains class representations built from examples and uses a metric-based prediction procedure. These comparisons address different features. Their results fit the paper’s case for joining example-conditioned initialization with adaptation. They leave room for differences in the metric, the encoder updates and the optimization procedure to contribute as well.

#### Deciding which layers to adapt

The layer ablation varies how much of the encoder can change within an episode and during target fine-tuning. The more restrictive versions freeze layers 0 through 5 or 0 through 10 in the inner loop, including the input embeddings. The outer loop can still optimize those layers across the source episodes. The intervention therefore concerns the extent to which the parameters specialize for the current task on the strength of its few labels.

At 16 examples per label in the CoNLL development evaluation, adapting all layers reaches 69.00% mean accuracy. Freezing through layer 5 gives 62.49%, and freezing through layer 10 gives 37.62%. On DVD sentiment development data, the same settings reach 76.65%, 71.50% and 58.10%, respectively. In these comparisons, restricting adaptation substantially can cost more than it saves in terms of the flexibility of the classifier. A layer may be useful across tasks and still need to change for an individual destination.

SciTail has a different pattern. On its development evaluation at 16 examples per label, freezing through layer 10 reaches 78.53%, adapting all layers reaches 76.10%, and freezing through layer 5 reaches 73.27%. The most restrictive tested setting leads this comparison. The intermediate setting is weaker than both ends, so the scores provide evidence for a particular restricted setting on this dataset instead of a steady improvement as more layers are held fixed.

The authors suggest that full adaptation can work well partly because the learned layer-specific rates already let some layers move less than others. On SciTail, they suggest that earlier training on several inference datasets gives the system a starting representation worth preserving. Both are interpretations of the observed rankings. The ablation changes the available layer updates and measures performance, leaving the precise source of the differences open.

For these development-set studies the appendix describes reserving 20% of target training data for early stopping and drawing the few-shot support sets from the remaining 80%. Early stopping selects where to end a training run using validation performance. The development results answer questions about component choices under that ablation procedure. The full test results in the main evaluation answer the separate question of how the chosen methods generalize under the target evaluation protocol.

#### Removing source tasks one at a time

The authors also ask whether the choice of supervised source tasks affects LEOPARD and MT-BERT in the same way. For each comparison, they remove a source task, retrain each method with the remaining tasks and then evaluate target adaptation on development data. The figures express each change relative to that method’s run trained with the full source collection. The rows are target tasks and the columns identify which source task was removed.

LEOPARD is generally more consistent than MT-BERT as the source collection changes. Dropping a source task often hurts LEOPARD, and the authors suggest that a smaller collection can make it easier for meta-training to specialize too closely to the remaining source-task distribution. MT-BERT’s target performance varies more with the source omission. An omitted task can matter differently to each destination, so the analysis is about sensitivity to source composition as well as whether the average moves up or down.

The supplementary figures compare the pattern at different target label budgets. The paper observes that the effect of omitting a source task decreases as k increases. More target labels give adaptation a larger body of direct evidence about the destination’s classes. The plots are consistent with that explanation. Each removal simultaneously changes the source-task mix and removes access to the corresponding training examples, so its effect represents the value of that source within the particular collection used in the experiment.

### Limitations

#### Limits described by the authors

The authors end by emphasizing the gap between the observed few-shot results and the human ability that motivates the work. Learning a more useful initialization improves accuracy in their experiments, while performance with so little supervision still falls short of what they describe as human-level ability. The conclusion treats broad linguistic intelligence as a longer-term objective. The evaluation itself is a study of adaptation to supervised classification tasks.

The task format is central to the scope. LEOPARD constructs one classifier row per class from examples with that label. The authors concentrate on inputs that can be encoded as sequences and outputs that are choices among classes. Within that scope, the experiments span single-text judgments, phrase typing and sentence-pair judgments. A task asking for a continuous value or a generated passage presents a different output problem. The paper’s architecture and results establish behavior for the classification workflow it evaluates.

The authors also identify an obstacle to comparing directly with standard MAML. The standard shared classifier does not readily cover the varying output sizes in this study. They test the zero-initialized alternative as a straightforward way to give an optimization-based learner the right output size. That experiment supports their generator over this baseline. A wider comparison of possible variable-output initializers would be needed to make a claim about optimization-based meta-learning in general.

The paper distinguishes optimization-based adaptation from prediction using fixed prototypes, and it notes the potential for gradient methods to make use of additional data. Its measured comparison concerns the specified few-shot budgets. The argument that gradient adaptation can keep benefiting from additional examples describes the flexibility of the approach. The experiment does not trace how the systems approach the performance of a classifier trained with full target supervision.

#### Limits visible in the evaluation design

A target described as new can still resemble a source task in meaningful ways. Entity typing has unfamiliar labels, but the source preparation includes a phrase-with-context input format derived from sentiment supervision. Social-media emotion or airline sentiment can draw on information learned from earlier sentiment examples even when their labels and domain differ. Such overlap is part of what makes transfer possible. The evaluation establishes transfer to held-out classification tasks drawn from this collection. It leaves the distance between source and target as a property of the examples, labels and formats, without a separate measure that isolates each of those dimensions.

The few-shot budget constrains the support set for adaptation. It does not describe the learner’s total access to supervision over the course of the study. The encoder has undergone pretraining, the supervised source datasets can be large, and the meta-learning procedure draws multiple batches in an episode. At test time, the sampling procedure allocates the specified number of labeled examples to every class. This lets the generator form a row for each class and ensures that rare classes are represented in the support. A practical setting in which some classes receive no examples, or in which the learner has to discover the label inventory from partially labeled data, would require evidence beyond these results.

Settings selection narrows the interpretation of some of the reported domain comparisons. The authors use SciTail and Electronics sentiment validation data to choose fine-tuning settings, and they also report test results for both datasets. Their labeled test examples are separate from that selection. Nevertheless, the selection process has already used validation evidence from those target domains. This matters when the intended claim is that a single adaptation procedure transfers to a destination for which no labeled validation information has been consulted.

The reported standard deviations quantify variation across sampled support sets. That is an important source of uncertainty, especially in the sentiment domains where the deviations at the smallest budget can be large. A mean and standard deviation across those draws do not say which classes account for the errors or what will happen on a particular draw. Nor does the overall average guarantee that a learner will improve on every task. Disaster and SciTail give concrete cases where another preparation has a stronger mean under some conditions.

Accuracy gives an interpretable comparison within the supplied test sets, but it pools correct predictions across the available examples. The balancing of Political Bias and Political Audience means that those results concern evaluation sets adjusted to align more closely with the balanced support procedure. For the full set of targets, differences in label count, dataset construction and difficulty affect what a given level of accuracy represents. The paper answers whether the transfer procedures perform better on the specified tests. Per-class behavior and performance under the original label frequencies of the balanced datasets remain separate questions.

Finally, the reported configuration learns rates by layer and can still adapt the whole encoder. The parameter-efficient variants show how performance changes when fewer layers are updated. The study gives the corresponding accuracy evidence, with no comparative time or memory measurements for those variants. Fewer inner-loop parameters is a narrower claim than a demonstrated speed or resource advantage. The evidence for the layer cutoff is strongest as a description of an adaptation choice whose value depends on the target.

### What came after

The later citations place the paper in several lines of research on learning from few examples and preparing a system for transfer. The clearest continuation at the level of evaluation is [CrossFit](https://md.research.elamur.ai/free/en/papers/ye-2021-crossfit-few-shot-learning-challenge/) (2021). It frames few-shot generalization across language tasks as a challenge in its own right. The connection is the unit of transfer. LEOPARD asks what happens when a learner moves to a different task with a small labeled support set. CrossFit likewise puts generalization across tasks at the center of the evaluation question. Its contribution as described by its title is the challenge design. That citation alone leaves the use of LEOPARD’s classifier generator unspecified.

[Making Pre-trained Language Models Better Few-shot Learners](https://md.research.elamur.ai/free/en/papers/gao-2021-making-pre-trained-language-models/) (2021) takes up the broader objective of improving how pretrained systems learn from limited supervision. For the earlier paper, pretraining supplies the starting encoder and supervised episodes are used to prepare its later adaptation. The shared question is how to turn the benefits of prior training into reliable performance with few examples. The later work’s title establishes that objective. It leaves the exact role played by LEOPARD’s training objective or classifier initializer unspecified.

[Parameter-efficient Multi-task Fine-tuning](https://md.research.elamur.ai/free/en/papers/mahabadi-2021-parameter-efficient-multi-task-fine/) (2021) is related through the design of adaptation parameters. It studies parameter-efficient multitask fine-tuning for Transformers through shared hypernetworks. In LEOPARD, a shared function produces the initial parameters of a classifier, and the layer analysis studies which other parameters should adapt. The later work’s title puts shared parameter generation in a multitask fine-tuning setting. This is a connection between the design questions raised by the two papers, while the citation does not establish that they generate the same parameters from the same inputs.

[Masked Language Modeling and the Distributional Hypothesis](https://md.research.elamur.ai/free/en/papers/sinha-2021-masked-language-modeling-distributional-hypothesis/) (2021) examines word order in pretraining. It connects to an earlier stage of the LEOPARD pipeline. The encoder brings representations acquired in pretraining into the supervised adaptation procedure, and the paper’s BERT baseline measures what that starting point can support in the few-shot setup. Studying the contribution of word order to pretraining asks how properties of that starting representation arise. It addresses a different part of the path from pretraining to transfer, and the citation leaves open how the later study used the LEOPARD results.

[Joint Prompt Optimization of Stacked LLMs](https://md.research.elamur.ai/free/en/papers/sordoni-2023-joint-prompt-optimization-stacked-llms/) (2023) names another place where optimization can act. Its title describes joint prompt optimization using variational inference. LEOPARD’s trainable quantities include the initialization, the class generator and the rates governing gradient updates. The later title puts the optimization emphasis on prompts in a stack. Both works concern choices that shape a system’s behavior for a task, with their stated methods operating on different quantities. The available citation relationship leaves direct algorithmic inheritance unspecified.

[A Systematic Survey of Automatic Prompt Optimization Techniques](https://md.research.elamur.ai/free/en/papers/ramnath-2025-systematic-survey-automatic-prompt-optimization/) (2025) is a survey of that later research area. Its citation places the LEOPARD paper among the works considered in a discussion of automatic optimization for task performance. The survey’s stated scope establishes the context for the citation. It does not by itself say whether the survey uses LEOPARD as historical background, as a comparison for few-shot adaptation or for a more specific methodological connection.

## Cite

Cite as Trapit Bansal, Rishikesh Jha and Andrew McCallum. 2020. Learning to Few-Shot Learn Across Diverse Natural Language Classification Tasks. Proceedings of the 28th International Conference on Computational Linguistics.

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.18653/v1/2020.coling-main.448](https://doi.org/10.18653/v1/2020.coling-main.448)

```bibtex
@inproceedings{bansal2020learning,
  title = {{Learning to Few-Shot Learn Across Diverse Natural Language Classification Tasks}},
  author = {Trapit Bansal, Rishikesh Jha and Andrew McCallum},
  booktitle = {Proceedings of the 28th International Conference on Computational Linguistics},
  year = {2020},
  doi = {10.18653/v1/2020.coling-main.448},
  url = {https://doi.org/10.18653/v1/2020.coling-main.448}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
