Index Ai Academy
Glossary · Phase 1 · Building with LLMs

Map-reduce

Splitting a big job into pieces, handling each piece separately (map), then combining the results (reduce).

Chains often run one step over a whole list, then combine the results. Say you need descriptions for 40 products. You call draft_email once per product, in a loop. Then a final step checks the whole set for repetition, such as ten descriptions that all open the same way. This shape is sometimes called map-reduce. You map one step over many inputs. Then you reduce the results into one.

Try it now

A fake model stands in for the real one, so you can see the shape of a chain. Each step's return value becomes the next step's argument. The final check runs in plain Python. The last line prints: email(facts(rain shell)) True

Learn it properly

Prompt chaining · Break big tasks into a pipeline of smaller model calls. About 30 minutes.

Create a free account See what's in the lesson

Other terms from the same lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write