Inducing LLM Workflows with Bilevel Optimization and Textual Gradients
Abstract
LLM workflows, which coordinate structured calls to individual LLMs (each augmented with varying instructions and tools) to achieve a particular goal, offer a promising path towards extending the capabilities of LLMs and building powerful systems that can tackle diverse tasks. However, existing approaches for building such workflows generally rely on human-crafted pipelines and prompts, which presents a substantial bottleneck to widening the scope of their applications. How can automatically induce and optimize such workflows in a data-driven way? And can lessons from optimizing deep learning architectures help the design of workflow induction algorithms? This paper describes a simple approach for automatically inducing LLM workflows. We formulate workflow induction as a bilevel optimization problem: an outer loop which optimizes a high-level sketch of the workflow (in particular how the LLM calls should be structured), and an inner loop which optimizes each individual LLM call one-by one. Both loops are optimized with textual gradients'', where for the inner loop we optimize each component in a modular way throughbackpropagating'' textual gradients layer-by-layer. We find that LLM workflows discovered through our WIBOT (\textbf{w}orkflow \textbf{i}nduction through \textbf{b}ilevel \textbf{o}ptimization and \textbf{t}extual gradients) approach performs competitively against strong baselines that automate workflow generation and optimization.