# PADA: Example-based Prompt Learning for on-the-fly Adaptation to Unseen Domains

PADA adapts NLP models to unseen domains by generating a prompt per example

Eyal Ben-David, Nadav Oved, Roi Reichart · arXiv · 2021-2-24

- **Problem** Existing adaptation methods need target-domain data or a separate model per domain, so they fit unseen target domains poorly.
- **Method** PADA trains one T5 model to write a short prompt for each test example from source-domain features, then labels the example conditioned on that prompt.
- **Results** PADA averaged 69.3 binary-F1 on Rumour Detection, against 65.8 for T5-NoDA.

## Why unseen-domain adaptation is hard

Domain adaptation tries to keep NLP models accurate when test text comes from a different distribution than the training text. Target-aware algorithms typically need a separate model for each target domain, which makes the overall solution inefficient. Unsupervised DA models assume access to unlabeled data from the target domain during training.

The authors see this as a slight relaxation of the goal of generalization beyond the training distribution.

Multi-source methods often fuse models from several sources, with Mixture of Experts (MoE) weighting the experts by their relation to the target example. MoE requires a standalone expert for each source domain, so the total number of parameters typically grows linearly with the number of source domains. Domain experts also become tuned to domain-specific knowledge, sometimes at the expense of cross-domain knowledge.

The authors' results indicate that this heuristic combination is sub-optimal. So the authors train only a single model that shares its parameters across all domains, without information about target domains at training time.

Pivot features are an earlier route to adaptation, and they fit tasks where words correlate with the label. Good pivots are ones correlated with the task label, such as in sentiment classification. For MNLI, the label depends on the relation between a pair of sentences, so single words rarely correlate with the label. Pivots are also typically applied in single source setups, which the authors' multi-source method goes beyond.

Some prior works, such as Wright and Augenstein (2020), avoid utilizing target data and serve as two of the baselines.

## Key idea: a per-example prompt drawn from source-domain features

PADA lets T5 write a short prompt for each test example, built from features tied to the source domains. That prompt acts as a signature that places the example in a semantic space spanned by those source domains. The authors expected this to work because domains share meanings, so their DRF sets can overlap and one set of parameters can serve several domains.

The authors define DRFs as words with strong ties to one source domain, which lets them describe that domain's meaning. Extraction scores each unigram by mutual information with a binary label that marks whether a text comes from the domain or from the other sources. Mutual information can favor words tied to the other domains, so the authors keep a token only if its count in the other sources, divided by its count in the domain, stays at or below ρ, and its count in the domain is positive.

\\\[ \\frac{C\_{S\\setminus S\_j}(n)}{C\_{S\_j}(n)} \\le \\rho, \\quad C\_{S\_j}(n) \> 0 \\\] The authors set ℓ to 1000 and ρ to 1.5 for all domains.

