Skip to content

docs: EP review phase 2 — formal Bayesian documentation of autofit/graphical #1333

Description

@Jammy2211

Overview

Phase 2 of the EP framework review (umbrella: PyAutoMind/research/graphical_ep/ep_framework_review.md; Phase 1 audit: #1332). Package-level documentation stating the exact Bayesian machinery autofit/graphical implements, in formal equations, written so an AI agent (or human) can verify code against the stated math line-by-line.

Autonomy: launched --auto, effective level supervised (docs cap). Plan below per the contract; the run proceeds through implementation and parks at ship sign-off with a batched question. No Heart YELLOW acknowledgement was given at launch.

Plan

  • autofit/graphical/README.md (new): the formal specification — factor-graph model, mean-field approximating family, the EP step (cavity → tilted → moment-matching KL projection → damped division as natural-parameter EMA), evidence decomposition, convergence criteria, exact conjugate updates, deterministic-variable mechanisms — each equation anchored to the implementing class/method (EPMeanField.factor_approximation, MeanField.update_factor_mean_field, AbstractMessage.project, …). Public and self-contained (no personal-repo references).
  • Targeted docstring upgrades at the load-bearing statistical points:
    • MeanField.update_factor_mean_field — the damped-update equation, delta semantics (scalar / per-factor / per-variable MeanField), and the invalid-projection fallback.
    • FactorApproximation.project_mean_field — fix the Phase 1 F5 docstring error ((qᶠₐ)ᵟ (qᶠₐ)¹⁻ᵟ(qᶠₐ)ᵟ (qₐ)¹⁻ᵟ).
    • TransformedMessage._transform / _inverse_transform + composed_transform.py module docstring — the asymmetric reversal convention and a worked UniformPrior example (folds in bug/priors/11, per its Phase 0 verdict).
    • MessageInterface.kl — state the direction contract m.kl(other) ≡ KL(m ‖ other), note the known Gamma/Beta deviation tracked in research: EP review phase 1 — statistics audit of autofit/graphical #1332 (F2) pending its fix.
    • AbstractMessage.project — the importance-weighted sufficient-statistics moment-matching equations.
  • Convention statement: document the current constant-dropping behaviour of log_prior_from_value per family factually, marked as pending unification under Priors & messages: 9 confirmed bugs — guidance wanted on 5 decisions #1331 decision 4 (the docs do not pre-empt that decision).
  • Verification: full test_autofit/graphical/ + test_autofit/messages/ suites (docstring-only changes must not alter behaviour); README proofread against source anchors.
Detailed implementation plan

Affected Repositories

  • PyAutoFit (only) — docs/docstrings; no behaviour changes.

Branch / worktree

  • Branch: feature/ep-graphical-docs; worktree ~/Code/PyAutoLabs-wt/ep-graphical-docs.
  • PyAutoFit is unclaimed at launch (previous aggregator-output-contracts claim released).

Files

  • autofit/graphical/README.md (new)
  • autofit/graphical/mean_field.py (docstrings: update_factor_mean_field, FactorApproximation, F5 fix)
  • autofit/messages/composed_transform.py (module + _transform/_inverse_transform docstrings)
  • autofit/messages/interface.py (KL contract on kl)
  • autofit/messages/abstract.py (project docstring)

Out of scope (later phases)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions