Last Updated: 2026-01-09
A standardized text-based language for Active Inference generative models
๐ Quick Start โข ๐ Documentation โข ๐ฏ Examples โข ๐ ๏ธ Tools โข ๐ค Contributing
- ๐ Overview
- ๐ Key Files
- ๐ฏ Motivation and Goals
- โจ Key Features
- ๐๏ธ Project Architecture
- โ๏ธ Processing Pipeline
- ๐ ๏ธ Tools and Utilities
- ๐ Quick Start
- ๐ Documentation
- ๐ฏ Examples
- ๐ Repository Health
- ๐ค Contributing
- ๐ License
Generalized Notation Notation (GNN) is a text-based language designed to standardize the representation and communication of Active Inference generative models. It aims to enhance clarity, reproducibility, and interoperability in the field of Active Inference and cognitive modeling.
Smรฉkal, J., & Friedman, D. A. (2023). Generalized Notation Notation for Active Inference Models. Active Inference Journal.
๐ DOI: 10.5281/zenodo.7803328
๐ Archive: zenodo.org/records/7803328
GNN provides a structured and standardized way to describe complex cognitive models. It is designed to be:
- ๐งโ๐ป Human-readable: Easy to understand and use for researchers from diverse backgrounds
- ๐ค Machine-parsable: Can be processed by software tools for analysis, visualization, and code generation
- ๐ Interoperable: Facilitates the exchange and reuse of models across different platforms and research groups
- ๐ฌ Reproducible: Enables precise replication of model specifications
GNN addresses the challenge of communicating Active Inference models, which are often described using a mix of natural language, mathematical equations, diagrams, and code. By offering a unified notation, GNN aims to streamline collaboration, improve model understanding, and accelerate research.
๐ Start here to understand the repository structure and find what you need quickly.
| File | Purpose | Start Here If... |
|---|---|---|
| README.md | Main entry point and overview | You're new to GNN |
| AGENTS.md | Master agent scaffolding - all 24 modules documented | You want to understand the pipeline architecture |
| DOCS.md | Comprehensive documentation with all diagrams | You need the complete system overview |
| ARCHITECTURE.md | Implementation patterns and extension guides | You're developing or extending GNN |
| doc/quickstart.md | Step-by-step getting started guide | You want to run your first pipeline |
| doc/gnn/gnn_syntax.md | Complete GNN syntax specification | You're writing GNN model files |
| pyproject.toml | Project dependencies and configuration | You're setting up the environment |
| SETUP_GUIDE.md | Detailed installation instructions | You're having setup issues |
| SECURITY.md | Security policy and vulnerability reporting | You found a security issue |
| SUPPORT.md | Getting help and community resources | You need assistance |
| CITATION.cff | Citation information for academic use | You're citing GNN in research |
GeneralizedNotationNotation/
โโโ ๐ README.md, AGENTS.md, DOCS.md, ARCHITECTURE.md # Core documentation
โโโ ๐ src/ # 24-step pipeline + 28 agent modules
โ โโโ main.py # ๐ฏ Main orchestrator - run this!
โ โโโ 0_template.py โ 23_report.py # Numbered pipeline scripts
โ โโโ gnn/, render/, execute/, llm/, ... # Agent modules
โ โโโ tests/ # Comprehensive test suite
โโโ ๐ doc/ # 580+ documentation files
โ โโโ gnn/ # GNN language specification
โ โโโ pymdp/, rxinfer/ # Framework integration guides
โ โโโ cognitive_phenomena/ # Example cognitive models
โโโ ๐ input/ # Input GNN files and configuration
โ โโโ gnn_files/ # Sample GNN model files
โโโ ๐ output/ # Generated outputs (24 step-specific folders)
โโโ ๐ pyproject.toml, pytest.ini # Configuration files
The GNN pipeline is composed of 24 specialized modules, each acting as an agent with specific responsibilities. This "Thin Orchestrator" architecture ensures modularity and testability.
| Step | Agent / Module | Description | Links |
|---|---|---|---|
| 0 | Template | Initial project scaffolding and configuration. | ๐ค Agent โข ๐ Code |
| 1 | Setup | Environment, dependencies, and UV package management. | ๐ค Agent โข ๐ Code |
| 2 | Tests | Comprehensive suite orchestration and coverage analysis. | ๐ค Agent โข ๐ Code |
| 3 | GNN | Core parsing, discovery, and semantic object model. | ๐ค Agent โข ๐ Code |
| 4 | Registry | Validation and versioning of model artifacts. | ๐ค Agent โข ๐ Code |
| 5 | TypeCheck | Static analysis, dimension validation, resource estimation. | ๐ค Agent โข ๐ Code |
| 6 | Validate | Logical consistency and ontology compliance. | ๐ค Agent โข ๐ Code |
| 7 | Export | Serialization to JSON, XML, GraphML, etc. | ๐ค Agent โข ๐ Code |
| 8 | Viz | Static visualization of matrices and network logic. | ๐ค Agent โข ๐ Code |
| 9 | Adv. Viz | Interactive diagrams and complex visual analysis. | ๐ค Agent โข ๐ Code |
| 10 | Ontology | Semantic mapping to Active Inference definitions. | ๐ค Agent โข ๐ Code |
| 11 | Render | Code generation for PyMDP, RxInfer, JAX, etc. | ๐ค Agent โข ๐ Code |
| 12 | Execute | Simulation runner and runtime management. | ๐ค Agent โข ๐ Code |
| 13 | LLM | Neurosymbolic analysis and text generation. | ๐ค Agent โข ๐ Code |
| 14 | ML | Integration with external ML frameworks. | ๐ค Agent โข ๐ Code |
| 15 | Audio | Sonification of model dynamics. | ๐ค Agent โข ๐ Code |
| 16 | Analysis | Statistical post-processing of simulation results. | ๐ค Agent โข ๐ Code |
| 17 | Integrate | Cross-module synthesis and coordination. | ๐ค Agent โข ๐ Code |
| 18 | Security | Safety checks and sandboxing. | ๐ค Agent โข ๐ Code |
| 19 | Research | Experimental features and benchmarking. | ๐ค Agent โข ๐ Code |
| 20 | Website | Static site generation for reports/docs. | ๐ค Agent โข ๐ Code |
| 21 | MCP | Model Context Protocol server and tools. | ๐ค Agent โข ๐ Code |
| 22 | GUI | Interactive visual editors (Web & Local). | ๐ค Agent โข ๐ Code |
| 23 | Report | Final comprehensive report assembly. | ๐ค Agent โข ๐ Code |
The primary motivation behind GNN is to overcome the limitations arising from the lack of a standardized notation for Active Inference models. This fragmentation can lead to difficulties in:
- ๐ฌ Effective Communication: Making complex models hard to explain and understand
- ๐ Reproducibility: Hindering the ability to replicate research findings
- โ๏ธ Consistent Implementation: Leading to variations when translating models into code
- ๐ Systematic Comparison: Making it challenging to compare different models
The goals of GNN are to:
- โ Facilitate clear communication and understanding of Active Inference models
- โ Promote collaboration among researchers
- โ Enable the development of tools for model validation, visualization, and automated code generation
- โ Support the creation of a shared repository of Active Inference models
- โ Bridge the gap between theoretical concepts and practical implementations
GNN supports three complementary modalities for model representation, known as the "Triple Play":
graph LR
subgraph "๐ญ Triple Play Approach"
A["๐ Text-Based Models<br/>โข GNN Markdown files<br/>โข Human-readable syntax<br/>โข Mathematical notation<br/>โข Natural language descriptions"]
B["๐ Graphical Models<br/>โข Factor graphs<br/>โข Network visualizations<br/>โข Dependency diagrams<br/>โข Interactive visualizations"]
C["โ๏ธ Executable Models<br/>โข PyMDP simulations<br/>โข RxInfer.jl implementations<br/>โข JAX computations<br/>โข DisCoPy diagrams"]
end
A -->|Parse & Extract| B
A -->|Generate Code| C
B -->|Validate Structure| C
C -->|Simulate & Test| A
B -->|Visual Feedback| A
C -->|Results Analysis| B
style A fill:#e8f5e8,stroke:#4caf50
style B fill:#e3f2fd,stroke:#2196f3
style C fill:#fff3e0,stroke:#ff9800
-
๐ Text-Based Models: GNN files are plain text and can be rendered into mathematical notation, pseudocode, or natural language descriptions. This forms the core representation.
-
๐ Graphical Models: The structure defined in GNN (variables and their connections) can be visualized as graphical models (e.g., factor graphs), clarifying dependencies and model architecture.
-
โ๏ธ Executable Cognitive Models: GNN specifications can serve as a high-level blueprint or pseudocode for implementing executable simulations in various programming environments. This ensures consistency and aids in the translation from theory to practice.
GNN defines a specific file structure, typically using Markdown, to organize model components. This includes sections for:
- ๐ท๏ธ Model metadata (name, version, annotations)
- ๐ State space (variable definitions)
- ๐ Connections (relationships between variables)
- โ๏ธ Initial parameterization
- ๐ Equations
- โฐ Time settings (for dynamic models)
- ๐ง Mapping to Active Inference Ontology terms
Here's a glimpse of what a GNN model file looks like (from input/gnn_files/actinf_pomdp_agent.md):
๐ View GNN File Example
# GNN Example: Active Inference POMDP Agent
# GNN Version: 1.0
## GNNSection
ActInfPOMDP
## ModelName
Active Inference POMDP Agent
## StateSpaceBlock
# Likelihood matrix: A[observation_outcomes, hidden_states]
A[3,3,type=float] # Likelihood mapping hidden states to observations
# Transition matrix: B[states_next, states_previous, actions]
B[3,3,3,type=float] # State transitions given previous state and action
# Preference vector: C[observation_outcomes]
C[3,type=float] # Log-preferences over observations
# Hidden State
s[3,1,type=float] # Current hidden state distribution
## Connections
D>s
s-A
s>s_prime
A-o
ฯ>u
## InitialParameterization
A={(0.9,0.05,0.05), (0.05,0.9,0.05), (0.05,0.05,0.9)}
C={(0.1, 0.1, 1.0)}
D={(0.33333, 0.33333, 0.33333)}
## ActInfOntologyAnnotation
A=LikelihoodMatrix
B=TransitionMatrix
s=HiddenState
o=ObservationConnection Syntax:
D>sโ D feeds into s (directed)s-Aโ s connects to A (undirected/bidirectional)ฯ>uโ Policy determines action
๐ Full syntax reference: doc/gnn/gnn_syntax.md
graph TB
subgraph "๐๏ธ GNN Project Architecture"
subgraph "๐ Source Code (src/)"
A[โ๏ธ Pipeline Scripts<br/>0_template.py โ 23_report.py]
B[๐ง Core Modules<br/>gnn/, render/, llm/]
C[๐ง Utilities<br/>utils/, pipeline/]
D[๐งช Testing<br/>tests/]
end
subgraph "๐ Documentation (doc/)"
E[๐ Core Docs<br/>gnn/, syntax, examples]
F[๐ฏ Specialized<br/>pymdp/, rxinfer/, mcp/]
G[๐งฉ Applications<br/>cognitive_phenomena/]
end
subgraph "๐ฏ Outputs (output/)"
H[๐ Reports<br/>Type checking, analysis]
I[๐จ Visualizations<br/>Graphs, matrices]
J[๐ป Generated Code<br/>PyMDP, RxInfer]
K[๐ Static Site<br/>HTML summaries]
end
end
A --> H
B --> I
B --> J
E --> A
F --> B
G --> B
style A fill:#e3f2fd
style B fill:#f3e5f5
style E fill:#e8f5e8
style H fill:#fff3e0
graph LR
subgraph "Infrastructure Layer"
Utils[utils/]
Pipeline[pipeline/]
end
subgraph "Core Processing"
GNN[gnn/]
TypeChecker[type_checker/]
Validation[validation/]
Export[export/]
end
subgraph "Code Generation"
Render[render/]
Execute[execute/]
end
subgraph "Analysis & Output"
LLM[llm/]
Analysis[analysis/]
Report[report/]
end
Utils --> GNN
Utils --> TypeChecker
Utils --> Render
Pipeline --> GNN
Pipeline --> Render
GNN --> TypeChecker
GNN --> Validation
GNN --> Export
GNN --> Render
Render --> Execute
Execute --> Analysis
LLM --> Analysis
Analysis --> Report
graph TB
subgraph "GNN Input"
GNNFile[GNN Markdown File]
end
subgraph "Parsing & Validation"
Parser[GNN Parser]
Validator[Type Checker]
end
subgraph "Code Generation"
Renderer[Render Module]
PyMDP[PyMDP Generator]
RxInfer[RxInfer.jl Generator]
ActInf[ActiveInference.jl Generator]
JAX[JAX Generator]
DisCoPy[DisCoPy Generator]
end
subgraph "Execution"
Executor[Execute Module]
PyMDPExec[PyMDP Runner]
RxInferExec[RxInfer Runner]
ActInfExec[ActiveInference Runner]
JAXExec[JAX Runner]
end
subgraph "Analysis"
Analyzer[Analysis Module]
Results[Simulation Results]
end
GNNFile --> Parser
Parser --> Validator
Validator --> Renderer
Renderer --> PyMDP
Renderer --> RxInfer
Renderer --> ActInf
Renderer --> JAX
Renderer --> DisCoPy
PyMDP --> Executor
RxInfer --> Executor
ActInf --> Executor
JAX --> Executor
Executor --> PyMDPExec
Executor --> RxInferExec
Executor --> ActInfExec
Executor --> JAXExec
PyMDPExec --> Analyzer
RxInferExec --> Analyzer
ActInfExec --> Analyzer
JAXExec --> Analyzer
Analyzer --> Results
๐ src/ Directory Structure
The src/ directory contains the 24-step pipeline scripts (0_template.py โ 23_report.py), their corresponding modules, and shared infrastructure. See DOCS.md and doc/pipeline/README.md for the full step-by-step mapping.
src/
โโโ ๐ Pipeline Scripts (0-23)
โ โโโ 0_template.py โฆ 23_report.py # Thin orchestrators (0โ23)
โโโ ๐ง Core Modules
โ โโโ gnn/ render/ execute/ llm/ visualization/ export/ type_checker/ ontology/ mcp/
โ โโโ setup/ tests/ website/ audio/ analysis/ integration/ security/ research/ report/
โโโ ๐ง Infrastructure: utils/ pipeline/
โโโ ๐๏ธ Orchestrator: main.py
๐ doc/ Directory Structure
The doc/ directory contains all supplementary documentation, including conceptual explanations, syntax guides, and examples.
doc/
โโโ ๐ Core Documentation
โ โโโ gnn/ # GNN specifications
โ โโโ quickstart.md # Getting started guide
โ โโโ SETUP.md # Installation instructions
โ โโโ README.md # Documentation overview
โโโ ๐ฏ Domain Applications
โ โโโ cognitive_phenomena/ # Cognitive modeling examples
โ โโโ pymdp/ # PyMDP integration
โ โโโ rxinfer/ # RxInfer.jl integration
โ โโโ templates/ # Model templates
โโโ ๐ ๏ธ Technical Integration
โ โโโ mcp/ # Model Context Protocol
โ โโโ llm/ # LLM integration
โ โโโ discopy/ # DisCoPy categorical diagrams
โ โโโ sympy/ # SymPy mathematical processing
โโโ ๐ Resources
โโโ troubleshooting/ # Common issues & solutions
โโโ testing/ # Testing documentation
โโโ security/ # Security guidelines
The GNN processing pipeline consists of 24 comprehensive steps (0-23), each handling a specific aspect of model processing from parsing to final report generation. The pipeline follows a thin orchestrator pattern where numbered scripts orchestrate execution while delegating core functionality to modular components.
flowchart TD
A["๐ Start Pipeline"] --> B["0๏ธโฃ Template Init<br/>src/template/"]
B --> C["1๏ธโฃ Setup & Dependencies<br/>src/setup/"]
C --> D["2๏ธโฃ Tests<br/>src/tests/"]
D --> E["3๏ธโฃ GNN Discovery & Parsing<br/>src/gnn/"]
E --> F["4๏ธโฃ Model Registry<br/>src/model_registry/"]
F --> G["5๏ธโฃ Type Checking<br/>src/type_checker/"]
G --> H["6๏ธโฃ Validation<br/>src/validation/"]
H --> I["7๏ธโฃ Export<br/>src/export/"]
I --> J["8๏ธโฃ Visualization<br/>src/visualization/"]
J --> K["9๏ธโฃ Advanced Viz<br/>src/advanced_visualization/"]
K --> L["1๏ธโฃ0๏ธโฃ Ontology<br/>src/ontology/"]
L --> M["1๏ธโฃ1๏ธโฃ Rendering<br/>src/render/"]
M --> N["1๏ธโฃ2๏ธโฃ Execution<br/>src/execute/"]
N --> O["1๏ธโฃ3๏ธโฃ LLM Analysis<br/>src/llm/"]
O --> P["1๏ธโฃ4๏ธโฃ ML Integration<br/>src/ml_integration/"]
P --> Q["1๏ธโฃ5๏ธโฃ Audio<br/>src/audio/"]
Q --> R["1๏ธโฃ6๏ธโฃ Analysis<br/>src/analysis/"]
R --> S["1๏ธโฃ7๏ธโฃ Integration<br/>src/integration/"]
S --> T["1๏ธโฃ8๏ธโฃ Security<br/>src/security/"]
T --> U["1๏ธโฃ9๏ธโฃ Research<br/>src/research/"]
U --> V["2๏ธโฃ0๏ธโฃ Website<br/>src/website/"]
V --> W["2๏ธโฃ1๏ธโฃ MCP<br/>src/mcp/"]
W --> X["2๏ธโฃ2๏ธโฃ GUI<br/>src/gui/"]
X --> Y["2๏ธโฃ3๏ธโฃ Report<br/>src/report/"]
Y --> Z["โ
Complete"]
style A fill:#e1f5fe
style G fill:#fff3e0,stroke:#ff9800,stroke-width:2px
style Y fill:#e8f5e8,stroke:#4caf50
flowchart TD
subgraph "๐ง GNN Processing Workflow"
A["๐ GNN File Input<br/>.md format"] --> B["๐ Discovery & Parsing<br/>Extract sections"]
B --> C["โ
Type Checking<br/>Validate syntax & structure"]
C --> D["๐ Multi-Format Export<br/>JSON, XML, GraphML, Pickle"]
C --> E["๐จ Visualization<br/>Generate graphs & matrices"]
C --> F["๐ Code Generation<br/>PyMDP, RxInfer & ActiveInference.jl templates"]
F --> G["โถ๏ธ Simulation Execution<br/>Run generated code"]
E --> H["๐ง LLM Analysis<br/>AI-powered insights"]
D --> I["๐ Ontology Mapping<br/>Active Inference terms"]
G --> J["๐ Results Analysis<br/>Performance metrics"]
H --> K["๐ต Audio Generation<br/>SAPF, Pedalboard backends"]
I --> L["๐ Site Generation<br/>Static HTML reports"]
J --> L
K --> M["๐ Report Generation<br/>Comprehensive analysis"]
L --> M
M --> N["โจ Complete Analysis<br/>Multi-modal outputs"]
end
style A fill:#e1f5fe,stroke:#0277bd
style C fill:#fff3e0,stroke:#f57c00
style L fill:#e8f5e8,stroke:#388e3c
flowchart LR
subgraph "Input Stage"
Input[GNN Files]
end
subgraph "Processing Stage"
Step3[Step 3: GNN Parse]
Step5[Step 5: Type Check]
Step6[Step 6: Validation]
Step7[Step 7: Export]
end
subgraph "Generation Stage"
Step8[Step 8: Visualization]
Step11[Step 11: Render]
Step12[Step 12: Execute]
end
subgraph "Analysis Stage"
Step13[Step 13: LLM]
Step16[Step 16: Analysis]
Step23[Step 23: Report]
end
Input --> Step3
Step3 --> Step5
Step3 --> Step6
Step3 --> Step7
Step3 --> Step8
Step3 --> Step11
Step5 --> Step6
Step6 --> Step7
Step7 --> Step8
Step11 --> Step12
Step12 --> Step13
Step12 --> Step16
Step13 --> Step16
Step8 --> Step16
Step16 --> Step23
The GNN framework is built around a modular architecture, where each pipeline step corresponds to a dedicated module. These modules encapsulate specific functionalities and interact with various "agents" (e.g., LLMs, external APIs) to perform their tasks.
| Module Name | Pipeline Step | Description | Key Agents/Integrations |
|---|---|---|---|
template |
0 | Initializes pipeline, sets up environment, and loads configuration. | Configuration Manager, Environment Setup |
setup |
1 | Manages dependencies, virtual environments, and system checks. | uv, pip, System Utilities |
tests |
2 | Executes unit, integration, and end-to-end tests. | pytest, coverage.py |
gnn |
3 | Discovers, parses, and validates GNN markdown files. | Markdown Parser, Schema Validator |
model_registry |
4 | Manages a central registry of GNN models and their metadata. | Database (SQLite), Model Metadata |
type_checker |
5 | Performs static analysis, type checking, and resource estimation. | Type Inference Engine, Resource Estimator |
validation |
6 | Validates GNN models against predefined rules and constraints. | Constraint Solver, Logic Validator |
export |
7 | Exports GNN models to various formats (JSON, XML, GraphML). | JSON/XML/GraphML Serializers |
visualization |
8 | Generates graphical representations of GNN models. | matplotlib, plotly, graphviz |
advanced_visualization |
9 | Provides advanced, interactive 3D and dynamic visualizations. | vedo, pyvista, dash |
ontology |
10 | Maps GNN concepts to Active Inference ontology terms. | Ontology Mapper, Knowledge Graph |
render |
11 | Renders GNN models into executable code for various backends. | Code Generators (PyMDP, RxInfer, ActInf.jl) |
execute |
12 | Executes the rendered code using the specified backend. | PyMDP, RxInfer.jl, ActiveInference.jl |
llm |
13 | Integrates Large Language Models for analysis, generation, and insights. | OpenAI GPT, Anthropic Claude, Local LLMs |
ml_integration |
14 | Integrates with machine learning frameworks for advanced analysis. | scikit-learn, tensorflow, pytorch |
audio |
15 | Generates audio representations of GNN model dynamics. | SAPF, Pedalboard, Audio Synthesis Engines |
analysis |
16 | Performs statistical and qualitative analysis of execution results. | pandas, scipy, Statistical Models |
integration |
17 | Manages external system integrations and data exchange. | REST APIs, Message Queues |
security |
18 | Implements security checks, vulnerability scanning, and access control. | SAST Tools, Security Scanners |
research |
19 | Supports research-specific tasks like hypothesis testing and data collection. | Experimentation Frameworks |
website |
20 | Generates static websites or documentation portals from GNN outputs. | Static Site Generators (e.g., MkDocs) |
mcp |
21 | Implements the Model Context Protocol for inter-model communication. | Protocol Handlers, Message Brokers |
gui |
22 | Provides interactive graphical user interfaces for model creation and editing. | gradio, streamlit, dash |
report |
23 | Generates comprehensive reports summarizing the pipeline execution. | Report Generators (PDF, HTML) |
The pipeline follows a three-tier architectural pattern (Script -> Interface -> Processor) for high maintainability and testability.
graph TB
subgraph "Tier 1: Orchestrator Layer"
Script[N_Module.py<br/>Thin Orchestrator]
end
subgraph "Tier 2: Interface Layer"
Init[__init__.py<br/>Public API]
end
subgraph "Tier 3: Implementation Layer"
Processor[processor.py<br/>Core Logic]
Framework[framework/<br/>Adapters]
MCP[mcp.py<br/>Tools]
end
Script -->|Calls| Init
Init -->|Delegates| Processor
Processor -->|Uses| Framework
Processor -->|Registers| MCP
style Script fill:#e3f2fd,stroke:#1565c0
style Init fill:#f3e5f5,stroke:#7b1fa2
style Processor fill:#fff3e0,stroke:#e65100
- Main Pipeline Orchestrator (
src/main.py): Central coordinator that executes numbered scripts in sequence. - Thin Orchestrators (
src/0_template.py,src/1_setup.py, etc.): Minimal scripts (<150 lines) that handle CLI args and logging, then delegate immediately. - Modular Scripts (
src/template/,src/setup/, etc.): The actual "brains" of the operation, containingprocessor.py, logic, and specialized tests.
โ Compliant Scripts (7/23):
src/0_template.pyโsrc/template/src/1_setup.pyโsrc/setup/src/6_validation.pyโsrc/validation/src/7_export.pyโsrc/export/src/8_visualization.pyโsrc/visualization/src/10_ontology.pyโsrc/ontology/src/11_render.pyโsrc/render/
๐ Pending Refactoring (16/23):
src/2_tests.pyโsrc/tests/(8 functions)src/3_gnn.pyโsrc/gnn/(1 function)src/4_model_registry.pyโsrc/model_registry/(3 functions)src/5_type_checker.pyโsrc/type_checker/(4 functions)src/9_advanced_viz.pyโsrc/advanced_visualization/(10 functions)src/12_execute.pyโsrc/execute/(14 functions)- And 10 more scripts...
src/
โโโ main.py # Main pipeline orchestrator
โโโ 0_template.py # Thin orchestrator - imports from template/
โโโ template/ # Modular template implementation
โ โโโ __init__.py # Module exports and initialization
โ โโโ processor.py # Core template processing logic
โ โโโ mcp.py # Model Context Protocol integration
โโโ tests/
โโโ test_template_integration.py # Tests for template module
For comprehensive architectural documentation, see:
src/template/README.md: Reference implementation and pattern documentationARCHITECTURE.md: Complete architectural guide
Navigate to the project's root directory and execute:
python src/main.py [options]| Option | Description | Default |
|---|---|---|
--target-dir DIR |
Target directory for GNN files | input/gnn_files |
--output-dir DIR |
Directory to save outputs | output/ |
--recursive |
Recursively process directories | True |
--skip-steps LIST |
Skip specific steps (e.g., "1,7") | None |
--only-steps LIST |
Run only specific steps | None |
--verbose |
Enable detailed logging | False |
--strict |
Enable strict type checking | False |
--estimate-resources |
Estimate computational resources | True |
๐ View All Pipeline Options
python src/main.py --helpAdditional specialized options:
--ontology-terms-file FILE: Path to ontology terms file--llm-tasks LIST: Comma-separated LLM tasks--llm-timeout: LLM processing timeout--pipeline-summary-file FILE: Pipeline summary report path--site-html-filename NAME: Generated HTML site filename--duration: Audio duration for audio generation (default: 30.0)--audio-backend: Audio backend to use (auto, sapf, pedalboard, default: auto)--recreate-uv-env: Recreate UV environment--dev: Install development dependencies
The GNN ecosystem includes several sophisticated tools to aid in model development, validation, and understanding. These tools are primarily invoked through the src/main.py pipeline script.
The GNN Type Checker (pipeline step 5) helps validate GNN files and estimates computational resources.
# Run only type checker
python src/main.py --only-steps 5 --target-dir path/to/gnn_files
# Include resource estimation
python src/main.py --only-steps 5 --estimate-resources --target-dir path/to/gnn_files
# Run full pipeline
python src/main.py --target-dir path/to/gnn_files- โ Validation of required sections and structure
- ๐ Type checking of variables and dimensions
- ๐ Verification of connections and references
- ๐ Detailed error reports with suggestions for fixes
- ๐พ Resource usage estimation and optimization recommendations
When executed, the type checker writes to output/5_type_checker_output/:
output/5_type_checker_output/
โโโ type_check_results.json
โโโ type_check_summary.json
โโโ global_type_analysis.json
GNN files can be visualized to create comprehensive graphical representations of models (pipeline step 8).
# Generate visualizations
python src/main.py --only-steps 8 --target-dir path/to/gnn_file.md- ๐ Network Graphs: Model structure and dependencies
- ๐จ Matrix Heatmaps: A, B, C, D matrix visualizations
- ๐ง Ontology Diagrams: Active Inference relationship maps
- ๐ Performance Plots: Resource usage and timing analysis
GNN provides three distinct interactive GUI interfaces for visual model construction and editing (pipeline step 22).
| GUI | Focus | Port | Key Features |
|---|---|---|---|
| GUI 1 | Form-based Constructor | :7860 |
Step-by-step model building, component management |
| GUI 2 | Visual Matrix Editor | :7861 |
Real-time heatmaps, interactive matrix editing |
| GUI 3 | Design Studio | :7862 |
State space design, ontology editing, low-dependency |
| oxdraw | Diagram-as-Code | :5151 |
Mermaid-based visual editing, GNN โ diagram sync |
# Launch all GUIs (recommended)
python src/22_gui.py --target-dir input/gnn_files --output-dir output --gui-types "gui_1,gui_2,gui_3,oxdraw" --interactive --verbose
# Launch specific GUI
python src/22_gui.py --gui-types "gui_3" --interactive --verbose # Design Studio only
python src/22_gui.py --gui-types "oxdraw" --interactive --verbose # oxdraw only
# Launch via main pipeline (headless mode)
python src/main.py --only-steps 22 --verbose๐ง GUI 1: Form-based Constructor (http://localhost:7860)
- Interactive two-pane editor for systematic GNN model construction
- Component management (observation/hidden/action/policy variables)
- State space entry management with live validation
- Synchronized plaintext GNN markdown editor
๐ GUI 2: Visual Matrix Editor (http://localhost:7861)
- Real-time matrix heatmap visualizations with Plotly
- Interactive DataFrame editing with +/- dimension controls
- Vector bar chart displays for C & D vectors
- Live matrix statistics (min, max, mean, sum)
- Auto-update functionality and matrix validation
๐จ GUI 3: State Space Design Studio (http://localhost:7862)
- Visual state space architecture designer with SVG diagrams
- Ontology term editor for Active Inference concept mapping
- Interactive connection graph interface (D>s, s-A, A-o format)
- Parameter tuning controls (states, observations, actions, horizons)
- Real-time GNN export and preview with low-dependency approach
output/22_gui_output/
โโโ gui_1_output/ # Form-based constructor outputs
โ โโโ constructed_model_gui_1.md
โ โโโ gui_status.json
โโโ gui_2_output/ # Visual matrix editor outputs
โ โโโ visual_model_gui_2.md
โ โโโ visual_matrices.json
โโโ gui_3_output/ # Design studio outputs
โ โโโ designed_model_gui_3.md
โ โโโ design_analysis.json
โโโ gui_processing_summary.json
New to GNN? Choose your learning path:
- โก Quick Demo (5 min): See GNN in action โ 5-Minute Demo
- ๐ฌ I'm a Researcher: Theory-first approach โ Research Path
- ๐ป I'm a Developer: Code-first approach โ Developer Path
- ๐ I'm Learning: Structured curriculum โ Academic Path
๐ Need guidance choosing? โ Complete Learning Paths Guide
1๏ธโฃ Prerequisites
Ensure you have Python 3.11+ installed:
python --version # Should show 3.11 or higher2๏ธโฃ Clone Repository
git clone https://github.com/ActiveInferenceInstitute/GeneralizedNotationNotation.git
cd GeneralizedNotationNotation3๏ธโฃ Setup Environment
Run the setup pipeline step to configure dependencies:
python src/main.py --only-steps 1 --devThis will:
- โ Create and configure virtual environment
- ๐ฆ Install all required dependencies
- ๐งช Install development dependencies (with
--dev) - โ Validate system requirements
4๏ธโฃ Enhanced Visual Output (Optional)
The pipeline includes enhanced visual logging for better accessibility:
# Run with visual enhancements (recommended)
python src/main.py --verbose
# Run with compact visual mode for narrow terminals
python src/main.py --verbose --compact
# Run with timestamps for detailed logging
python src/main.py --verbose --timestampsVisual Features:
- ๐จ Color-coded status indicators (green=success, yellow=warning, red=error)
- ๐ Progress bars and completion indicators
- ๐ข Step-by-step visual progress with correlation IDs
- ๐ Structured summary tables with key metrics
- โฟ Screen reader friendly output (emoji can be disabled)
- โฑ๏ธ Performance timing and memory usage tracking
5๏ธโฃ Run Your First Pipeline (using uv)
Use uv to run the pipeline inside the managed project environment:
uv sync # ensure dependencies from pyproject.toml are installed
uv run python src/main.py -- --target-dir input/gnn_files --verboseYou can also run individual commands under uv (recommended):
uv run pytest # run tests inside uv-managed venv
uv run python -m pytest5๏ธโฃ Explore Results
Check the generated outputs in the output/ directory. The static site is under the numbered website folder:
ls -la output/
open output/20_website_output/website/index.html # macOS
# or
xdg-open output/20_website_output/website/index.html # Linux๐ Common Issues & Solutions
๐ Python Version Issues
# Check Python version
python --version
# If < 3.8, install Python 3.8+ from python.org๐ฆ Dependency Issues
# Force reinstall dependencies
uv run python src/main.py --only-steps 2 --recreate-uv-env --dev๐ง Pipeline Failures
# Run with verbose logging
python src/main.py --verbose
# Check specific step
python src/main.py --only-steps 5 --verbose๐พ Disk Space Issues
# Check available space
df -h
# Clean output directory
rm -rf output/*๐ Get Support:
- ๐ Documentation: See Documentation section below
- ๐ Known Issues: Check troubleshooting guide
- ๐ฌ Community: Open an issue on GitHub
- ๐ Quick Fix: Try
python src/main.py --only-steps 2 --devfirst
Comprehensive documentation is organized in the doc/ directory.
Tip
Start Here for Architecture:
| Document | Description |
|---|---|
| AGENTS.md | MUST READ: The master guide to all pipeline agents and modules. |
| DOCS.md | High-level system architecture and comprehensive documentation index. |
| GNN Overview | High-level introduction to the GNN language. |
| Syntax Guide | Detailed GNN syntax specification. |
| File Structure | Guide to GNN file organization. |
| Quick Start Tutorial | Step-by-step beginner guide. |
| Architecture Guide | Implementation, extension patterns, and system design. |
| Machine-Readable Indices | API index and generator. |
| Topic | Documentation |
|---|---|
| ๐ง Active Inference | About GNN |
| ๐ค LLM Integration | LLM & Neurosymbolic AI |
| ๐ Implementation | Implementation Guide |
| ๐ ๏ธ Tools | Tools & Resources |
| ๐ Research Paper | Academic Paper Details |
| Platform | Documentation |
|---|---|
| ๐ PyMDP | PyMDP Integration |
| ๐ฌ RxInfer.jl | RxInfer Integration |
| ๐ง ActiveInference.jl | ActiveInference.jl Integration |
| ๐ก MCP | Model Context Protocol |
| ๐งฎ SymPy | Mathematical Processing |
| ๐ DisCoPy | Categorical Diagrams |
| Domain | Examples |
|---|---|
| ๐ง Cognitive Phenomena | Cognitive Models |
| ๐ฏ Templates | Model Templates |
| ๐ Configuration | Configuration Examples |
Explore practical GNN implementations and use cases:
- ๐ Primary Examples:
src/gnn/gnn_examples/ - ๐ Cognitive Models:
doc/cognitive_phenomena/ - ๐ Templates:
doc/templates/
| Example | Description | Location |
|---|---|---|
| ๐ฏ PyMDP POMDP Agent | Complete POMDP implementation | src/gnn/gnn_examples/actinf_pomdp_agent.md |
| ๐ฌ RxInfer Hidden Markov Model | Probabilistic sequence modeling | doc/archive/rxinfer_hidden_markov_model.md |
| ๐ง ActiveInference.jl Examples | Julia-based Active Inference models | doc/activeinference_jl/actinf_jl_src/ |
| ๐ค Multi-Agent System | Collaborative agent modeling | doc/archive/rxinfer_multiagent_gnn.md |
| Phenomenon | Model | Documentation |
|---|---|---|
| ๐ฏ Attention | Attention mechanisms | doc/cognitive_phenomena/attention/ |
| ๐ง Consciousness | Global workspace theory | doc/cognitive_phenomena/consciousness/ |
| ๐ช Cognitive Effort | Effort and control | doc/cognitive_phenomena/effort/ |
| โค๏ธ Emotion & Affect | Interoceptive emotion | doc/cognitive_phenomena/emotion_affect/ |
| ๐ฎ Executive Control | Task switching | doc/cognitive_phenomena/executive_control/ |
# Process all examples
python src/main.py --target-dir src/gnn/gnn_examples
# Process specific example
python src/main.py --target-dir src/gnn/gnn_examples/actinf_pomdp_agent.md
# Process with full analysis
python src/main.py --target-dir src/gnn/gnn_examples --estimate-resources --verbose๐ Advanced Usage Patterns
๐ฅ Quick Commands
# Full pipeline with all features
python src/main.py --verbose --estimate-resources --dev
# Type check only (fastest validation)
python src/main.py --only-steps 5 --strict
# Visualization only (quick preview)
python src/main.py --only-steps 8
# Complete analysis for single file
python src/main.py --target-dir path/to/file.md --verbose๐ฏ Pipeline Optimization
# Skip time-consuming steps for quick iteration
python src/main.py --skip-steps "11,12,13"
# Focus on core processing
python src/main.py --only-steps "1,4,5,6"
# Development workflow
python src/main.py --only-steps "2,3" --dev๐ Output Management
# Custom output directory
python src/main.py -o /path/to/custom/output
# Timestamped outputs
python src/main.py -o "output/run_$(date +%Y%m%d_%H%M%S)"The GNN project maintains high standards for code quality, testing, and documentation.
| Metric | Status | Details |
|---|---|---|
| Pipeline Success | โ 100% | 24/24 steps passing |
| Tests Passing | โ 579/579 | 3 skipped (service-dependent), 56 skipped (optional deps) |
| Execution Time | โฑ๏ธ ~3 min | Full pipeline in under 3 minutes |
| Memory Usage | ๐พ 36 MB peak | Efficient resource consumption |
| Module Coverage | ๐ 74-95% | Median ~82% test coverage |
| Documentation | ๐ 100% | All 28 modules have AGENTS.md |
# Run comprehensive test suite
python src/2_tests.py --comprehensive
# Run fast pipeline tests (default)
python src/2_tests.py
# Check test coverage
pytest --cov=src --cov-report=term-missing
# Run specific module tests
pytest src/tests/test_[module]*.py -vTest Configuration: See pytest.ini for complete test settings.
| File | Purpose |
|---|---|
| pyproject.toml | Project metadata, dependencies, and build configuration |
| pytest.ini | Test suite configuration with markers and coverage settings |
| input/config.yaml | Pipeline default configuration |
| Dockerfile | Container image definition |
- Security Policy: See SECURITY.md for vulnerability reporting
- Code of Conduct: See CODE_OF_CONDUCT.md
- Contributing Guidelines: See CONTRIBUTING.md
GNN is an evolving standard, and contributions are welcome! Here's how you can get involved:
- ๐ Report Issues: Found a bug? Open an issue
- ๐ก Suggest Features: Have ideas? Start a discussion
- ๐ Improve Documentation: Help make our docs better
- ๐งช Add Examples: Share your GNN models
- ๐ง Code Contributions: Submit pull requests
- ๐ด Fork the repository
- ๐ฟ Create a feature branch (
git checkout -b feature/amazing-feature) - โ Test your changes thoroughly
- ๐ Document your changes
- ๐พ Commit with clear messages (
git commit -m 'Add amazing feature') - ๐ค Push to your branch (
git push origin feature/amazing-feature) - ๐ Submit a Pull Request
Please read our Code of Conduct to understand the standards we maintain for our community.
- ๐ Documentation: Check the docs first
- ๐ฌ Discussions: Use GitHub Discussions
- ๐ Issues: For bugs, use GitHub Issues
- ๐ง Contact: Reach out to the maintainers
All contributors will be recognized in our contributors list and release notes.
This project is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0). See LICENSE.md for full terms.
- โ Attribution required
- โ Adaptation/Redistribution permitted under the same license
- โ Private use permitted
- โ Commercial use not permitted without explicit permission
- โ Include license and changes notice in redistributions
- ๐ Active Inference Institute: activeinference.institute
- ๐ฌ Community Discussions: Active Inference Discord
- ๐ PyMDP Framework: github.com/infer-actively/pymdp
- ๐ฌ RxInfer.jl: github.com/biaslab/RxInfer.jl
- ๐ง ActiveInference.jl: github.com/ComputationalPsychiatry/ActiveInference.jl
- ๐ DisCoPy: github.com/oxford-quantum-group/discopy
- ๐ Research Papers: Active Inference on arXiv