![Table 2: A sample of DRFs extracted for the Fer- guson domain (rumour detection) with different ρ values. Each column represents DRFs which are ﬁltered in DRF…](https://refivu.com/papers/1c1edf58-9646-4fc9-9631-5ddd3c11e749/figures/figure-2b02a6021bc4d71fe99b3d61c72194e6.png?thumb=512)

**Table 2** : A sample of DRFs extracted for the Fer- guson domain (rumour detection) with different ρ values. Each column represents DRFs which are ﬁltered in DRF sets of lower ρ value. DRFs of lowerρ values are more domain speciﬁc.

[Original paper](https://arxiv.org/abs/2102.12206v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

Each training example gets its own prompt, made of the m = 5 DRFs of its domain that sit closest to it. Closeness is the Euclidean distance between T5 embeddings of each DRF and of each token in the example, using the non-contextual embeddings from T5 pre-training. Because each example gets a different selection, every training example has its own prompt, which maps it to the semantic space of its domain.

## How training and inference run in two steps

PADA trains one T5 model on two kinds of examples, a generative one and a discriminative one. A generative example starts with the special prompt 'Domain:', and the model writes the domain name Ni followed by the DRF signature Ri. A discriminative example receives the domain name and DRFs, Ni and Ri, as its prompt and must predict the label yi.

Each training example becomes a generative example with probability α and a discriminative one with probability 1 − α. A larger α means the model trains more on the generative task.

The authors tuned α over 0.1, 0.25, 0.5, 0.75 and 0.9. They chose 0.75 for Rumour Detection and 0.1 for both MNLI and Aspect Prediction. With α at 0.75, the rumour model leaned toward prompt generation during training. Sharing parameters across both tasks separates PADA from PADA-NM, whose two models are trained independently.

At test time the domain is unknown, so the model first generates a domain name and DRFs for the example. For an airlines review, the model generated restaurants as the domain name. It then generated the words food and chair, and predicted a negative sentiment from that prompt. Figure 1 shows the same flow, with the domain name generated first and the label predicted last.

The model's parameters aren't updated when a new domain appears, so only the generated prompt changes from one example to the next.

![Figure 1: Text classiﬁcation with PADA. Colored texts signify relation to a speciﬁc source domain. PADA ﬁrst generates the domain name, followed by a set of DR…](https://refivu.com/papers/1c1edf58-9646-4fc9-9631-5ddd3c11e749/figures/figure-b03cdb49db7e7a4eff14c5dca6351f28.png?thumb=512)

**Figure 1** : Text classiﬁcation with PADA. Colored texts signify relation to a speciﬁc source domain. PADA ﬁrst generates the domain name, followed by a set of DRFs related to the input example. Then it uses the prompt to predict the task label.

[Original paper](https://arxiv.org/abs/2102.12206v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Eyal Ben-David, Nadav Oved, Roi Reichart · PADA: Example-based Prompt Learning for on-the-fly Adaptation to Unseen Domains · Original paper figure · Extracted the figure area from page 1 of the original PDF.

For Aspect Prediction, the model casts sequence tagging as text generation. It writes a B, I or O token for each input token. Text classification trains for 5 epochs and sequence tagging for 60 epochs. Early stopping uses performance on the development data.

## Three tasks, leave-one-out splits and metrics

PADA is evaluated on three multi-source tasks, giving 14 domain adaptation setups in total. The experiments are run leave-one-out: the model trains on all domains but one, and the held-out domain serves as the target.

The PHEME rumour dataset contains 5,802 tweets from 5 real-world events, and the authors treat each event as one domain. The five rumour domains are Charlie-Hebdo (C), Ferguson (FR), Germanwings-crash (GW), Ottawa-shooting (OS), and Sydney-siege (S). Each event corpus is split 4:1 into training and development sets, following the procedure of Wright and Augenstein (2020).

Because the corpora are small, the authors include all examples from the target domain in the test set. Rumour Detection is scored with binary-F1, the F1 score of the positive class.

The MNLI corpus extends SNLI, and each example pairs a premise with a hypothesis. The authors use the five matched domains: Fiction (F), Government (G), Slate (SL), Telephone (TL) and Travel (TR). The MNLI test sets are not public, so the original development sets serve as test sets for each target domain. Each training set is randomly downsampled by a factor of 30, leaving 2,000 to 3,000 examples per set.

MNLI is scored with macro-F1.

Aspect Prediction is built from ABSA corpora across four domains: Device (D), Laptops (L), Restaurant (R), and Service (SE). The authors follow the training and test splits of Gong et al. (2020) for D and SE, and take L and R from SemEval-2014. A development set is made by randomly sampling 10% of the training data. Aspect Prediction is scored by binary-F1 on the aspect class.

## Main results against T5 and MoE baselines

On Rumour Detection PADA averaged 69.3, compared to 65.8 for T5-NoDA and 62.4 for Tr-MoE. PADA beat all baselines in 7 of 10 text classification settings, and reached the top result in one more setting, where T5-NoDA was best. The average gains over the best baseline were 3.5% for Rumour Detection and 1.3% for MNLI, as the authors report.

The authors highlight that T5-NoDA, which does no domain adaptation, beats the other baselines, MoE included, on average.

![Table 5: Binary-F1 scores for the Rumour Detection task and macro-F1 scores for the MNLI task](https://refivu.com/papers/1c1edf58-9646-4fc9-9631-5ddd3c11e749/figures/figure-f73bcb7d6af20596c601a59341295e67.png?thumb=512)

**Table 5** : Binary-F1 scores for the Rumour Detection task and macro-F1 scores for the MNLI task.

[Original paper](https://arxiv.org/abs/2102.12206v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

The authors use T5-UB, tested on each domain's development data, as an upper bound, at 82.8% for Rumour Detection and 80.8% for MNLI. T5-NoDA reaches 65.8% on Rumour Detection and 78.3% on MNLI, which leaves a gap that PADA narrows. Measured against that gap, PADA reduces the error rate by 21% on Rumour Detection and by 52% on MNLI. The authors call these improvements substantial in both tasks.

PADA scales differently from Tr-MoE, which trains five DistilBERT models and therefore 5 × 66M = 330M parameters in total.

On Aspect Prediction PADA averaged 47.5 binary-F1, compared to 42.7 for T5-IRM, the second-best model. PADA was the best model in all four setups compared to its baselines. Given T5-UB at 69.4% and T5-NoDA at 38.7% on this task, the authors compute a 24% error reduction.

## What the ablations isolate

The ablations split PADA into simpler variants, each changing one design element at a time. Prompt-DN gives only a domain name as the prompt, and the model is run once per training domain name at test time. Prompt-RDW and Prompt-REW fill the prompt with five random domain words or five random words from the example. PADA-NP generates the domain name and DRF prompt together and predicts the label without conditioning on the prompt.

PADA-NM is a pipeline of two independent models, one for prompt generation and one for prompted prediction, with no shared parameters. Figure 3 shows the two multi-task ablation designs side by side.

![Figure 3: PADA ablation models: (a) PADA-NP, which follows a multi-task training protocol, but does not condition its prediction on the generated prompt; (b) P…](https://refivu.com/papers/1c1edf58-9646-4fc9-9631-5ddd3c11e749/figures/figure-d6541dcc77069e7adab8bfb3830b8564.png?thumb=512)

**Figure 3** : PADA ablation models: (a) PADA-NP, which follows a multi-task training protocol, but does not condition its prediction on the generated prompt; (b) PADA-NM, which separately trains a prompt generation model (→) and a prompted task prediction model (→).

[Original paper](https://arxiv.org/abs/2102.12206v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

PADA beats all its variants in 6 of 10 text classification settings. On Aspect Prediction, PADA beats Prompt-DN, Prompt-REW and PADA-NP in all four setups. It beats Prompt-RDW and PADA-NM in three of four setups on the same task. The authors read these gaps as support for three choices: DRFs in the prompt, a classifier that depends on the generated prompt, and joint training of both tasks.

They didn't test the ablations on a sequence tagging task with a different prompt length.

Prompt-DN averaged 35.9 on Aspect Prediction, compared to 47.5 for PADA. The authors take this weakness as another sign that the DRFs in the generated prompt matter.

## What the generated prompts contain

The authors compare generated prompts with annotated prompts on the development sets of the rumour detection task. Two families of automatic metrics are used: ROUGE for n-gram overlap and BERTScore for semantic similarity. BERTScore averages 0.94, while ROUGE-1, ROUGE-2 and ROUGE-L average 0.64, 0.30 and 0.61. A high BERTScore alongside lower n-gram overlap suggests the model matches meaning rather than exact words.

A generated DRF can differ in wording from the annotated one, for example gunman in place of terrorist, and still fit the meaning.

Most generated tokens come from the source DRF sets, at 92.7% on development sets and 75.3% on test sets. On unseen target test sets, tokens absent from both the source DRF sets and the input, labelled Novel, rise to 18.9% from 5.4% on development sets. Tokens from the input text also rise, to 14.1% from 11.7%. On an unknown domain, the prompt therefore leans more on new words and on the example itself.

Test prompts draw on several domains: 95% of them include DRFs from more than two source domains. Development prompts mostly use DRFs from only the correct source domain. The authors read this as PADA combining its source domains rather than copying one of them. Together with the examples in Table 1, this supports the claim that PADA integrates both the source domains and the input's semantics.

![Figure 5: Average ratios of number of domains in generated prompts, calculated over all develop- ment and test sets in the rumour detection task](https://refivu.com/papers/1c1edf58-9646-4fc9-9631-5ddd3c11e749/figures/figure-885f9246d477e22a5a9dc085fb9ecbbe.png?thumb=512)

**Figure 5** : Average ratios of number of domains in generated prompts, calculated over all develop- ment and test sets in the rumour detection task.

[Original paper](https://arxiv.org/abs/2102.12206v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

## Effect of source-domain count and transfer gap

PADA's F1 scores rise as the number of source domains grows, which the authors read as evidence for their central claim. The authors plot F1 against the number of source domains for PADA, T5-NoDA and T5-MoE on the rumour detection dataset. They report results on two target domains and an average over all five target domains. For the baselines T5-NoDA and T5-MoE, adding source domains can sometimes hurt generalization to unknown target domains.

The authors say PADA learns a meaningful domain mixture and uses it when it meets an example from a new domain. Their hypothesis is that a domain adaptation model benefits from combined knowledge of several source domains, and PADA follows it while T5-MoE and T5-NoDA fall short.

The authors also measure the drop from source to target performance, which indicates how stable a model is across domains. They compute in-domain F1 on all development examples from the source domains and out-of-domain F1 on the target test set. Figure 7 is a heatmap of these drops, and it reports the best performing models from the experiments.

T5-NoDA, which is not a domain adaptation model, has the largest average absolute drop at 17%. PADA's average absolute drop is 8.7%, so its gap to the target is much smaller. The authors treat this stability as desirable because future target domains are unknown, so a small gap makes transfer easier to predict.

The discussion states the broader result: PADA gives one unified model rather than one model per source domain. Its parameter count does not grow with the number of source or target domains. The authors also note that PADA's prompt generation is limited by the source domains it is trained on.

## Constraints on prompts and untested settings

PADA's prompt generation is bounded by the source domains it was trained on. Target domains semantically unrelated to every source domain may therefore receive weaker DRFs. The authors let PADA produce non-DRF words as a partial remedy for this limit. Their prompt training never optimizes the downstream prediction objective directly. The authors suggest this gap may also produce sub-optimally generated prompts.

The experiments cover 14 multi-source adaptation setups across three tasks, and PADA builds on T5. The Tr-MoE baseline trains DistilBERT experts, so it doesn't share PADA's T5 base model. T5-NoDA uses a pre-trained T5 with the same task classifier as PADA, trained on all source domains.

MNLI test labels aren't publicly available, so the authors can't score on the official test sets. Instead, the original development sets serve as the test sets for each target domain. Source domains use those same development sets for development. The authors randomly downsample each MNLI training set by a factor of 30, leaving 2,000 to 3,000 examples.

They describe this as a lightly supervised scenario that stresses the need for a DA algorithm.

The Aspect Prediction data come from four domains: Device, Laptops, Restaurant, and Service. The authors sample 10% of the training data to form each development set for these domains. They don't test target domains that are semantically unrelated to all of the source domains.

## Paper info

- **Authors**: Eyal Ben-David, Nadav Oved, Roi Reichart
- **Venue**: arXiv · Preprint
- **First published**: 2021-2-24
- **Added**: 2026-11-6
- **Updated**: 2022-1-27
- **Version**: v4
- **arXiv**: 2102.12206
- **Category**: cs.CL · cs.AI · cs.LG
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2102.12206v4) · [PDF ↗](https://arxiv.org/pdf/2102.12206v4)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Abstract

Natural Language Processing algorithms have made incredible progress, but they still struggle when applied to out-of-distribution examples. We address a challenging and underexplored version of this domain adaptation problem, where an algorithm is trained on several source domains, and then applied to examples from unseen domains that are unknown at training time. Particularly, no examples, labeled or unlabeled, or any other knowledge about the target domain are available to the algorithm at training time. We present PADA: An example-based autoregressive Prompt learning algorithm for on-the-fly Any-Domain Adaptation, based on the T5 language model. Given a test example, PADA first generates a unique prompt for it and then, conditioned on this prompt, labels the example with respect to the NLP prediction task. PADA is trained to generate a prompt which is a token sequence of unrestricted length, consisting of Domain Related Features (DRFs) that characterize each of the source domains. Intuitively, the generated prompt is a unique signature that maps the test example to a semantic space spanned by the source domains. In experiments with 3 tasks (text classification and sequence tagging), for a total of 14 multi-source adaptation scenarios, PADA substantially outperforms strong baselines.

## Quote from the paper

Eyal Ben-David, Nadav Oved, Roi Reichart (2021). PADA: Example-based Prompt Learning for on-the-fly Adaptation to Unseen Domains. arXiv:2102.12206v4. https://arxiv.org/abs/2102.12206v4

**BibTeX**

```
@misc{bendavid2021pada,
  title = {{PADA: Example-based Prompt Learning for on-the-fly Adaptation to Unseen Domains}},
  author = {Eyal Ben-David and Nadav Oved and Roi Reichart},
  year = {2021},
  eprint = {2102.12206},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2102.12206v4}
}
```

## Other paper commentary

- [Ultra-fine Entity Typing with Indirect Supervision from Natural Language Inference](https://refivu.com/en/papers/ec3b192e-6258-46de-ab68-df02723dc86f-ultra-fine-entity-typing-with-indirect-supervision-from.md)
- [Prefix-Tuning: Optimizing Continuous Prompts for Generation](https://refivu.com/en/papers/01cf041e-b71c-444b-8b44-e94ac976a9db-prefix-tuning-optimizing-continuous-prompts-for-generation.md)
- [Neural Machine Translation of Rare Words with Subword Units](https://refivu.com/en/papers/0950e659-f6cc-4852-b244-bbb2742bf059-neural-machine-translation-of-rare-words-with-subword.md)
- [SQuAD: 100,000+ Questions for Machine Comprehension of Text](https://refivu.com/en/papers/b88d7f5b-b008-4a74-a452-4513427bbf9f-squad-100-000-questions-for-machine-comprehension-of.md)
- [Measuring Massive Multitask Language Understanding](https://refivu.com/en/papers/c93df260-9bcd-49a6-95e1-3da2df6130ee-measuring-massive-multitask-language-understanding.md)
- [GShard: Scaling Giant Models with Conditional Computation and Automatic Sharding](https://refivu.com/en/papers/2481fdbe-b100-433d-877a-6976f982ccaa-gshard-scaling-giant-models-with-conditional-computation-and.md)
- [PredRNN: A Recurrent Neural Network for Spatiotemporal Predictive Learning](https://refivu.com/en/papers/c0da3abd-5c1e-4383-ae59-22d04fe3eb7d-predrnn-a-recurrent-neural-network-for-spatiotemporal.md)
- [DSEC: A Stereo Event Camera Dataset for Driving Scenarios](https://refivu.com/en/papers/9a47b9e3-cfd0-4ca3-91d0-e4740b73872a-dsec-a-stereo-event-camera-dataset-for-driving.md)
- [Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus](https://refivu.com/en/papers/9c8e6aa3-4291-4395-9813-828baebb2513-reinforcement-learning-based-quantum-circuit-optimization.md)
- [V3D: Video Diffusion Models are Effective 3D Generators](https://refivu.com/en/papers/7ac7016e-0685-4edf-a818-3baccf2777ee-v3d-video-diffusion-models-are-effective-3d-generators.md)
- [The no-free-lunch theorems of supervised learning](https://refivu.com/en/papers/e3085891-a4f1-4605-8cbb-a1c36168e267-the-no-free-lunch-theorems-of-supervised-learning.md)
- [Decision-Oriented Dialogue for Human-AI Collaboration](https://refivu.com/en/papers/1d9fad4b-76a3-40b2-b7c6-3b42b2a8ddc5-decision-oriented-dialogue-for-human-ai-collaboration.md)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/1c1edf58-9646-4fc9-9631-5ddd3c11e749-pada-example-based-prompt-learning-for-on-the)
