Velamuvi AIAcademy

Lesson 3 of 7 · Patterns

Parallelisation

Run LLM calls in parallel: sectioning splits a job into independent parts, and voting takes the majority of several answers. When each helps and how to combine.

  • 4 min read
  • Intermediate
  • Reviewed
In this lesson you will learn
  • Explain the two kinds of parallelisation: sectioning and voting
  • Split a job into independent parts and combine the results
  • Use voting with an agreement threshold for important decisions
  • Know the cost and speed trade-offs

Two ways to work in parallel

Both patterns in action

Try it yourselfPython
from collections import Counter

# ---- Sectioning: split one job into independent parts, run them at the same time ----
review = "Great battery, but the screen scratches easily and support never replied."
def check_sentiment(text):  return "mixed"
def extract_topics(text):   return ["battery", "screen", "support"]
def check_language(text):   return "polite"
SECTIONS = {"sentiment": check_sentiment, "topics": extract_topics, "tone": check_language}

results = {name: fn(review) for name, fn in SECTIONS.items()}   # independent: could all run at once
print("Sectioning:", results)

# ---- Voting: ask the same question several times (or to several models), take the majority ----
def is_safe_to_publish(text, attempt):
    """Stand-in for 5 separate model calls that don't always agree."""
    return ["yes", "yes", "no", "yes", "yes"][attempt]

votes = Counter(is_safe_to_publish(review, i) for i in range(5))
decision, count = votes.most_common(1)[0]
print("Votes:", dict(votes), "->", decision, f"({count}/5)")
if count < 4:
    print("Not a clear majority: send to a person")

Sectioning gave three focused answers about one review. Because the parts don't depend on each other, they can run at the same time, so the whole job takes as long as the slowest part. Each prompt can also be short and specialised, which often beats one prompt asked to do everything.

Voting asked the same yes/no question five times. Four said “yes”: a clear enough majority to act. With fewer than 4 out of 5 agreeing, the workflow would hand the decision to a person.

When to use which

PatternUse it forCost
SectioningSeveral independent checks or sub-tasks on the same inputSame total calls as doing them in sequence; much faster
VotingHigh-stakes yes/no or category decisions; catching unstable answersSeveral times the cost of one call

Common mistakes

Practice exercise

Combine several model answers by voting, and only act automatically when they clearly agree.

Your solutionPython
from collections import Counter

votes = ["spam", "not spam", "spam", "spam", "not spam"]
required = 4     # need at least 4 of 5 to agree before acting automatically

# Print the majority answer and how many votes it got, then the decision, like:
# ham 5/5
# act on: ham      (or: send to a person)
Knowledge check

Which situation suits voting best?

Summary

  • Sectioning runs independent parts of a job in parallel and combines them.
  • Voting asks several times and acts only on a clear majority.
  • Sectioning saves time; voting buys reliability at extra cost.
  • Only independent steps can run in parallel; make votes genuinely independent.

Next: orchestrator-workers, when the sub-tasks aren't known in advance.

Finished reading? Tick it off to track your progress.