Fine-Tuning Without Forgetting In-Context Learning: A Theoretical Analysis of Linear Attention Models
Organizations: Yonsei University, Korea · University of Wisconsin–Madison, USA · KRAFTON, Korea · Ludo Robotics, Korea
Abstract
Transformer-based large language models exhibit in-context learning, enabling adaptation to downstream tasks via few-shot prompting with demonstrations. In practice, such models are often fine-tuned to improve zero-shot performance on downstream tasks, allowing them to solve tasks without examples and thereby reducing inference costs. However, fine-tuning can degrade in-context learning, limiting the performance of fine-tuned models on tasks not seen during fine-tuning. Using linear attention models, we provide a theoretical analysis that characterizes how fine-tuning objectives modify attention parameters and identifies conditions under which this leads to degraded few-shot performance. We show that fine-tuning all attention parameters can harm in-context learning, whereas restricting updates to the value matrix improves zero-shot performance while preserving in-context learning. We further show that incorporating an auxiliary few-shot loss enhances in-context learning primarily on the target task, at the expense of degraded in-context learning ability on tasks not seen during fine-tuning. We provide empirical evidence from synthetic and real-world datasets consistent with the qualitative predictions of our theory.
Figures & tables
| Section | Training Regime | Zero-shot error on | Few-shot error on | Few-shot error on | Results |
| (in-distribution) | (in-distribution) | (out-of-distribution) | |||
| § 4.1 | Pretraining | Corollary 4.1 | |||
| ( worst ) | ( best ) | ( best ) | Corollary 4.2 | ||
| § 4.2 | Fine-tuning all parameters | Theorem 4.3 | |||
| with the zero-shot loss | ( best ) | ( worst ) | ( worst ) | Corollary 4.4 | |
| § 4.3 | Fine-tuning the value matrix | Theorem 4.6 |
Appendix figures & tables3 assets
Supplementary material from the paper’s appendix.
Appendix
| 0-shot accuracies | 7-shot accuracies | |||||||
| Model | Humanities | Social Sciences | STEM | Other | Humanities | Social Sciences | STEM | Other |
| Base model | 63.62 (0.11) | 70.12 (0.14) | 70.69 (0.17) | 63.52 (0.12) | 70.13 (0.15) | 75.33 (0.12) | 71.77 (0.17) | 64.06 (0.07) |
| ZS fine-tuning on Q/K/V | 69.30 (0.16) | 75.15 (0.14) | 68.27 (0.20) | 63.65 (0.09) | 66.06 (0.06) | 73.26 (0.19) | 66.72 (0.11) | 62.91 (0.11) |
| +5.69 | +5.03 | -2.42 | +0.13 | -4.07 | -2.06 | -5.05 | -1.15 | |
| ZS fine-tuning on Q | 66.05 (0.11) | 71.77 (0.36) | 67.42 (0.38) | 60.83 (0.13) | 68.57 (0.14) | 73.13 (0.16) | 71.17 (0.27) | 64.01 (0.23) |
| +2.44 | +1.65 | -3.28 | -2.69 | -1.55 | -2.19 | -0.60 | -0.05 | |