ProTeGi / Gradient Descent for Prompts (2023) logo

ProTeGi / Gradient Descent for Prompts (2023)

Free

Textual gradient descent — source paper for many auto-optimization methods

FreeFree tier
Inputs: textOutputs: text
Type
Open Source

About ProTeGi / Gradient Descent for Prompts (2023)

Automatic Prompt Optimization (APO) is a nonparametric method inspired by numerical gradient descent that automatically improves prompts for Large Language Models (LLMs) given training data and an LLM API. The algorithm uses minibatches of data to form natural language 'gradients' that criticize the current prompt, then edits the prompt in the opposite semantic direction of the gradient. These gradient descent steps are guided by a beam search and bandit selection procedure for efficiency. In preliminary experiments across three benchmark NLP tasks and the novel problem of LLM jailbreak detection, APO outperformed prior prompt editing techniques and improved an initial prompt's performance by up to 31%. The paper was presented at EMNLP 2023.

Key Features

Uses training data and LLM API to automatically improve prompts
Forms natural language 'gradients' that criticize the current prompt
Edits prompt in opposite semantic direction of the gradient
Employs beam search and bandit selection for algorithmic efficiency
Demonstrates up to 31% performance improvement on NLP tasks
Applies to novel problem of LLM jailbreak detection

Pros & Cons

Pros
  • Data-driven optimization eliminates manual trial-and-error
  • Outperforms prior prompt editing techniques
  • Significant performance gains (up to 31% improvement) across benchmarks
  • Nonparametric and simple approach with broad applicability
  • Effective on novel tasks like jailbreak detection
Cons
  • Requires access to training data and an LLM API
  • Preliminary results are limited to three benchmark NLP tasks
  • Computational cost from beam search and multiple API calls
  • May not generalize well to highly creative or open-ended prompts

Best For

Automated prompt optimization for LLMsImproving vague task descriptions into precise annotation instructionsLLM jailbreak detectionGeneral NLP tasks requiring prompt engineering

FAQ

What is APO?
APO stands for Automatic Prompt Optimization, a method inspired by numerical gradient descent that automatically improves prompts using training data and an LLM API.
How does APO work?
APO uses minibatches of data to form natural language 'gradients' that criticize the current prompt, then edits the prompt in the opposite semantic direction of the gradient, guided by beam search and bandit selection.
What are the main results?
APO outperformed prior prompt editing techniques on three benchmark NLP tasks and LLM jailbreak detection, improving initial prompt performance by up to 31%.