Few-shot Fine-tuning vs. In-context Learning: A Fair Comparison and Evaluation

Marius Mosbach, Tiago Pimentel, Shauli Ravfogel, Dietrich Klakow, Yanai Elazar

2023 · 66 citations · 28 references

DOIFull text

Open access

Concepts

TL;DR

Few‑shot fine‑tuning and in‑context learning are two alternative strategies for adapting pre‑trained language models, with the latter gaining popularity for its simplicity and better out‑of‑domain generalization, while fine‑tuned models are prone to spurious correlations. The study asks whether fine‑tuned models’ weaker out‑of‑domain performance is inherent to fine‑tuning or merely a consequence of prior experimental setups. We conduct a controlled comparison across models sized 125 M to 30 B, varying example counts and parameters, to evaluate generalization of both approaches on challenging datasets. Fine‑tuned models can generalize well out‑of‑domain, and both fine‑tuning and in‑context learning perform similarly, with performance varying widely based on model size and example count, underscoring the difficulty of robust task adaptation.

Abstract

Few-shot fine-tuning and in-context learning are two alternative strategies for task adaptation of pre-trained language models. Recently, in-context learning has gained popularity over fine-tuning due to its simplicity and improved out-of-domain generalization, and because extensive evidence shows that fine-tuned models pick up on spurious correlations.Unfortunately, previous comparisons of the two approaches were done using models of different sizes. This raises the question of whether the observed weaker out-of-domain generalization of fine-tuned models is an inherent property of fine-tuning or a limitation of the experimental setup. In this paper, we compare the generalization of few-shot fine-tuning and in-context learning to challenge datasets, while controlling for the models used, the number of examples, and the number of parameters, ranging from 125M to 30B. Our results show that fine-tuned language models can in fact generalize well out-of-domain. We find that both approaches generalize similarly; they exhibit large variation and depend on properties such as model size and the number of examples, highlighting that robust task adaptation remains a challenge.

References

28