ELOC CYBER

LESSON 6 / MIXTURE OF EXPERTS · 50–60 minutes

Mixture of Experts and task routing

An agent can route a task to a tool or another agent. This lesson compares language predictions with code and explains how that routing differs from a model’s internal Mixture of Experts.

The examples run in your browser. The coding assignments run in your VCC workspace and use the classroom AI allowance.

  • Distinguish internal MoE from routing to tools or agents.
  • Compare a language answer with a checked computation.
  • Test a game-board decision and explain its limits.

01 / CHOOSE THE SOLVER

Choosing tools and specialist agents

Some tasks call for language: rewrite an explanation, summarize notes, or suggest possibilities. Others have a precise rule we can execute: add a column, search a game tree, or fit a statistical model. A useful agent can recognize the difference and hand work to an appropriate tool or specialist.

A basic text LLM predicts tokens. Its harness can use a classifier, routing rules, or a model decision to choose an expert. That expert could be another prompted agent, a calculator, a search service, or a program. Two specialist agents can even use the same underlying model with different instructions and tools.

Routing a task and routing a token happen at different levels

A harness can choose a calculator, another agent, or a workflow for a request. An internal MoE gate selects neural networks during a model’s forward pass. Both can appear in the same system.

Harness routing compared with internal Mixture of Experts routingThe top diagram routes a whole task to a calculator, writing agent or data agent. The bottom diagram routes one token vector through a learned gate to selected expert networks and mixes their outputs. An inactive expert is omitted from the computation.Harness routing — outside the modelTaskA whole requestRouterRules, classifier, or LLMCalculatorWriting agentData agentMixture of Experts — inside a model layerToken vectorOne positionLearned gateSelects expert networksExpert 1Expert 2Expert 3MixOutputs

Swipe or scroll sideways to view the whole diagram.

INTERNAL MoE: A DIFFERENT KIND OF ROUTING

A hand-chosen gate scores three tiny numeric functions, selects two, renormalizes their weights, and combines their outputs. Real MoE gates and expert networks are learned during training. “Expert 1” is a network, not a separate chatbot or a guaranteed math specialist.

QUESTION Could a harness route to several specialists while every model it calls is a dense model? Explain your answer.

02 / INFERENCE AND COMPUTATION

When should we turn it into a coding problem?

An LLM might infer a plausible answer from patterns in training and the current prompt. For arithmetic or a game with exact rules, we can ask it to write or call code that computes an answer we can test. Both routes may begin with the same model; the difference is the evidence behind the result.

For “17 × 23,” a calculator executes a defined operation and returns 391. For an NBA draft board, “best pick” needs a definition, data, and a way to evaluate predictions. A statistical model makes those choices inspectable.

03 / THE NBA DRAFT EXAMPLE

Using regression to evaluate NBA draft picks

Imagine an agent helping you choose your next NBA draft pick. One approach is to show it the board and ask for a recommendation based on what it already knows. It may draw on patterns in pretraining, including commentary about players. That knowledge can be stale, and it does not prove the agent checked current stats.

A stronger investigation gives the agent a concrete job: get a current, permitted raw dataset; record its source and timestamp; clean it; define a target; fit a model; and check its predictions against data it did not train on. Regression predicts a number. You still have to decide which number matters for your draft.

Training data and evaluation data have different jobs

The regression is fitted on training rows. Its held-out predictions are compared with the baseline, while the fitted model can also score current prospects using the information available at draft time.

Data split, regression fitting, evaluation and draft-board predictionsA dated dataset is split before fitting. Training rows fit a regression model. Held-out rows evaluate the fitted model against a baseline. The same fitted model scores the draft board using information known at draft time. Held-out outcomes do not enter training.Dated datasetSource + available statsSplit dataBefore fittingTrainingFit regressionTraining rows onlyHeld outCheck predictionsRows not used to fitFitted modelScore draft boardStats known at draft timeCompare errorsRegression vs baselineHeld-out outcomes are used for evaluation, not to fit the model.

Swipe or scroll sideways to view the whole diagram.

NBA DRAFT EXAMPLE · SYNTHETIC CLASSROOM DATA

Suppose we want to estimate a prospect’s next-season points per game from their current minutes per game. Fit one straight line using six made-up training players, then check three held-out players.

Predict which prospect will rank highest before fitting.

Draft board · synthetic players
ProspectCurrent minutes/gamePredicted next points/game
J22Fit the model first
K27Fit the model first
L19Fit the model first
Inspect training and held-out data
Download the synthetic data

