Home

Awesome

InstructZero: Efficient Instruction Optimization for Black-Box Large Language Models (ICML2024)

Lichang Chen*, Jiuhai Chen*, Tom Goldstein, Heng Huang, Tianyi Zhou

Project page | Paper

<p align="center"> <img src=images/leviosa_v1.jpg width="80%" height="60%"> </p> Find the optimal instruction is extremely important for achieving the "charm", and this holds true for Large Language Models as well. ("Wingardium Leviosa" was a charm used to make objects fly, or levitate. If you are interested in "leviOsa", please check the video in our project page). <br>

If you have any questions, feel free to email the correspondence authors: Lichang Chen, Jiuhai Chen. (bobchen, jchen169 AT umd.edu)

News

About

We propose a new kind of Alignment! The optimization process in our method is like aligning human with LLMs. (Compared to ours, instruction finetuning is more like aligning LLMs with human.) It is also the first framework to optimize the bad prompts for ChatGPT and finally obtain good prompts.

Background

LLMs are instruction followers, but it can be challenging to find the best instruction for different situations, especially for black-box LLMs on which backpropagation is forbidden. Instead of directly optimizing the discrete instruction, we optimize a low-dimensional soft prompt applied to an open-source LLM to generate the instruction for the black-box LLM. <br> <br>

Code Structure

We have two folders in InstructZero:

Installation

conda create -n InstructZero
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.6 -c pytorch -c nvidia
conda install botorch -c pytorch -c gpytorch -c conda-forge
pip install -r requirements.txt # install other requirements

Usage

  1. Firstly, you need to prepare your OPENAI KEY.
export OPENAI_API_KEY=Your_KEY
  1. Secondly, run the script to reproduce the experiments.
bash experiments/run_instructzero.sh

Hyperparameters

Here we introduce the hyperparameters in our algorithm.

Frequently Asked Questions

Comments

Our codebase is based on the following repo:

Thanks for their efforts to make the code public!

Stay tuned! We will make the usage and installation of our packages as easy as possible!

Citation

Please consider citing our paper if you used our code, or results, thx!

@article{chen2023instructzero,
  title={InstructZero: Efficient Instruction Optimization for Black-Box Large Language Models},
  author={Chen, Lichang and Chen, Jiuhai and Goldstein, Tom and Huang, Heng and Zhou, Tianyi},
  journal={arXiv preprint arXiv:2306.03082},
  year={2023}
}