prompt chaining
In plain wordsA way of getting a big job done with a relay of AI requests: each handles one stage and passes its result to the next — pull out the facts, write, polish — with automatic checks between stages.
A workflow technique in which a task runs as a fixed relay of language-modellarge language model, n.: A computer program trained on enormous amounts of text to predict the words that come next. At vast scale, that simple skill lets it chat, answer questions, translate, summarize and write code. calls, each with its own prompt and each consuming what the previous call produced — for example extract the facts, then draft, then adjust the tone, then translate. Code placed between the calls (sometimes called gates) can test intermediate results against a format, a length or a policy and halt or reroute the chain when a test fails. Because every call faces a narrower problem, accuracy tends to rise at the price of latency and extra calls, and the intermediate outputs can be inspected and improved one at a time. It is the simplest agentic workflowagentic workflow, n.: A multi-step process in which AI models draft, check, use tools and revise their work over several rounds, instead of answering in one shot; often the steps are laid out by developers in advance. pattern and the source of the 'chain' in LangChain; unlike an AI agentAI agent, n.: An AI system that does not just answer but acts: given a goal, it decides on steps, uses tools such as a browser or code editor, checks the results and keeps going until the job is done., a chain does not choose its own next step.
We replaced one giant prompt with a three-step prompt chain and the invented figures disappeared.
Origin
Described in 'AI Chains: Transparent and Controllable Human-AI Interaction by Chaining Large Language Model Prompts' by Tongshuang Wu, Michael Terry and Carrie J. Cai (Google; posted October 2021, CHI 2022). LangChainLangChain, prop. n.: A popular free software toolkit, and the company behind it, for building applications that connect AI language models to documents, databases, tools and multi-step workflows. (October 2022) built a popular library around chains, and Anthropic's 'Building effective agents' (December 2024) listed prompt chaining as the first workflow pattern.
Related
- agentic workflowagentic workflow, n.: A multi-step process in which AI models draft, check, use tools and revise their work over several rounds, instead of answering in one shot; often the steps are laid out by developers in advance.
- task decompositiontask decomposition, n.: Breaking a big, vague job into smaller, concrete steps that can each be done and checked — the way a recipe splits a meal into stages.
- evaluator–optimizerevaluator–optimizer, n.: A pairing in which one AI produces a draft and another AI grades it and suggests fixes, repeating the cycle until the work is good enough.
- orchestrationorchestration, n.: Coordinating several AI calls, tools or agents so each does its part in the right order and their results are combined into one finished piece of work, as a conductor directs an orchestra.
- prompt engineeringprompt engineering, n.: The skill of writing requests to an AI — picking the words, examples, format and background information it receives — so that it reliably gives the result you want, without retraining it.
- LangChainLangChain, prop. n.: A popular free software toolkit, and the company behind it, for building applications that connect AI language models to documents, databases, tools and multi-step workflows.
- AI agentAI agent, n.: An AI system that does not just answer but acts: given a goal, it decides on steps, uses tools such as a browser or code editor, checks the results and keeps going until the job is done.
Sources
- Wu, T., Terry, M. & Cai, C. J. (2022). AI Chains: Transparent and Controllable Human-AI Interaction by Chaining Large Language Model Prompts. CHI 2022. arXiv:2110.01691. arxiv.org/abs/2110.01691
- Schluntz, E. & Zhang, B. (2024). Building effective agents. Anthropic. anthropic.com/research/building-effective-agents
Mentioned in
prompt engineeringprompt engineering, n.: The skill of writing requests to an AI — picking the words, examples, format and background information it receives — so that it reliably gives the result you want, without retraining it., agentic workflowagentic workflow, n.: A multi-step process in which AI models draft, check, use tools and revise their work over several rounds, instead of answering in one shot; often the steps are laid out by developers in advance., LangChainLangChain, prop. n.: A popular free software toolkit, and the company behind it, for building applications that connect AI language models to documents, databases, tools and multi-step workflows., orchestrationorchestration, n.: Coordinating several AI calls, tools or agents so each does its part in the right order and their results are combined into one finished piece of work, as a conductor directs an orchestra., orchestrator–worker patternorchestrator–worker pattern, n.: A way of organizing AI teamwork, like a newsroom: an editor AI decides which stories a big assignment needs, sends reporter AIs to cover them at the same time, and turns what they file into one report., scaffoldingscaffolding, n.: The code, prompts and tools built around an AI model so it can carry out tasks it could not manage from a bare prompt — like the scaffolding that lets builders reach every part of a building., evaluator–optimizerevaluator–optimizer, n.: A pairing in which one AI produces a draft and another AI grades it and suggests fixes, repeating the cycle until the work is good enough., least-to-most promptingleast-to-most prompting, n.: A prompting method that has an AI list the smaller questions a hard problem depends on, answer the easiest first, and feed each answer into the next, building up to the full solution.