Week 15 • Day 3Week 15
Day 3:Parallel Map-Reduce Agents & Majority Voting Ensembles
Battle-tested daily lesson note • 100% runnable code, interview Q&A, test suite & interactive quiz
Day 3: Parallel Map-Reduce Agents & Majority Voting Ensembles
1. First-Principles Math: Condorcet's Jury Theorem for Agent Ensembles
Suppose we run independent reasoning agents (or diverse prompt/temperature samples) on a high-stakes classification or root-cause identification task, where each individual agent has accuracy .
By Condorcet's Jury Theorem, the probability that a majority vote of (odd) agents is correct is:
Example Calculation ()
- Single Agent ():
- 3-Agent Ensemble ():
- 5-Agent Ensemble ():
2. Map-Reduce over Log Shards
When an incident spans 500,000 log lines across N regional clusters, a single context window overflows.
- Map Phase: Partition logs into regional shards; run stateless
MapperAgentinstances in parallel to extract structuredShardAnomalySummaryobjects. - Reduce Phase: A single
ReducerAgentaggregates the compact summaries into a global diagnosis.
In Simple English: Wisdom of Crowds Voting ()
Suppose a complex bug classifier is right of the time on a single try:
- Ask 1 agent once: 75% chance of being right.
- Ask 3 independent agents (
M = 3) in parallel (with slight prompt/temperature diversity) and take the majority vote (2 or 3 agree):- Chance all 3 are right: $0.75^3 = 42.2%$
- Chance exactly 2 are right: $3 \times 0.75^2 \times 0.25 = 42.2%$
- Combined Majority Accuracy: $42.2% + 42.2% = \mathbf{84.4%}$ — nearly +10% higher reliability in the exact same wall-clock latency because all 3 ran at once!