Automatic Prompt Optimization with "Gradient Descent" and Beam Search

05/04/2023
by   Reid Pryzant, et al.
0

Large Language Models (LLMs) have shown impressive performance as general purpose agents, but their abilities remain highly dependent on prompts which are hand written with onerous trial-and-error effort. We propose a simple and nonparametric solution to this problem, Automatic Prompt Optimization (APO), which is inspired by numerical gradient descent to automatically improve prompts, assuming access to training data and an LLM API. The algorithm uses minibatches of data to form natural language “gradients” that criticize the current prompt. The gradients are then “propagated” into the prompt by editing the prompt in the opposite semantic direction of the gradient. These gradient descent steps are guided by a beam search and bandit selection procedure which significantly improves algorithmic efficiency. Preliminary results across three benchmark NLP tasks and the novel problem of LLM jailbreak detection suggest that Automatic Prompt Optimization can outperform prior prompt editing techniques and improve an initial prompt's performance by up to 31%, by using data to rewrite vague task descriptions into more precise annotation instructions.

READ FULL TEXT
research
06/11/2019

Power Gradient Descent

The development of machine learning is promoting the search for fast and...
research
11/03/2022

Large Language Models Are Human-Level Prompt Engineers

By conditioning on natural language instructions, large language models ...
research
06/29/2020

Natural Gradient for Combined Loss Using Wavelets

Natural gradients have been widely used in optimization of loss function...
research
02/25/2023

Achieving High Accuracy with PINNs via Energy Natural Gradients

We propose energy natural gradient descent, a natural gradient method wi...
research
05/23/2023

Robust Instruction Optimization for Large Language Models with Distribution Shifts

Large Language Models have demonstrated significant ability in accomplis...
research
05/15/2023

Interpretability at Scale: Identifying Causal Mechanisms in Alpaca

Obtaining human-interpretable explanations of large, general-purpose lan...

Please sign up or login with your details

Forgot password? Click here to reset