CRoFT: Robust Fine-Tuning with Concurrent Optimization for OOD Generalization and Open-Set OOD Detection

Lin Zhu, Yifeng Yang, Qinying Gu, Xinbing Wang, Chenghu Zhou, Nanyang Ye

Introduction

Fine-tuning large-scale vision-language models like CLIP often leads to "knowledge distortion," where the model excels at the target task but loses its inherent robustness. CRoFT (Concurrent Robust Fine-Tuning) addresses this by simultaneously optimizing for out-of-distribution (OOD) generalization and open-set OOD detection.

The Challenge: Covariate vs. Semantic Shifts

In real-world applications, models face two distinct types of distribution shifts that are typically handled separately:

  1. Covariate Shift (OOD Generalization): Changes in data style (e.g., a photo of a dog vs. a sketch of a dog) while the semantic class remains the same.
  2. Semantic Shift (Open-Set Detection): Encountering entirely new classes not present during training (e.g., seeing a panda when trained only on dogs and cats).
Comparison of ID, Closed-Set OOD, and Open-Set OOD scenarios.

Standard fine-tuning often improves classification on known classes but degrades the model's ability to identify unknown ones. CRoFT aims to bridge this gap by reshaping the model's energy landscape to handle both shifts concurrently.

The CRoFT Framework

CRoFT introduces a unified approach using lightweight adapters and a novel loss function designed to stabilize the model's response to distribution shifts.

The CRoFT framework pipeline.

Technical Components

  • Lightweight Adapters: One-layer linear adapters are added after CLIP’s image and text encoders. This allows for task-specific tuning without the high cost and forgetting associated with full-model fine-tuning.
  • Energy Distribution Reshaping (EDR) Loss: Unlike standard energy-based methods that simply lower energy for in-distribution (ID) data, CRoFT minimizes the gradient magnitude of energy scores. This creates a "flatter" loss landscape, which theoretically ensures domain-consistent Hessians—a key indicator of strong generalization.
  • Adversarial OOD Generation: The framework iteratively generates "worst-case" covariate-shifted image features ($z_I^c$) to train the model to remain robust against style changes it hasn't seen during training.

Experimental Evaluation

The researchers evaluated CRoFT across several rigorous setups, including ImageNet-based benchmarks (ImageNet-A, R, Sketch) and cross-dataset benchmarks (PACS, VLCS). They also tested the framework in few-shot scenarios ranging from 1 to 16 training samples per class.

Key Results and Insights

CRoFT demonstrates that OOD detection and generalization are two sides of the same coin. By shaping the energy landscape, the model achieves:

  • Superior Detection: A reduction in the False Positive Rate (FPR95) by up to 25.3% compared to standard CLIP.
  • Robust Generalization: The best average test accuracy on ImageNet-Sketch and ImageNet-R, proving that detection capabilities do not come at the expense of classification performance.
  • Few-Shot Efficiency: A stable improvement of approximately 1.5% on average over state-of-the-art methods in data-scarce environments.

Conclusion

By focusing on the gradient of energy scores rather than just their absolute values, CRoFT provides a robust mechanism for deploying vision-language models in unpredictable real-world environments. Future work may extend these energy-reshaping principles to other modalities like audio and video.

Summary updated

BibTeX
@inproceedings{zhu2024croft,
  author = {Lin Zhu and Yifeng Yang and Qinying Gu and Xinbing Wang and Chenghu Zhou and Nanyang Ye},
  title = {{CRoFT: Robust Fine-Tuning with Concurrent Optimization for OOD Generalization and Open-Set OOD Detection}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=xFDJBzPhci},
}
Figure