Lesson 3 of 5 Multi-Agent Systems and Agent Safeguards

Coordinating Several Models with Pipelines and Ensembles

This lesson covers specialised model pipelines, ensembles and model selection frameworks that coordinate several foundation models with different strengths to outperform any single one.

Learning outcomes

After completing this lesson, you will be able to:

  • Assign specialised models to sub-tasks.
  • Aggregate ensemble outputs with voting or a judge.
  • Record selection rules in a model selection framework.

Specialized models for sub-tasks

A complex task often contains sub-tasks with very different needs. Processing a contract, for example, involves reading a scanned document, which needs a multimodal model or a document service such as Amazon Textract; extracting parties and dates, which a small, fast model handles well; identifying unusual clauses, which needs strong reasoning; and writing a summary in another language, which needs strong multilingual ability.

Assigning each sub-task to the model that performs it best, as measured on evaluation data for that sub-task, improves both quality and cost compared with sending everything to the strongest model. The largest model is used only for the steps that need it, and the overall task often finishes faster because smaller models respond more quickly.

Sort into groups

The right model for each sub-task

Exam skills 2.1.4 · 2.2.3

A contract processing pipeline splits the work into sub-tasks. Choose what should handle each one.

Log in to try this activity Interactive activities are free with an account.

Ensembles and aggregation logic

An ensemble sends the same request to several models (or to one model several times) and aggregates the outputs with custom logic. Majority voting suits classification and yes or no decisions. Agreement checks accept extracted fields only when models agree and flag disagreements for review. Judge selection asks an evaluator model to choose the best response against a rubric. Merging combines complementary outputs, such as findings from several reviewers.

Ensembles multiply cost and add latency, so they are reserved for high-stakes decisions, or applied only when a first model's confidence is low. A Step Functions Parallel state or concurrent SDK calls run the models simultaneously so latency equals the slowest model rather than the sum.

The following diagram shows the ensemble and its agreement logic.

An ensemble for medical coding. Three models assign a code in a Parallel state; agreement logic accepts the code when at least two agree and sends disagreements to human coders. Accuracy of accepted codes rises, and people review only the uncertain minority.
Ensembles multiply cost, so they suit decisions where errors are expensive.
Scenario questions

Aggregating several models

Exam skills 2.1.4

Choose the aggregation logic for each ensemble.

Log in to try this activity Interactive activities are free with an account.

Model selection frameworks

A model selection framework records, for each task type, the candidate models and their measured quality, latency and cost, and the selection rules: the default model, the escalation model, the ensemble policy and fallback models. It is stored as configuration (for example in AWS AppConfig) so it can change without code, and it is updated whenever evaluations are re-run. The following table compares coordination approaches.

ApproachImprovesCost
Specialized model per sub-taskQuality and cost per stepMore integration and evaluation
Majority vote ensembleClassification reliabilityN times the calls
Agreement checkExtraction accuracy with review of disagreementsN times the calls plus review
Judge selectionBest-of-N quality for open-ended outputN calls plus a judge call
Confidence-triggered ensembleReliability where it mattersExtra calls only for uncertain cases
Worked example

Medical coding accuracy

A healthcare company assigns billing codes from clinical notes. Errors are costly, and a single model's accuracy is 92%. Latency is not critical.

An ensemble of three models running in a Parallel state with agreement logic accepts a code when at least two agree and sends disagreements to human coders. Accuracy of accepted codes rises, and humans review only the uncertain minority.

Check yourself

Why are ensembles not used for every request?

Show answer

They multiply cost and latency, so they are reserved for high-stakes or low-confidence cases.

Exam Tips

Remember for the exam

  • Assign each sub-task to the model best and cheapest for it.
  • Ensembles: voting, agreement checks, judge selection, merging.
  • Reserve ensembles for high-stakes or low-confidence cases.
  • Keep model selection rules in configuration such as AppConfig.