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.
The right model for each sub-task
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.

Aggregating several models
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.
| Approach | Improves | Cost |
|---|---|---|
| Specialized model per sub-task | Quality and cost per step | More integration and evaluation |
| Majority vote ensemble | Classification reliability | N times the calls |
| Agreement check | Extraction accuracy with review of disagreements | N times the calls plus review |
| Judge selection | Best-of-N quality for open-ended output | N calls plus a judge call |
| Confidence-triggered ensemble | Reliability where it matters | Extra calls only for uncertain cases |
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.
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.