This repository is built for you to do the work, not to watch a model do it
for you. There is no LLM review stage, no code-generation step, no autopilot:
every figure, number, and test in output/ is produced by a script you run and
a library you can read. The understanding comes from the run → observe → fix
loop, not from a summary someone else wrote.
Use this page as the companion to reading_order.md. Where
that page tells you what to read, this page tells you how to practice so the
material actually sticks.
Everything you learn by doing happens across three places. Keep them mentally separate — each has a different job.
| Surface | What it is | What you do there |
|---|---|---|
src/active_inference/ |
The library — every algorithm (distributions, inference, estimators, visualizations). Pure logic, fully tested. | Read it to understand how a method works. Occasionally edit it when extending. |
chapters/, extras/, demo/ |
Thin orchestrators (≤ ~120 LOC) that wire library components together to produce a figure or raw-data file. No domain logic. | Run them to see the method in action. Copy/tweak one to run your own experiment. |
tests/ |
pytest suite mirroring src/ one-for-one; 90%+ coverage, no mocks. |
Run them to confirm your change is correct. Add a small test to lock in what you learned. |
That’s the whole map. The scripts/ validators and run.sh menu are just
drivers around these three — they never contain the understanding.
You don’t need to launch anything big. Run the smallest thing that will give you feedback:
# One example, headless, saving figure + raw data
uv run python chapters/chapter_02/example_2_2_linear_probabilistic.py --save
# One whole chapter through the text menu
./run.sh --chapter 2
uv run python -m active_inference.menu --chapter 2
# Unit tests for the logic you just read (fast, no subprocess)
uv run pytest tests/core tests/estimators
# Smoke tests: every chapter script run with --save
uv run pytest tests/chapters -v
# Check the generated artifacts are real (not hand-faked)
uv run python scripts/validate_raw_data_exports.py --root output/data
uv run python scripts/validate_orchestrator_provenance.py
uv run python scripts/validate_source_spine.py --require-pdf
# Export Jupyter notebooks (one per chapter/extras/demo)
uv run python scripts/export_notebooks.py
Each command reports real pass/fail against real artifacts. Read the output, change something, run it again. That loop is the practice.
Unlike some research pipelines that bolt an optional “LLM scientific review” stage onto the end, this repo has none. There is nothing to turn off. The intended workflow is already the manual one:
src/.output/figures/ and output/data/.The correction signal is the rendered figure and the numeric sidecar, not a chat reply. That is what makes it stick.
./run.sh is a stdlib text menu — no model behind it. Use it to browse and
run chapters without remembering filenames:
./run.sh # interactive text menu
./run.sh --all # render every chapter to output/figures/
./run.sh --chapter 3 # one chapter
./run.sh --script example_2_2 # one orchestrator by filename fragment
./run.sh --list # print the discovered menu and exit
# Local browser UI — one tab per chapter, render buttons, inline docs
./run.sh --web
./run.sh --web is the same content with a clickable gallery; nothing is
generated for you that you couldn’t generate from the terminal.
Pick one concept and run the full cycle. Example: Chapter 2, Example 2.2 (Gaussian likelihood × Gaussian prior).
chapters/chapter_02/example_2_2_linear_probabilistic.py — see how it
builds a process + model and calls the inference routine.src/active_inference/core/inference.py (GridBayesianInference) and
src/active_inference/estimators/mle.py — the actual math.uv run python chapters/chapter_02/example_2_2_linear_probabilistic.py --save
Then open output/figures/chapter_02/... and
output/data/chapter_02/<stem>.npz + <stem>.json.topics/bayesian_inference.md
and notation.md to map the code identifier to the book
symbol (e.g. m_x, s2_x ↔ prior mean/variance).tests/. Run
uv run pytest tests/chapters -v to confirm nothing regressed.Steps 3–4 are the part an LLM summary would skip. They are the part that builds the intuition.
reading_order.md — Path A (book follower), Path D
(extender), Path E (claim verifier).architecture.md — the layered design; which subpackage
owns which concern.notation.md — every book symbol ↔ Python identifier.AGENTS.md — the contributor contract and “How to Add a New
Example”.reference/ — per-subpackage API catalogue (core.md,
estimators.md, utils.md, visualizations.md).output/ (figures, data, notebooks) is git-ignored and regenerated from source.
Never hand-edit an artifact under output/ to make a validator pass or to make
a figure “look right.” Fix the source in src/ or the orchestrator.
The validators — validate_raw_data_exports.py,
validate_orchestrator_provenance.py, validate_source_spine.py — exist to
catch real gaps (missing raw-data sidecars, domain logic leaking into a
wrapper, source-status drift). Patching the output to satisfy them defeats the
discipline that makes this repo teach you something. If a validator fails, the
bug is upstream in your code, not in the artifact.
If you only ever read one page, make it cookbook.md — then run
every recipe and change a parameter in each. If you read a second, make it
architecture.md so you know which layer to open when
something surprises you.