Skip to content

ActiveInferenceInstitute/GeneralizedNotationNotation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

GeneralizedNotationNotation (GNN)

Last Updated: 2026-01-09

License: CC BY-NC-SA 4.0 Python 3.11+ Active Inference DOI Pipeline Steps Latest Run Tests Mermaid Diagrams Documentation

A standardized text-based language for Active Inference generative models

๐Ÿš€ Quick Start โ€ข ๐Ÿ“– Documentation โ€ข ๐ŸŽฏ Examples โ€ข ๐Ÿ› ๏ธ Tools โ€ข ๐Ÿค Contributing


๐Ÿ“‹ Table of Contents


๐ŸŒŸ Overview

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.

๐Ÿ“š Initial Publication

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

๐ŸŽฏ Core Design Principles

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.


๐Ÿ“ Key Files

๐Ÿš€ 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

๐Ÿ“‚ Directory Overview

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

๐Ÿงฉ Modules & Agents

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

๐ŸŽฏ Motivation and Goals

๐Ÿšซ Current Challenges

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

๐ŸŽฏ Our Goals

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

โœจ Key Features

๐ŸŽญ The Triple Play Approach

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
Loading
  1. ๐Ÿ“ 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.

  2. ๐Ÿ“Š 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.

  3. โš™๏ธ 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.

๐Ÿ“‹ Structured File Format

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

๐Ÿ“ GNN Syntax Preview

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=Observation

Connection 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


๐Ÿ—๏ธ Project Architecture

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
Loading

Module Dependency Graph

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
Loading

Framework Integration Architecture

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
Loading

๐Ÿ“ Directory Structure

๐Ÿ“‚ 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

โš™๏ธ Processing Pipeline

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
Loading

๐ŸŽฏ GNN Processing Workflow

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
Loading

Data Flow Between Pipeline Steps

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
Loading

๐Ÿง  Modules & Agents

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)

๐Ÿ—๏ธ Pipeline Architecture: Three-Tier Pattern

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
Loading

๐Ÿ›๏ธ Architectural Components

  1. Main Pipeline Orchestrator (src/main.py): Central coordinator that executes numbered scripts in sequence.
  2. Thin Orchestrators (src/0_template.py, src/1_setup.py, etc.): Minimal scripts (<150 lines) that handle CLI args and logging, then delegate immediately.
  3. Modular Scripts (src/template/, src/setup/, etc.): The actual "brains" of the operation, containing processor.py, logic, and specialized tests.

๐Ÿ“‹ Current Status

โœ… 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...

๐Ÿ“ Example Structure

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

๐Ÿ“š Documentation

For comprehensive architectural documentation, see:

  • src/template/README.md: Reference implementation and pattern documentation
  • ARCHITECTURE.md: Complete architectural guide

๐Ÿš€ Running the Pipeline

Navigate to the project's root directory and execute:

python src/main.py [options]

๐Ÿ› ๏ธ Key Pipeline 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 --help

Additional 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

๐Ÿ› ๏ธ Tools and Utilities

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.

โœ… Type Checker and Resource Estimator

The GNN Type Checker (pipeline step 5) helps validate GNN files and estimates computational resources.

๐ŸŽฏ Quick Usage

# 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

๐Ÿ“Š Features

  • โœ… 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

๐Ÿ“ Output Structure

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

๐ŸŽจ Visualization

GNN files can be visualized to create comprehensive graphical representations of models (pipeline step 8).

๐ŸŽฏ Usage

# Generate visualizations
python src/main.py --only-steps 8 --target-dir path/to/gnn_file.md

๐Ÿ–ผ๏ธ Visualization Types

  • ๐Ÿ“Š 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

๐ŸŽฎ Interactive GUI Interfaces

GNN provides three distinct interactive GUI interfaces for visual model construction and editing (pipeline step 22).

๐ŸŽฏ GUI Overview

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

๐Ÿš€ Quick Launch

# 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 Details

๐Ÿ”ง 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

๐Ÿ“ GUI Output Structure

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

๐Ÿš€ Quick Start

New to GNN? Choose your learning path:

๐ŸŽฏ Choose Your Journey

  • โšก 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

๐Ÿ› ๏ธ Direct Installation (if you know what you want)

1๏ธโƒฃ Prerequisites

Ensure you have Python 3.11+ installed:

