Coder Social home page Coder Social logo

bostoncake / promptalign Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jameelhassan/promptalign

0.0 0.0 0.0 6.55 MB

[NeurIPS 2023] Align Your Prompts: Test-Time Prompting with Distribution Alignment for Zero-Shot Generalization

Home Page: https://jameelhassan.github.io/promptalign/

Shell 1.11% Python 98.89%

promptalign's Introduction

Align Your Prompts: Test-Time Prompting with Distribution Alignment for Zero-Shot Generalization [NeurIPS 2023]

Jameel Hassan *, Hanan Gani *, Noor Hussein, Uzair Khattak, Muzammal Naseer, Fahad Khan, Salman Khan

paper Poster Slides Video

Official implementation of the paper "Align Your Prompts: Test-Time Prompting with Distribution Alignment for Zero-Shot Generalization".


Contents

  1. Updates
  2. Highlights
  3. Main Contributions
  4. Installation
  5. Datasets
  6. Run PromptAlign
  7. Results
  8. Citation
  9. Contact
  10. Acknowledgements

Updates

  • Code for PrompAlign is released. [November 3, 2023]
  • Our paper is accepted at NeurIPS 2023 [September 22, 2023]

Highlights

concept-diagram

Abstract: The promising zero-shot generalization of vision-language models such as CLIP has led to their adoption using prompt learning for numerous downstream tasks. Previous works have shown test-time prompt tuning using entropy minimization to adapt text prompts for unseen domains. While effective, this overlooks the key cause for performance degradation to unseen domains โ€“ distribution shift. In this work, we explicitly handle this problem by aligning the out-of-distribution (OOD) test sample statistics to those of the source data using prompt tuning. We use a single test sample to adapt multi-modal prompts at test time by minimizing the feature distribution shift to bridge the gap in the test domain. Evaluating against the domain generalization benchmark, our method improves zero-shot top-1 accuracy beyond existing prompt-learning techniques, with a 3.08% improvement over the baseline MaPLe. In cross-dataset generalization with unseen categories across 10 datasets, our method improves by 1.82% compared to the existing state-of-the-art.


Main Contributions

  • Distribution alignment using a single sample: Given only a single test sample, we introduce a distribution alignment strategy for V-L models to improve test-time adaptation using lightweight prompt learning strategy.
  • Offline statistics for distribution alignment: The proposed strategy formulates a distribution alignment loss that utilizes offline computed source data statistics to encourage the test sample token distributions to be aligned with the source data token distributions. This harmonically combines token distribution alignment with entropy minimization using multi-modal prompt learning.
  • Proxy Source dataset: Since CLIP-pre-training data is not publicly released, we study the statistics of ImageNet as a possible candidate for the source distribution, and our empirical results show that ImageNet is an effective proxy source dataset for large-scale V-L models such as CLIP.

Installation

For installation and other package requirements, please follow the instructions detailed in INSTALL.md

Data Preparation

Please follow the instructions at DATASETS.md to prepare all datasets.

Run PromptAlign

Please refer to the RUN.md for detailed instructions on training, evaluating and reproducing the results using our pre-trained models.

Results

Domain Generalization

Method IN-V2 IN-Sketch IN-A IN-R OOD Average
CLIP 60.86 46.06 47.87 73.98 57.20
CoOp 64.20 47.99 49.71 75.21 59.28
CoCoOp 64.07 48.75 50.63 76.18 59.91
MaPLe 64.07 49.15 50.90 76.98 60.28
TPT + CLIP 64.35 47.94 54.77 77.06 60.81
TPT + CoOp 66.83 49.29 57.95 77.27 62.84
TPT + CoCoOp 64.85 48.27 58.47 78.65 62.61
TPT + MaPLe 64.87 48.16 58.08 78.12 62.31
PromptAlign 65.29 56.23 59.37 79.33 63.55

Citation

If you use our work, please consider citing:

@inproceedings{samadh2023align,
  title={Align Your Prompts: Test-Time Prompting with Distribution Alignment for Zero-Shot Generalization},
  author={Samadh, Jameel Hassan Abdul and Gani, Hanan and Hussein, Noor Hazim and Khattak, Muhammad Uzair and Naseer, Muzammal and Khan, Fahad and Khan, Salman},
  booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
  year={2023}
}

Contact

Should you have any questions, please create an issue in this repository or contact at [email protected] or [email protected]

Acknowledgements

We thank the authors of MaPLe, TPT, and CoOp and CoCoOp for their open-source implementation and instructions on data preparation.

promptalign's People

Contributors

jameelhassan avatar hananshafi avatar muzairkhattak 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.