Active Inference Language Model (AILM)
AILM's contribution is two things, both explicit: a discrete probabilistic
language-level stack, L1 through L6, with every level declared in Generalized
Notation Notation (GNN) — the Active Inference Institute's structured notation
for generative models — and conformance-checked against the live
pymdp Agent object (inferactively-pymdp)
that declaration describes, with no transformer, no neural network, and no
learned embedding anywhere in it; and a gate-audit and claims-ledger method that
makes every recorded number checkable — a single-writer ledger backs every
quantitative claim in this repository's prose, and every stage gate is scored
against a live positive and negative control before it counts as passing.
External LLM probes (served via a local or hosted transport) are an accessory
reference frame used for comparison, not part of AILM's own model stack. It is
a research system for bounded filtering and lexical generation, with no
behavioral comprehension claim or general-purpose conversational interface.
GNN maintains a downstream adoption guide for repositories that consume the notation.
At a glance
The public source is available on GitHub.
The v1.0.0 GitHub release is published with its Zenodo archive,
10.5281/zenodo.22409419: the DOI
resolves to the archived source and manuscript, and the release page links back
to that record. The release is a frozen snapshot identified by its own tag, and
the work on this branch after that tag is not part of it.
The release carries its own verification record, which accepts the full
software profile and, in that same record, discloses the cold-public quick
resource-accounting hold of that run. Nothing on this branch after the release tag
is covered by it, and full cannot be taken on a checkout that lacks the inputs
listed under verification.

The recorded stage results cover discrete levels and separately measured
cross-level interventions. A connected development runtime now executes live
GNN-built agents with explicit message timing and conditional next-word generation;
its corpus comparison is reported separately from the historical stage scores. Gate outcomes,
the paper, and the decision log are linked throughout this document; start
with docs/hierarchy.md if you want the governing
description, docs/guides/quickstart.md if you want a
running checkout, or docs/README.md for a short
start-here path by audience (newcomer, reviewer, contributor), with a
glossary of every project-specific term.
Data-use notice: the repository and built wheel include Brown-derived
material subject to NLTK's non-commercial-use metadata and Czech-PDTC-derived
material under CC BY-NC-SA 4.0. The source distribution also includes the GUM
evaluation input under CC BY-NC-SA 4.0. See LICENSE and
THIRD_PARTY_NOTICES.md for the component inventory
and upstream terms.
What this is
AILM implements six discrete state spaces, one per level, each a description of
the same text at a different grain:
letter · phoneme · word (factored word+position, trie induced) · case · clause · document position

