DEV Community

ORCHESTRATE
ORCHESTRATE

Posted on

Active Inference — The Learn Arc, Part 39: Session §7.5 — Worked example (the Chapter 7 capstone)

Session 7.5 — Worked example

Series: The Learn Arc — 50 posts through the Active Inference workbench.
Previous: Part 38 — Session §7.4: Hierarchical active inference

Hero line. Session 7.5 fuses the whole chapter into one agent: Dirichlet A and B, two hierarchical layers, full Eq 4.14 policy scoring. It is the first time the framework runs at anything like the scale of a real problem.


The capstone

If Chapter 7 is the muscle chapter, Session 7.5 is the match day. Everything 7.1 through 7.4 introduced fires simultaneously: the refreshed POMDP loop, the factor-graph derivation of Eq 4.13, Dirichlet learning, and the two-layer stack. Each piece carries weight it did not carry in isolation.

Five beats

  1. A live two-layer agent. Abstract layer picks intents. Concrete layer picks movements. Eq 4.13 runs on both layers every step; Eq 4.14 runs on both layers every planning horizon.

  2. Dirichlet counts compounding in real time. The agent starts with uniform priors on all four slots (a_top, b_top, a_bot, b_bot) and watches E[A], E[B] converge. By step 500, the concrete layer has a crisp world model even though it booted up knowing nothing.

  3. EFE is split across layers. The upper layer's EFE scores abstract policies against its abstract C. The lower layer's EFE scores concrete policies against a C inherited from the upper layer's current intent. The reward signal never leaves the graph.

  4. Surprise as diagnostic. Watching per-step surprise (negative log-evidence) tells you which layer is doing the work. A spike at the concrete layer means new territory; a spike at the abstract layer means the intent was wrong. Nothing else has to change for the agent to notice.

  5. One screen, whole framework. The Workbench renders all of it live: both posteriors, both Dirichlet count sums, EFE per candidate policy on each layer, last observation, last action. If something breaks, where it breaks is visible within one frame.

Why it matters

This is the moment Active Inference stops being a neat idea and becomes a tractable engineering stack. The math from Chapters 4 and 7, the matrices from Chapter 6, the biology metaphors from Chapter 5 — they all compile down to one agent running one loop. If the capstone lands, Chapter 8 (continuous time) and Chapter 9 (fitting) feel like extensions, not new frameworks.

Quiz

  • If the upper layer's posterior is very uncertain early on, what does that imply for the lower layer's C?
  • Which Dirichlet count tensor grows fastest — a_bot or b_top — and why?
  • At step 500 the agent's surprise drops steadily. Which of the four matrices deserves credit?

Run it yourself

mix phx.server
# open http://localhost:4000/learn/session/7/s5_worked_example
Enter fullscreen mode Exit fullscreen mode

Cookbook recipe: chapter-7/capstone — the exact two-layer agent from the session, seeded so the plotted trajectory matches the book. Run it, then mutate one parameter at a time (flatten C, tighten B_top, wipe the Dirichlet counts) and see which knob does what.

Next

Part 40: Session §8.1 — Generalized coordinates. Chapter 8 opens. Time becomes continuous. We trade the discrete q(s_t) for a belief about (s, s', s'', s''', …) — the state and its derivatives — and Eq 4.13 mutates into its continuous-time cousin. Same philosophy, new calculus.


Powered by The ORCHESTRATE Active Inference Learning Workbench — Phoenix/LiveView on pure Jido.

Top comments (0)