arXiv:2409.16223cs.LGcs.AI2024-09NeurIPS被引 33

微调后模型准确率下降,根源是类别间置信度尺度不一致。

Fine-Tuning is Fine, if Calibrated

  • 发现微调后特征未退化,反而更区分不同类别。
  • 仅因分类头置信度尺度失衡导致其他类识别能力下降。
  • 简单校准即可恢复预训练性能,适合做迁移学习的开发者。

微调是将预训练模型适配下游任务最直接的方法,但存在丢失预训练知识的风险。例如,将一个能识别大量类别的预训练分类器微调为只掌握部分类别时,模型在其他类上的准确率会显著下降。本文系统分析该问题,发现微调后的模型并未遗忘其他类间的关联关系,也未降低其特征表达能力;相反,对未参与微调的类别,模型甚至产生了更具区分性的特征。真正影响准确率的是微调类别与其它类别之间置信度(logit)尺度的不一致。通过简单的后处理校准,即可恢复预训练模型的能力,并提升所有类别的表现。实验验证了结论的稳健性,并提供了初步解释,为未来理论研究提供新方向。代码已开源。

原文摘要 · Abstract (English)

Fine-tuning is arguably the most straightforward way to tailor a pre-trained model (e.g., a foundation model) to downstream applications, but it also comes with the risk of losing valuable knowledge the model had learned in pre-training. For example, fine-tuning a pre-trained classifier capable of recognizing a large number of classes to master a subset of classes at hand is shown to drastically degrade the model's accuracy in the other classes it had previously learned. As such, it is hard to further use the fine-tuned model when it encounters classes beyond the fine-tuning data. In this paper, we systematically dissect the issue, aiming to answer the fundamental question, "What has been damaged in the fine-tuned model?" To our surprise, we find that the fine-tuned model neither forgets the relationship among the other classes nor degrades the features to recognize these classes. Instead, the fine-tuned model often produces more discriminative features for these other classes, even if they were missing during fine-tuning! {What really hurts the accuracy is the discrepant logit scales between the fine-tuning classes and the other classes}, implying that a simple post-processing calibration would bring back the pre-trained model's capability and at the same time unveil the feature improvement over all classes. We conduct an extensive empirical study to demonstrate the robustness of our findings and provide preliminary explanations underlying them, suggesting new directions for future theoretical analysis. Our code is available at https://github.com/OSU-MLB/Fine-Tuning-Is-Fine-If-Calibrated.

微调模型校准迁移学习

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。