Textual Gradient Descent

Update a graph variable by asking an LLM to incorporate textual-gradient criticisms — the natural-language analogue of an SGD step.

Textual Gradient Descent (TGD) replaces θ ← θ − ∂L/∂θ with v_new = TGD.step(v, ∂L/∂v): an LLM rewrites variable v in light of aggregated textual gradients. Keep that rewrite behind critique–optimizer separation so the backward pass criticizes without proposing, and steer what may change with optimization variable role descriptions. Optional harness knobs: natural-language optimizer constraints, textual optimizer momentum, and optimizer in-context examples. The same step operator applies across prompts, code, molecules, and plans once the graph and losses are defined. For a graph with n edges, each optimization iteration costs at most n extra LM calls for gradients (one ∇ per edge), plus the forward evaluations.

Objectives may be unstructured and nondifferentiable — LLM judges, unit tests, simulators — so TGD is a general offline improvement loop for compound systems, not only numeric loss minimization. Choose the optimization target with instance vs prompt optimization. Keep accepted updates behind offline prompt evaluation or per-task offline harness tests, and version winning prompts under harness drift awareness.


Sources

  • TextGrad (Yuksekgonul et al.), ch. 2