Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 24 of 39
❮Prev Next❯

Orchestrate Multiple Models and Rules Engines

Module 2: GenAI & Agents ⏱ 11 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    Don't send everything to the biggest model. A hybrid design tries rules first for answers code can decide exactly, a small language model for easy language work, and a large or reasoning model only for hard requests. A model router deployment can choose among models for you, or your own cascade can escalate when the small model is unsure. This lowers cost and latency, and you measure each route with evaluations and traces.

    Simulate it » No Azure account needed

    Exam objective: 2.3.4 Orchestrate multiple models, flows, or hybrid LLM and rules engines. (Skills measured as of April 16, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    Azure portal: Deploy a small and a large model, then route between them Deploy a small and a large model and test a router.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    Deploy a <strong>small</strong> model for easy work and a <strong>large</strong> one for hard work. Each gets its own deployment name and quota.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. Deploy a small model for easy work and a large one for hard work. Each gets its own deployment name and quota.
    2. A model router deployment picks a model for each prompt for you. It’s one option. Another is your own routing code.
    3. Rules first, then the small model, and the large model only when needed. Two of four requests used no model at all.
    4. Watch Monitoring and Tracing to confirm the router sends what you expect, and tune the rules if too much reaches the large model.

    🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.

    😟 THE PROBLEM

    Every request goes to the large model, including “what time do you open?”.

    😊 THE SOLUTION

    Answer with rules where code can decide, a small model for easy language work, and a large model only when needed.

    • Exact answers✓ A rules engine
    • Easy classification✓ A small model
    • Hard reasoning✓ A large or reasoning model
    🛠️ Solved with: Hybrid routing across models and rules

    Start with a question

    Who answers the phone at a good hospital?

    The receptionist answers “what are the visiting hours?” from a card on the desk. A nurse handles common questions. Only the hard cases go to a consultant, whose time is the most expensive.

    A good AI system works the same way. Rules answer what a table can answer. A small model handles easy language work. The large model is the consultant, called only when needed.

    Explain it like I’m 10

    The technical explanation

    Choose the cheapest thing that works

    RequestHandled byWhy
    “What are your store hours?”Rules (lookup table)Exact, free, no model
    “Refund ₹1,200 for ORD-1042”Rules (policy limit in code)The limit is a policy, so code decides
    “Classify this review”Small model (Phi-4-mini-instruct)Simple, high volume
    “Compare three warranty plans for a café”Large or reasoning model (gpt-4.1, o4-mini)Multi-part reasoning

    A cascade in code

    def route(request: str) -> str:
        if re.search(r"store hours|opening time", request, re.I):  return "rules"     # deterministic answer, no LLM
        if re.search(r"refund", request, re.I):                    return "rules"     # policy limit decided by code
        if len(request) < 120:                                     return os.environ.get("SMALL_DEPLOYMENT", "Phi-4-mini-instruct")
        return os.environ.get("LARGE_DEPLOYMENT", "gpt-4.1")                          # long, multi-part reasoning
    
    for req in REQUESTS:
        target = route(req)
        answer = RULES[req] if target == "rules" else openai.responses.create(model=target, input=req).output_text

    Real systems often decide with more than length. They use a classifier, the small model’s own confidence, or the result of a first attempt, and escalate when the cheaper component isn’t sure.

    Let a router choose

    A model router is a Foundry deployment (preview as of 25 November 2026) that looks at each prompt and selects one of several underlying models, balancing quality and cost. You call it like any deployment, and the response says which model answered. Use it when you want routing without writing the logic, and check traces to confirm the mix is what you expect.

    Combine models and tools in one flow

    Routing also joins different kinds of components in one flow: Content Understanding extracts fields from an invoice, a small model classifies the vendor, a large model drafts a dispute letter, and rules check the totals. Each piece is the right size for its job.

    Measure it

    In the lab’s four-request example, one large model makes 4 model calls. The cascade makes 2, because rules answered two requests, so the relative cost falls to roughly a quarter. Compare quality, cost and latency per route with evaluations and traces, and watch the share of requests that reach the large model.

    Architect level Guard the router too

    If a user’s text decides which model runs, a user can try to steer it. Don’t let the request tell the router “use the biggest model”. Route on your own signals, cap the large-model calls per user, and trace routing decisions so a spike of expensive calls is easy to spot.

    Real-world business scenario

    Wholesale

    Northwind Traders (fictional)

    The problem
    Every customer message went to the largest model, including store hours and refund limits. Replies were slow at peak and the bill kept growing.
    What they used
    A cascade: a rules table for store hours and the refund limit, Phi-4-mini-instruct for review labels, and gpt-4.1 only for long multi-part questions, with escalation when the small model is unsure.
    Why that choice
    Exact answers cost nothing, simple language work uses the small model, and the large model sees only the requests that need it.
    The result
    Half the requests needed no model call, average latency fell, and the model bill dropped by about three quarters with no drop in evaluation scores.

    When to use it and when not to

    ✓ Use it when…

    • Request difficulty varies a lot.
    • Some answers are exact policy that code can decide.
    • Volume is high enough that model size changes the bill.

    ✕ Think twice when…

    • A single, uniform task. One model is simpler.
    • You can't test each route. Untested routing hides quality loss.
    • Routing based on text the user controls, with no limits.

    ↔ Alternatives to consider

    • One well-chosen model when traffic is small.
    • A model router for routing with no custom logic.
    • A workflow when steps, not requests, differ.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the AI-103 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    A support app answers "What are your store hours?" thousands of times a day. The answer is in a table.

    How should the request be handled?

    Question 2

    Question 2 of 5

    The app must label 100,000 reviews as positive, neutral or negative every hour at low cost.

    Which component fits?

    Question 3

    Question 3 of 5

    A team wants a service to choose a suitable model for each prompt automatically.

    Which feature fits?

    Question 4

    Question 4 of 5

    A hybrid design uses rules, a small model and a large model.

    In what order should a request be tried to reduce cost?

    Question 5

    Question 5 of 5

    The small model returns a low-confidence label for some reviews.

    What should the design do?

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner Why not use the biggest model for everything?

    Model answer

    It's slower and costs more, and for simple questions it gives no better answer. A lookup table answers store hours perfectly for free.

    Intermediate How does a cascade work?

    Model answer

    The request goes to rules first. If no rule fits, a small model tries. If it's unsure or the task is hard, the request goes to the large model. Each step is cheaper than the next, and most requests stop early.

    Experienced developer What are the risks of routing?

    Model answer

    Misrouting a hard request to a weak model lowers quality, and routing logic is another thing to test. I evaluate each route on its own and the whole path together, set confidence thresholds for escalation, and watch traces for requests that bounce between models.

    Scenario Reviews must be labelled at 100,000 an hour, but a few are sarcastic and confuse the small model. What do you do?

    Model answer

    I keep the small model for the volume, have it return a confidence or a label I can check, and escalate low-confidence reviews to a larger model. I measure how many escalate and whether accuracy improves.

    Quick revision

    Key points

    • Rules first for exact answers.
    • Small models for simple, high-volume language work.
    • Large or reasoning models only when needed.
    • Escalate when the cheaper component is unsure.
    • Evaluate each route and the whole path.

    Important terminology

    Hybrid design
    A system that combines a rules engine, small models and large models, each doing what it does best.
    Cascade
    Trying the cheapest component first and escalating to a stronger one only when needed.
    Model router
    A Foundry deployment that selects among underlying models for each prompt.
    Rules engine
    Plain code or tables that give exact, repeatable answers with no model call.
    Escalation
    Passing a request to a larger model or a person when the first attempt is unsure.
    Reasoning model
    A model that thinks through multistep problems before answering, at higher cost and latency.

    Common mistakes

    • Using a model for a lookup a table can answer.
    • Routing with no fallback for low confidence.
    • Never measuring how many requests reach the large model.

    Exam tips

    • "Fixed policy limit" = rules engine.
    • "High-volume simple labelling" = small model.
    • "Pick the model for each prompt automatically" = model router.

    Five quick revision questions

    1. 1.What goes first in a cascade?Show

      Rules.

    2. 2.Which model suits simple volume labelling?Show

      A small language model.

    3. 3.What chooses a model per prompt?Show

      A model router.

    4. 4.When do you escalate?Show

      When the cheaper component is unsure.

    5. 5.What do you measure per route?Show

      Quality, cost and latency.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: Generate and Edit Images

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.