No live NBA feed is connected to this demo. One feature and nine invented players teach the method; they do not support an actual draft decision.

  1. Fit the line and inspect its slope and intercept. Which prospect ranks first under this one-feature model?
  2. Compare held-out mean absolute error (MAE) with the baseline that always predicts the training average. Lower MAE means smaller average errors on these held-out players.
  3. Name two missing factors: injuries, role, age, competition level, team needs, or something else. Explain how one might change the pick.
How would we use actual current stats?

Ask your coding agent to use an instructor-approved dataset/API, record the provider, season, retrieval time, units, and missing values, and save a dated snapshot. Split training and evaluation by time when predicting future performance. Fit preprocessing using training data only. Compare regression with a simple baseline and report held-out errors.

Then score the current draft board using information available at draft time. Never train on future outcomes for the players you are pretending to predict; that is data leakage. Show uncertainty and limitations alongside the ranking. A live feed supplies newer observations, not guaranteed future outcomes.

Help investigate an NBA draft board using code. First ask me for the board, an instructor-approved current stats source, and the target to predict. Record source, season, and retrieval timestamp; save a reproducible data snapshot. Check units and missing values. Build a simple regression with a time-based held-out evaluation and a training-mean baseline; avoid future-data leakage. Run the code and report held-out MAE, the model ranking, assumptions, and missing factors. Keep synthetic examples clearly labeled. Do not invent live stats or claim a ranking guarantees the best pick.

04 / ASSIGNMENT

Ask an agent to analyze a game board.

We can check a board more completely than a future basketball career. Use tic-tac-toe, where the rules are small enough to search every possible legal continuation.

LANGUAGE GUESS → SEARCH THE GAME

Click a square to cycle empty → X → O → empty. Squares are numbered 1–9, left to right.

Compare the approaches

The browser “guess” is a scripted center-first rule, not a live LLM. The search runs exhaustive minimax over legal continuations. A score of +1 / 0 / −1 means forced win / draw / forced loss with perfect play by both sides. Several moves can tie.

  1. Choose a valid unfinished board. Before searching, write your own suggested move and why.
  2. Copy its board prompt into VCC ↗. First ask the agent for a best-move guess without tools. Record its square and reasoning as a language prediction.
  3. Then ask it to create and run a minimax solver. Tell it to validate the board, score every legal move, test immediate wins and blocks, and report ties. Keep the rules and board identical.
  4. Compare the real agent’s first guess with its computed move scores and this browser’s search. Ask for the executed command, output, and tests.
  5. Change one square to make a second valid board. Repeat. One correct guess does not show the method is always reliable.
Now solve the exact same tic-tac-toe board with code. X starts and turns alternate. Validate counts, winners, whose turn it is, and whether the game already ended. Write and run an exhaustive minimax solver that assumes perfect play by both sides. Score every legal move as win, draw, or loss for the player to move and report all tied best moves. Test an immediate win, a necessary block, a draw, and an invalid board. Show the command, actual output, and tests. Compare that evidence with your earlier no-tool guess. Keep the starter app working.

05 / NEXT: SPLITTING THE WORK

Dividing a task among agents

A harness can split a larger task into discrete parts: one specialist fetches data, another checks it, another fits a model, and another explains the results. The harness must track which results belong together and check that the combined answer still meets the goal. More handoffs also add coordination and token costs. Separate agents are useful when the work benefits from separate contexts or independent parallel tasks; they are not a requirement for every workflow. Lesson 7 follows how a model builds a response, and Lesson 8 explores sparse expert networks.

Which is an example of internal MoE?

A regression script runs twice and gives the same ranking. What have you established?

Turn in: your two valid boards, each no-tool guess, each executed solver result, tests, and a short comparison. Add one limitation of the draft regression and one sentence distinguishing MoE from harness routing.

Review: Describe a task you would give a language specialist, one you would give a code tool, and the evidence you would request from each. Save your work and stop your VCC workspace.

Instructor notes & sources

Allow about 5–10 minutes for the opening model, 15 for the browser investigation, 20–25 for the VCC activity, and 5 for the review questions. Students can work in pairs and compare their answers. Provision VCC access before class. The demos need no sign-in, API key, or paid inference. If class AI is unavailable, students can inspect demos, run the offline harness, and write expected traces; the live assignment still needs a later model run.

Assess the prediction, trace, and explanation along with the result. The small models, invented player data, fixed chat replies, and scripted browser requests are labeled at the point of use.

Further reading: Attention Is All You Need · Chat templates · Agent workflows and routing · Switch Transformers.