Coder Social home page Coder Social logo

map's Introduction

MAP: Low-compute Model Merging with Amortized Pareto Fronts via Quadratic Approximation

map Logo

arXiv

Lu Li†, Tianyu Zhang†, Zhiqi Bu†, Suyuchen Wang, Huan He, Jie Fu, Yonghui Wu, Jiang Bian, Yong Chen, Yoshua Bengio

† Equal contribution

Code

Quick Start

conda env create -f environment.yaml
conda activate map
git clone https://github.com/mlfoundations/task_vectors # we used the zero-shot task vectors from this repo
python run_MAP.py # check the args.py for the hyperparameters and 4 modes

Introduction

scatter

The overall process of MAP under 2 tasks.

  • Step 1: select tasks and their corresponding task vectors.
  • Step 2: sample a few scaling weights $c$ to query the task metrics accordingly.
  • Step 3: use a quadratic model to approximate the mapping of $c \rightarrow \textit{metrics}$ as a surrogate model.
  • Step 4: use NSGA-III (or other multi-objective optimization algorithms) to find amortized Pareto fronts.

Figure (a) shows the contour plots of the actual accuracy landscape for the ViT models obtained from 100 scaling coefficients (sampled uniformly) evaluated on the SUN397 and Cars.

Figure (b) shows the contour plots of the fitted quadratic functions. Red lines represent the Pareto front in the decision variable $(c_1, c_2)$ space.

Figure (c) shows an example of the Pareto Front. Pareto front (Grid search) is regarded as the ground truth given the enough number of grid points. Pareto front (MAP, predicted) is the amortized Pareto front. Pareto front (MAP, real) is the Pareto front involving the same ${(c_1,c_2)}$ but re-evaluated as to get the ground truth metrics as a comparison. The yellow lines are the evaluation performance of the fine-tuned single task models.

Examples

Nested merging

Given a preference weights vector [a,b,c,d]. In the following example, it is the example_preferece.yaml file.

  1. According to the losses on single task, first, we merge Cars and SVHN models according to the amortized Pareto Front and the preference [a, b].
  2. In the mean time, we merge SUN397 and DTD models according to the amortized Pareto Front and the preference [c, d].
  3. Finally, we merge the merged Cars+SVHN and SUN397+DTD models according to the amortized Pareto Front and the preference [a + b, c + d].
Merge Cars and SVHN
Merge Cars and SVHN Models
Merge SUN397 and DTD
Merge SUN397 and DTD Models
Merge SUN397+DTD and Cars+SVHN
Merge SUN397+DTD and Cars+SVHN Models

Run the 8-task nested merging

  python MAP/run_MAP.py \
    --zeroshot-merge-models SUN397Val CarsVal DTDVal SVHNVal EuroSATVal GTSRBVal RESISC45Val \
    --zeroshot-eval-datasets SUN397Val CarsVal DTDVal SVHNVal EuroSATVal GTSRBVal RESISC45Val \
    --preference example_preferece.yaml \
    --results-path nested_experiments8
# Example of the example_preferece.yaml
{
  "SUN397Val": 1,
  "CarsVal": 2,
  "DTDVal": 6,
  "SVHNVal": 5,
  "EuroSATVal": 4,
  "GTSRBVal": 3,
  "RESISC45Val": 7,
}

map's People

Contributors

luli-git avatar

Stargazers

 avatar Xiang Zhao avatar Tianyu Zhang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.