Giter Site home page Giter Site logo

sbi_llm's Introduction

Reliable Gradient-free and Likelihood-free Prompt Tuning

This repository contains official implementation of EACL 2023 (Findings) paper Reliable Gradient-free and Likelihood-free Prompt Tuning.

Prepare your environment

conda create --name SBI_LLM python=3.8
conda activate SBI_LLM
pip install transformers==4.1.1
pip install datasets
pip install fastNLP
pip install cma
pip install sklearn
pip install sbi
pip install uq360

Usage

The main.py file includes all the interfaces required for experiments.

The algorithm.py file implements 4 algorithms proposed in the work:

  1. Ensembles: prompt ensembles based on CMA_ES algorithm (for gradient-free prompt tuning).
  2. CMA_ELBO: gradient-free variational inference based on CMA_ES algorithm (for gradient-free prompt tuning).
  3. ABC_SMC: SBI based algorithm ABC_SMC (for likelihood-free prompt tuning).
  4. SBI_neural: neural net-based SBI algorithm (for likelihood-free prompt tuning).

Examples:

To apply ABC_SMC algorithm for likelihood-free prompt tuning on SST2 dataset, and collect 100 prompt samples, simply run:

python main.py \
  --task_name "sst2" \
  --alg_name "ABC_SMC"\
  --num_samples 100 \
  --device "cuda:0" \
  --seed 0 \

To apply Prompt Ensembles algorithm for gradient-free prompt tuning on SNLI dataset, and collect 10 prompt samples, simply run:

python main.py \
  --task_name "snli" \
  --alg_name "Ensembles"\
  --num_samples 10 \
  --device "cuda:0" \
  --seed 0 \

Reference

The implementation is based on this repo: https://github.com/txsun1997/Black-Box-Tuning.

Citations

@inproceedings{shen2023reliable,
  title={Reliable Gradient-free and Likelihood-free Prompt Tuning},
  author={Shen, Maohao and Ghosh, Soumya Sankar and Sattigeri, Prasanna and Das, Subhro and Bu, Yuheng and Wornell, Gregory},
  booktitle={Findings of the Association for Computational Linguistics: EACL 2023},
  pages={2371--2384},
  year={2023}
}

sbi_llm's People

Contributors

maohaos2 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.