Domain Generalization using Large Pre-Trained Models with Mixture-of-Adapters

Korea University

Loss surface visualization Flatness comparison of loss surfaces from models trained with (a) full fine-tuning, (b) LoRA, (c) KAdaptation, and (d) KAdaptation with Mixture-of-Adapter (ours) (denoted as KMoA) on PACS dataset. All visualizations are computed from test environment 0 (TE0) (Art) domain.

Source Image
Target Image
Location 100 (class dog)
Location 38 (class cat)

Visualizations of routed indices for each patch in the TerraIncognita dataset. The left column displays the original image, while in the right column, we indicate where each patch is routed. The upper and lower images were taken at the same location but different times, therefore they share the same background but feature different objects (dog and cat) in terms of shape and location.

Abstract

Learning a robust vision model despite large distribution shift is essential for model deployment in real-world settings. Especially, domain generalization (DG) algorithm aims to maintain the performance of a trained model on different distributions which were not seen during training. One of the most effective methods has been leveraging the already learned rich knowledge of large pretrained models. However, naively fine-tuning large models to DG tasks is often practically infeasible due to memory limitations, extensive time requirements for training, and the risk of learned knowledge deterioration. Recently, parameter-efficient fine-tuning (PEFT) methods have been proposed to reduce the high computational cost during training and efficiently adapt large models to downstream tasks. In this work, for the first time, we find that the use of adapters in PEFT methods not only reduce high computational cost during training but also serve as an effective regularizer for DG tasks. Surprisingly, a naive adapter implementation for large models achieve superior performance on common datasets. However, in situations of large distribution shifts, additional factors such as optimal amount of regularization due to the strength of distribution shifts should be considered for a sophisticated adapter implementation. To address this, we propose a mixture-of-expert based adapter fine-tuning method, dubbed as mixture-of-adapters (MoA). Specifically, we employ multiple adapters that have varying capacities, and by using learnable routers, we allocate each token to a proper adapter. By using both PEFT and MoA methods, we effectively alleviate the performance deterioration caused by distribution shifts and achieve state-of-the-art performance on diverse DG benchmarks.


Framework


Adapter PEFT method (left) and our Mixture-of-Adapter method (right). $W_{0}$ , $X_{in}$ , and $X_{out}$ denotes original pretrained weight, input, and output tokens in multi-head self-attention (MHSA). Adapter can represent any adapter-based PEFT method, such as LoRA, Compacter, KAdaption, etc. Additionally, Router can be a linear or cosine router commonly used in Mixture-of-Expert methods.


Quantitive Results

Overall Results. Quantitative evaluation on domain generalization datasets with Mixture-of-Adapter (MoA) methods. Results with ensemble methods and ours are highlighted in gray and blue. For more details refer to our original paper.

Qualitive Results

Visualizations of routed indices of each patch. We show a total of seven classes in PACS dataset, with one class per row in the order of ‘Guitar’, ‘Horse’, ‘House’, ‘Person’. Also, in each column, the same domains are located in the order of ‘Art Painting’, ‘Cartoon’, ‘Photo’, and ‘Sketch’.

Loss surface visualization Additional flatness comparison of loss surfaces trained with (a) full fine-tuning, (b) LoRA, (c) KAdaptation, and (d) KAdaptation with Mixture-of-Adapter (ours) on PACS dataset. The four test environments in PACS are denoted as TE0, TE1, TE2, TE3.



BibTeX

@article{lee2023domain,
      title={Domain Generalization Using Large Pretrained Models with Mixture-of-Adapters},
      author={Lee, Gyuseong and Jang, Wooseok and Kim, Jin Hyeon and Jung, Jaewoo and Kim, Seungryong},
      journal={arXiv preprint arXiv:2310.11031},
      year={2023}
    }