Workshop · Optimize
TextGrad
Treat the prompt as a variable. Generate. Score or critique the outputs in language. Ask a model to write how the prompt should change. Apply that edit. Repeat. The gradient is text, not a tensor — but the loop is still optimize-against-a-loss.
What a template cannot do
Hand-rewriting a library persona has no backward pass. You cannot point to the error and get a structured update.
- Not automatic differentiation of neural weights.
- Not live TextGrad in this encyclopedia.
- Not a visualization of private chain-of-thought; the “gradient” is an inspectable critique.
How it works
Conceptual workflow
Steppable map of TextGrad. Evidence is taken from the spec on this page. Nothing here is a live compiler, eval, decoder, or optimizer run.
vcp · prompts/textgrad
run@once
- variable
- forward
- loss
- backward
- update
Stage 1 / 5 · receive
Parameterize the prompt
The text you are willing to change is a variable. If it cannot be updated, it cannot be optimized.
Artifact · prompt.txt
User input
You are a helpful refund agent.
Rule in force
Mark the instruction as the parameter.
Visible reply
variable = Prompt('You are a helpful refund agent.')
Illustration · not a live model run
Spec evidence
TextGrad optimizes prompts and other textual parameters by treating natural-language feedback as a gradient. A variable is the prompt, a code snippet, or another text parameter you are willing to change. It is explicit, like a weight. Forward generation runs the current variable on examples and produces outputs. Those outputs are the activations of this analog. A textual loss is a critique: a metric, a rubric, or an LLM that explains what is wrong with the outputs. The loss is not a number alone; it is language about the error. Backward pass: an LLM writes a textual gradient — advice about how to change the variable to reduce that loss. “Add a constraint to refuse unsourced numbers” is a gradient in this system. Update applies the gradient to the variable, producing a new prompt. Repeat until the metric stops improving or the budget is spent. The loop is search, not a one-shot rewrite. TextGrad is not executed here. The map is the forward/backward loop.
- This page is a conceptual map
- The compiler or eval runner is not executed here
Method
Optimize loop · not executed here
Library
A pasted persona belongs in the library
Conceptual workflow · 4.5s / stage · 1/5