Practice: Review Summaries
Send in action.
Let's practise map reduce with a model. A book has several customer reviews. We'll summarise each one in parallel, then ask the model for one overall verdict.

- Several reviews
- Summarise each in parallel
- One overall verdict
Summarising reviews
Fan out sends each review to the summarise node. Each branch asks the model for a few words, in parallel. The verdict node waits for every summary, and asks for one sentence. Run it. We see a short summary per review, then a single verdict that weighs them together.
import operator
from typing import Annotated, TypedDict
from langchain.chat_models import init_chat_model
from langgraph.graph import StateGraph, START
from langgraph.types import Send
from reviews import REVIEWS
model = init_chat_model("google_genai:gemini-flash-lite-latest", temperature=0)
class State(TypedDict):
reviews: list[str]
notes: Annotated[list[str], operator.add]
verdict: str
def fan_out(s): return [Send("summarise", {"review": r}) for r in s["reviews"]]
def summarise(x): return {"notes": [model.invoke(f"Summarise in 5 words: {x['review']}").text.strip()]}
def verdict(s): return {"verdict": model.invoke(f"One-sentence verdict from these notes: {s['notes']}").text}
b = StateGraph(State); b.add_node(summarise); b.add_node(verdict)
b.add_conditional_edges(START, fan_out, ["summarise"]); b.add_edge("summarise", "verdict")
out = b.compile().invoke({"reviews": REVIEWS, "notes": []})
print(*out["notes"], "", out["verdict"], sep="\n")Captivating world, slow start, unputdownable. Boring, confusing, and unfinished. Desert classic, brilliantly rich characters. Despite a slow and confusing start for some, this desert-set novel ultimately delivers a captivating, unputdownable experience driven by brilliantly rich characters.
Also uses reviews.py
REVIEWS = [
"Couldn't put it down. The world-building is incredible, though the start is slow.",
"Too long and the politics confused me. I gave up halfway.",
"A classic for a reason. Rich characters and a brilliant desert setting.",
]What you practised
You used Send to fan out model calls, a reducer to collect them, and a reduce node for the verdict. Because the summaries run in parallel, ten reviews take about as long as one.
| key | value |
|---|---|
| Send | one call per review |
| Reducer | collects notes |
| Reduce node | the verdict |
| Parallel | 10 ≈ 1 in time |
Summary
Map reduce with Send makes many model calls in parallel, then combines them. Next, Command, which updates state and chooses the next node in one go.
Key takeaways- Fan out model calls
- Collect with a reducer
- One verdict