python --version  # Should show 3.11 or higher

2๏ธโƒฃ Clone Repository

git clone https://github.com/ActiveInferenceInstitute/GeneralizedNotationNotation.git
cd GeneralizedNotationNotation

3๏ธโƒฃ Setup Environment

Run the setup pipeline step to configure dependencies:

python src/main.py --only-steps 1 --dev

This 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 --timestamps

Visual 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 --verbose

You can also run individual commands under uv (recommended):

uv run pytest          # run tests inside uv-managed venv
uv run python -m pytest

5๏ธโƒฃ 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

๐Ÿ†˜ Need Help?

๐Ÿ” 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 --dev first

๐Ÿ“– Documentation

Comprehensive documentation is organized in the doc/ directory.

Tip

Start Here for Architecture:

  • AGENTS.md: Master Agent Scaffolding - Detailed breakdown of every pipeline module and its agentic responsibilities.
  • DOCS.md: Comprehensive Project Docs - Full architecture, high-level diagrams, and integration points.

๐Ÿ“š Core Documentation

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.

๐ŸŽฏ Specialized Guides

Topic Documentation
๐Ÿง  Active Inference About GNN
๐Ÿค– LLM Integration LLM & Neurosymbolic AI
๐Ÿ“Š Implementation Implementation Guide
๐Ÿ› ๏ธ Tools Tools & Resources
๐Ÿ“„ Research Paper Academic Paper Details

๐ŸŽฏ Integration Guides

Platform Documentation
๐Ÿ PyMDP PyMDP Integration
๐Ÿ”ฌ RxInfer.jl RxInfer Integration
๐Ÿง  ActiveInference.jl ActiveInference.jl Integration
๐Ÿ“ก MCP Model Context Protocol
๐Ÿงฎ SymPy Mathematical Processing
๐Ÿ”„ DisCoPy Categorical Diagrams

๐Ÿงฉ Application Examples

Domain Examples
๐Ÿง  Cognitive Phenomena Cognitive Models
๐ŸŽฏ Templates Model Templates
๐Ÿ“‹ Configuration Configuration Examples

๐ŸŽฏ Examples

Explore practical GNN implementations and use cases:

๐Ÿ“‚ Example Files Location

๐Ÿ”ฅ Featured Examples

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

๐Ÿง  Cognitive Phenomena Examples

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/

๐Ÿƒโ€โ™‚๏ธ Running Examples

# 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

โšก Power User Tips

๐Ÿš€ 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)"

๐Ÿ’š Repository Health

The GNN project maintains high standards for code quality, testing, and documentation.

๐Ÿ“Š Current Metrics (2026-01-08)

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

๐Ÿงช Testing Infrastructure

# 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 -v

Test Configuration: See pytest.ini for complete test settings.

๐Ÿ“‹ Configuration Files

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 & Quality


๐Ÿค Contributing

GNN is an evolving standard, and contributions are welcome! Here's how you can get involved:

๐ŸŽฏ Ways to Contribute

  • ๐Ÿ› 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

๐Ÿ“‹ Contribution Guidelines

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒฟ Create a feature branch (git checkout -b feature/amazing-feature)
  3. โœ… Test your changes thoroughly
  4. ๐Ÿ“ Document your changes
  5. ๐Ÿ’พ Commit with clear messages (git commit -m 'Add amazing feature')
  6. ๐Ÿ“ค Push to your branch (git push origin feature/amazing-feature)
  7. ๐Ÿ”„ Submit a Pull Request

๐Ÿ›ก๏ธ Code of Conduct

Please read our Code of Conduct to understand the standards we maintain for our community.

๐Ÿ“ž Getting Help

  • ๐Ÿ“– Documentation: Check the docs first
  • ๐Ÿ’ฌ Discussions: Use GitHub Discussions
  • ๐Ÿ› Issues: For bugs, use GitHub Issues
  • ๐Ÿ“ง Contact: Reach out to the maintainers

๐Ÿ™Œ Recognition

All contributors will be recognized in our contributors list and release notes.


๐Ÿ“„ License

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.

๐Ÿ“‹ License Summary

  • โœ… 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

๐Ÿ”— External Resources & Links

๐ŸŒ Active Inference Community

๐Ÿ› ๏ธ Technical Resources


Built by the Active Inference community

โฌ†๏ธ Back to top

About

No description or website provided.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •