A standardized text-based language for Active Inference generative models
๐ Quick Start โข ๐ Documentation โข ๐ฏ Examples โข ๐ ๏ธ Tools โข ๐ค Contributing
- ๐ Overview
- ๐ฏ Motivation and Goals
- โจ Key Features
- ๐๏ธ Project Architecture
- โ๏ธ Processing Pipeline
- ๐ ๏ธ Tools and Utilities
- ๐ Quick Start
- ๐ Documentation
- ๐ฏ Examples
- ๐ค 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.
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
graph TB
subgraph "๐๏ธ GNN Project Architecture"
subgraph "๐ Source Code (src/)"
A[โ๏ธ Pipeline Scripts<br/>0_template.py โ 22_mcp.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
๐ src/ Directory Structure
The src/
directory contains the 23-step pipeline scripts (0_template.py
โ 22_mcp.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-22)
โ โโโ 0_template.py โฆ 22_mcp.py # Thin orchestrators (0โ22)
โโโ ๐ง 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 23 comprehensive steps (0-22), 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๏ธโฃ Report<br/>src/report/"]
W --> X["2๏ธโฃ2๏ธโฃ MCP<br/>src/mcp/"]
X --> Y["โ
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
The pipeline follows a three-tier architectural pattern for maintainability and modularity:
main.py โ Numbered Scripts (Thin Orchestrators) โ Modular Scripts in Folders
- 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 that delegate to modules - Modular Scripts (
src/template/
,src/setup/
, etc.): Core functionality implementation
โ 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 | src/gnn/examples |
--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
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 4) helps validate GNN files and estimates computational resources.
# Run only type checker
python src/main.py --only-steps 4 --target-dir path/to/gnn_files
# Include resource estimation
python src/main.py --only-steps 4 --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 6).
# Generate visualizations
python src/main.py --only-steps 6 --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
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.8+ installed:
python --version # Should show 3.8 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๏ธโฃ Run Your First Pipeline
Process the example GNN files:
python src/main.py --target-dir src/gnn/examples --verbose
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
๐ 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 4 --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
Comprehensive documentation is organized in the doc/
directory. Here are the key resources:
Document | Description |
---|---|
GNN Overview | High-level introduction to GNN |
Syntax Guide | Detailed GNN syntax specification |
File Structure | GNN file organization guide |
Quick Start Tutorial | Step-by-step beginner guide |
Comprehensive Project Docs | Full architecture, pipeline, and dataflow diagrams |
Architecture Guide | Implementation-oriented architecture and extension patterns |
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/examples/
- ๐ Cognitive Models:
doc/cognitive_phenomena/
- ๐ Templates:
doc/templates/
Example | Description | Location |
---|---|---|
๐ฏ PyMDP POMDP Agent | Complete POMDP implementation | src/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/examples
# Process specific example
python src/main.py --target-dir src/gnn/examples/actinf_pomdp_agent.md
# Process with full analysis
python src/main.py --target-dir src/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 4 --strict
# Visualization only (quick preview)
python src/main.py --only-steps 6
# 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)"
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 the MIT License. See the LICENSE.md file for full details.
- โ Commercial use permitted
- โ Modification permitted
- โ Distribution permitted
- โ Private use permitted
- โ License and copyright notice required
- ๐ 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