Official Implementation of InstructZero; the first framework to optimize bad prompts of ChatGPT(API LLMs) and finally obtain good prompts!
See the codeLichang Chen*, Jiuhai Chen*, Tom Goldstein, Heng Huang, Tianyi Zhou
If you have any questions, feel free to email the correspondence authors: Lichang Chen, Jiuhai Chen. (bobchen, jchen169 AT umd.edu)
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.
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.
We have two folders in InstructZero:
automatic_prompt_engineering: this folder contains the functions from APE, like you could use functions in generate.py to calculate the cost of the whole training required. BTW, to ensure a more efficient OPENAI querying, we make asynchronous calls of ChatGPT which is adapted from Graham's code
experiments: contains the implementation of our pipeline and instruction-coupled kernels.
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
export OPENAI_API_KEY=Your_KEY
bash experiments/run_instructzero.sh
Here we introduce the hyperparameters in our algorithm.
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!
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}
}
105 followers · starred Jun 2023
35 followers · starred Jun 2023
23 followers · starred Nov 2023
Official Implementation of InstructZero; the first framework to optimize bad prompts of ChatGPT(API LLMs) and finally obtain good prompts!
See the codeLichang Chen*, Jiuhai Chen*, Tom Goldstein, Heng Huang, Tianyi Zhou
If you have any questions, feel free to email the correspondence authors: Lichang Chen, Jiuhai Chen. (bobchen, jchen169 AT umd.edu)
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.
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.
We have two folders in InstructZero:
automatic_prompt_engineering: this folder contains the functions from APE, like you could use functions in generate.py to calculate the cost of the whole training required. BTW, to ensure a more efficient OPENAI querying, we make asynchronous calls of ChatGPT which is adapted from Graham's code
experiments: contains the implementation of our pipeline and instruction-coupled kernels.
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
export OPENAI_API_KEY=Your_KEY
bash experiments/run_instructzero.sh
Here we introduce the hyperparameters in our algorithm.
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!
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}
}
105 followers · starred Jun 2023
35 followers · starred Jun 2023
23 followers · starred Nov 2023