The separators are dots rather than arrows because the levels are not stages of
one pipeline in the historical stage evaluations: those default level scorers
operate independently. The opt-in connected runtime is described below. Each level is a proper pymdp generative model.
They compose in ways weaker than the word hierarchy suggests. Some share an
alphabet — a level's observation space is the level below's
state space, so the letter-to-phone emission is
A[0, letter, phone] = P(letter | phone) — which is a type identity fixed when
the matrices are built, with nothing flowing along it at run time. The rest is
measured receiver interventions, not assumed messages: update_empirical_prior is
within-level temporal recursion at every call site, while each reported
receiver intervention is a recorded experiment. The measured interventions are:
L1 letters → L2B letter-to-phone is significantly
harmful (docs/decisions.md entry 9), the lexical L3 → L2B message helps at every
tested weight, with an interior argmax the sweep does not distinguish from a
plateau (entries 19 and 110), the document-position (tercile) → clause
prior intervention (narrative in code) is measured (entry 26),
the L3 → L1g generation seam works (entry 17), and the privileged
punctuation-type-oracle → L3 word-prior intervention helps on both recorded
directional summaries, falsifying its predicted harm (entries 27 and 88). That
last arm does not use an L5 posterior. The L3→L1g generation run, L6→L5
D-prior intervention, and oracle→L3 D-prior intervention are independently
measured experiments. Those recorded runs did not connect their interventions
into a document-to-letter cascade. Generation by policy selection
under expected free energy G(π) is built at L1g with L3 lexical preferences; the
policy posterior is computed in closed form (efe_policy_posterior) and
verified against agent.infer_policies, with the agreement recorded — see
docs/decisions.md entries 17 and 95 and the status list below.
The connected runtime uses ailm.levels.connected.ConnectedRuntime with
load_connected_model() from ailm.levels.connected_builder. infer_text()
normalizes raw text into ASCII lexical runs; infer_document() accepts the typed
Sentence and Token contract, optionally with external UPOS observations.
generate_next_word() uses the inferred context and live L1g policy selection.
The composition is a causal schedule of conditional updates, with train-only
bridge kernels, named channel ablations and reset boundaries. It is not an exact
posterior for a single global generative model. See the
connected runtime contract for its assumptions,
observation boundary and executable example. Existing stage and channel results
remain evidence for their original populations and estimands. On the locally
frozen GUM raw-text population, the equal-document normalized-character log-loss
gain (disconnected minus connected) is claim:connected_gum_document_mean_gain
nats, with interval [claim:connected_gum_document_ci_low,
claim:connected_gum_document_ci_high] across claim:connected_gum_documents
documents after excluding claim:connected_gum_excluded_documents previously
inspected documents. Vocabulary coverage is claim:connected_gum_vocab_coverage_pct%;
claim:connected_gum_oov_tokens out-of-vocabulary tokens remain in the scored
stream. Full-stream closed-vocabulary word loss is infinite, as recorded by the
connected_gum_word_loss_is_infinite ledger flag. This is a local
prospective comparison, not external registration or replication; the
manuscript results state the
normalized-stream and conditional-inference limits.
The installed wheel includes the runtime's GNN specifications and bounded data
artifacts. Its library API works outside a source checkout:
from ailm.levels.connected import ConnectedRuntime
from ailm.levels.connected_builder import load_connected_model
runtime = ConnectedRuntime(load_connected_model())
result = runtime.infer_text("the man.")
next_word = runtime.generate_next_word(result)
scripts/run_connected_ailm.py is a source-checkout convenience, not an installed
console command.
The case structure (Level 4 — syntactic case roles (UD-derived), not
grammatical case) is grounded in two of the author's papers:
- CEREBRUM (Friedman 2025) — the core case ontology, a separate novel
Generative role, structurally distinct case free-energy formulations, and the
Supplement {{CEREBRUM_POMDP_SUPPLEMENT}} POMDP tuple
- Compositional Approaches to Linguistic Case for Cognitive Modeling
(Friedman 2026) — enriched categorical formalism, the belief update equation
q^(t+1)(c_k) ∝ q^(t)(c_k) · exp(w_k · o_k), and a case-typed DisCoCat
analysis in FVect/FinHilb. AILM does not implement or claim a DisCoCat
meaning functor; its measured compositions are explicit stochastic kernels.
Exact record identities for both papers, including where a Zenodo record and its
deposited PDF disagree, are pinned in
data/reference_sources.json and summarized in
AGENTS.md.
What Active Inference contributes
Active Inference provides a common framework for perception, learning, and
action; the discrete-state synthesis and
pymdp paper describe that framework.
AILM exercises its parts in distinct paths:
| Operation |
Role in AILM |
Evidence boundary |
| Belief updating |
infer_states updates beliefs about hidden linguistic states from observations and predictive priors. |
This is perceptual inference. The historical stage scorers also use exact or NumPy calculations under the agreements stated in the scope statement. |
| Parameter learning |
infer_parameters updates Dirichlet beliefs over model parameters in the dedicated learning experiments. |
Learning is separate from temporal state recursion; it does not mean every decoder learns online. |
| Action selection |
Lexical preferences and a letter habit shape the next-symbol policy posterior. |
The historical generator uses a checked closed form; connected generation calls live infer_policies and sample_action. |
Recognition receives a text stream; generation chooses the symbols it emits.
In the deterministic letter generator the epistemic term vanishes, so its
actions reflect preferences and habit rather than information-seeking behavior.
Using the framework does not by itself establish an advantage over a matched
probabilistic comparator. The formalism map
links the equations to their implementations and tests and separates these paths
from unused case-function scaffolding.
What this is not
| What AILM is NOT |
What it uses instead |
| A transformer |
pymdp discrete state-space agents |
| A neural language model |
Factorized A/B matrices |
| A system with learned embeddings |
Stochastic maps (discrete probability distributions) |
A system using update_A / update_B |
infer_parameters for learning |
| A black box |
Every factor, every matrix, every case role named and traceable |
What is built
Stages 0-6 are built and have recorded gate outcomes; Stage 7 (speech) is
scoped to a boundary interface contract. Built is not passed: the list below
inventories what exists and states each recorded outcome beside it, and the
gate table in AGENTS.md