Albert Orozco
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee
  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- title: Model soups tags: merging, distributed learning, continual learning --- <!-- <img src="https://i.imgur.com/PP10FkM.png" alt="clip performance" width="40%" height="50%"> <img src="https://thdaily.s3-us-west-1.amazonaws.com/gif_20200719232646.gif" alt="clip performance" width="40%" height="50%"> ![](https://media.tenor.com/D12KYBUCOBAAAAAd/git-merge.gif) --> <!-- .slide: data-text-color="black" data-transition="zoom" --> ## Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time [`Mitchell Wortsman`](https://mitchellnw.github.io), [`Gabriel Ilharco`](https://gabrielilharco.com), _et al_. presented by [Albert M. Orozco Camacho](https://twitter.com/alorozco53) ---- <iframe width="900" height="500" src="https://www.youtube.com/embed/Zv71G3yXPi4" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> --- <!-- .slide: data-transition="zoom" data-background="red"--> # Preliminaries ---- - <!-- .element: class="fragment" --> Finetuning large models <i>often</i> works well... - <!-- .element: class="fragment" --> but it's not everything we need! - <!-- .element: class="fragment" --> Finetuning roughly consists in two steps: 1. finetune (train) models using many hyperparameter configurations, and 2. select the model that achieves the highest accuracy. ---- ## What happens to discarded models when finetuning? - _Ensembling_ models can outperform the best finetuned model. - It is known that finetuning may reduce OoD performance ([Radford et al., 2021](https://arxiv.org/abs/2103.00020), [Wortsman et al., 2021](https://arxiv.org/abs/2109.01903)). - i.e., zero-shot tasks are quite challenging ---- TODO: Recycle image ---- <!-- .slide: data-background="white"--> ## In this paper... <p style="text-align:left;"> The authors take an alternative way in the <b>finetuning recipe</b>, which is claimed to be <i>more robust</i> and <i>more accurate</i>. </p> > **Finetuning (Soups) Recipe** > :male-cook: :female-cook: <font size="5"> 1. finetune (train) models using many hyperparameter configurations, and 2. _average the weights of all models finetuned before_ </font> Note: - averaging weights seems like a surprising method to improve performance - yet the literature indicates many success stories, due to LMC - but don't forget about model merging... ---- <!-- .slide: data-background="yellow"--> ### Paper Contributions ---- - <!-- .element: class="fragment" --> <b>Greedy Soups</b> - a sequential recipe where models are added to the soup only if they improve accuracy on held-out data ---- - <!-- .element: class="fragment" --> <b>Experiments</b> - using models like CLIP, ALIGN, ViT-G; - authors achieve 90.94% accuracy on IMAGENET, beating previous SOTA, - also requiring 25% less FLOPs; - soups can approach ensembling performance with no additional computational cost; - soups have applications in various distribution shift regimes. ---- <!-- .slide: data-background="white" .slide: data-transition="zoom"--> <img src="https://www.moma.org/d/assets/W1siZiIsIjIwMTUvMTAvMjEvOTY0aWFsdm96Yl9zb3VwY2FuLmpwZyJdLFsicCIsImNvbnZlcnQiLCItcXVhbGl0eSA5MCAtcmVzaXplIDIwMDB4MjAwMFx1MDAzZSJdXQ/soupcan.jpg?sha=9a38fb887eb28928" alt="campbell's" width="50%" height="50%"> --- <!-- .slide: data-transition="zoom" data-background="blue"--> # Method ---- <!-- .slide: data-background="white"--> <p style="text-align:left;"> The authors propose 3 recipes for <i>model souping</i>: </p> 1. :martial_arts_uniform: **Uniform** 2. :money_mouth_face: **Greedy** 3. :books: **Learned** Note: 1. uniform soup is naïve averaging 2. greedy soup is the central, incremental algorithm 3. learned soup optimizes model interpolation weights with a gradient based approach ---- <!-- .slide: data-transition="fade" .slide: data-background="brown" --> ## Setting ---- <!-- .slide: data-background="white"--> - Consider a neural network $f(x, \theta)$ with input data $x$ and parameters $\theta \in \mathbb{R}^d$. - Let $\theta = \text{FineTune}(\theta_0, h)$ be the parameters obtained after finetuning with pretrained weights $\theta_0$ and parameter configuration $h$. - We can list all parameter configurations $h_1,\ldots,h_k$ and distinguish each $\theta_i = \text{FineTune}(\theta_0, h_i)$. ---- <!-- .slide: data-transition="zoom" data-background="white"--> - **Model Soups**: $$ \theta_S = \frac{1}{|S|} \sum_{i \in S} \theta_i \text{ ; where } S \subseteq \{1,\ldots,k\} $$ - :martial_arts_uniform: Uniform Soup: average for $S = \{1,\ldots,k\}$ ---- <!-- .slide: data-transition="zoom" data-background="white"--> ### :money_mouth_face: Greedy Soup :female-cook: :male-cook: ![](https://i.imgur.com/Xl904DW.png) ---- <!-- .slide: data-transition="zoom" data-background="white"--> ### :books: Learned Soup - Mix of coefficients for each of the ingredients on the held-out validation set. - Given loss $\ell$ and validation set $\{x_i, y_i\}_{i=1}^n$ the authors, exhaustively, find coefficients $\alpha \in \mathbb{R}^k$ and temperature scaling parameter $\beta$ via $$ \text{argmin}_{\alpha \in \mathbb{R}^k, \beta \in \mathbb{R}} \sum_{j=1}^n \ell \left(\beta \cdot f\left(x_j, \sum_{i=1}^k \alpha_i \theta_i \right), y_j \right) $$ ---- <!-- .slide: data-transition="zoom" data-background="white"--> ![](https://i.imgur.com/1veiWT3.png) ---- <!-- .slide: data-transition="fade" data-background="orange"--> ![pozole](https://blog.amigofoods.com/wp-content/uploads/2021/03/pozole-rojo-mexican-soup.jpg) --- <!-- .slide: data-background="purple"--> # Experiments ---- <!-- .slide: data-transition="fade" --> ## Models - _CLIP_ ([Radford, et al 2021](https://arxiv.org/abs/2103.00020)), _ALIGN_ ([Jia, et al 2021](https://arxiv.org/abs/2102.05918)), _BASIC_ ([Pham, et al 2021](https://arxiv.org/abs/2111.10050)). - trained with contrastive supervision from image-text pairs <img src="https://i0.wp.com/www.thepanthertech.com/wp-content/uploads/2023/01/Screenshot-2023-01-05-130218.png?resize=1296%2C747&ssl=1" alt="google vs openai" width="50%" height="50%"> ---- <!-- .slide: data-transition="fade" --> - _ViT-G/14_ ([Zhai, et al 2021](https://arxiv.org/abs/2106.04560v2)) - pretrained on JFT-3B ([Zhai, et al 2021](https://arxiv.org/abs/2106.04560v2)) - Transformer models for text classification, such as BERT ([Devlin, et al 2019](https://aclanthology.org/N19-1423/), [Raffel, et al 2020](https://jmlr.org/papers/v21/20-074.html)) ---- ### Initialization of the final layer 1. Via _linear probe_ (LP), that is, freeze almost all layers and finetune a model's head only. 2. Zero-shot: using the classifier produced by the text portion of CLIP or ALIGN. The authors claim that both methods produce similar trends, but LP is prefered among most experiments. ---- ### Error Landscapes <!-- .slide: data-transition="zoom" .slide: data-background="white"--> ![](https://i.imgur.com/rIoeRG7.png) ---- <!-- .slide: data-transition="zoom" .slide: data-background="white"--> ### A Geometric Observation <font size="5"><i>Models that form an angle closer to $90^\circ$ tend to lead to higher accuracy.</i></font> ![](https://i.imgur.com/pYiAgcF.png) ---- ### Ensemble performance is correlated with _Soup_ performance <!-- .slide: data-transition="zoom" .slide: data-background="white"--> ![](https://i.imgur.com/VYJ90lP.png) ---- ### Comparison of :stew::stew::stew: vs individual models <!-- .slide: data-transition="zoom" .slide: data-background="white"--> <img src="https://i.imgur.com/e6u06bY.png" alt="comparison soups" width="50%" height="70%"><img src="https://i.imgur.com/Y66V3wt.png" alt="comparison soups" width="50%" height="70%"> Note: - Model soups improve accuracy over the best individual model when performing a large, random hyperparameter search for finetuning a CLIP ViT-B/32 model on ImageNet - greedy soup outperforms the best dingle model on bothe settings ---- ### Ablation Study <!-- .slide: data-transition="zoom" .slide: data-background="white"--> <img src="https://i.imgur.com/uaK3EFY.png" alt="comparison soups" width="60%" height="70%"> Note: - Model soups improve accuracy when fine-tuning on the diverse classification tasks WILDS-FMoW ---- ### Greedy Soup does better than the best ViT-G individual models <!-- .slide: data-transition="zoom" .slide: data-background="white"--> ![](https://i.imgur.com/hZiPXjY.png) ---- <img src="https://dishingouthealth.com/wp-content/uploads/2022/01/SpicyMisoRamen_Square.jpg" alt="ramen" width="60%" height="70%"> --- <!-- .slide: data-transition="zoom" data-background="pink"--> # Epilogue & Interesting Stuff ---- <!-- .slide: data-background="cyan"--> <img src="https://i.imgur.com/PTnkkRI.jpg" alt="dog" width="70%" height="70%"> ---- <!-- .slide: data-transition="fade" data-background="white"--> ### Expected Soup vs Ensemble loss comparison - Authors obtain an algebraic expression for the expected difference between souping and ensembling models. ![](https://i.imgur.com/Ldp9Dts.png) ---- <!-- .slide: data-transition="fade" data-background="white"--> ### ~~Scope and Limitations~~ Caveats :necktie: - Experiments were done on large models, with pretrained heterogeneous datasets; - _what about low resource regimes?_ - Ensembles improve model calibration, that is, providing a confidence likelihood of prediction; - model soups don't show the same benefits. ---- <!-- .slide: data-transition="zoom" data-background="yellow"--> <img src="https://i.imgur.com/JB8gSM2.jpg" alt="cereal" width="70%" height="70%"> <b>#controversial</b>

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully