# mackelab/simformer architecture

> Architecture diagram of the GitHub repository mackelab/simformer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mackelab/simformer
- Repository: https://github.com/mackelab/simformer

## Overview

##### Main Components
The system should be divided into these key components:

a) Core Framework Layer:
- Subcomponents for:
- Custom Primitives
- Interpreters
- JAX Propagation
- Distributions
- Neural Network Components
- Inference Methods

b) Simulation-Based Inference Layer:
- `scoresbibm` as the main application layer
- Components for:
- Tasks (Various inference problems)
- Methods (Different inference approaches)
- Evaluation
- Configuration Management

##### Component Relationships

- Dependencies from Methods to Core Framework components
- Configuration management affecting all components

##### Detailed Component Breakdown

For each major component, include:

a) Core Framework (probjax):
**┌─ Core Framework ─────────────────┐**
- ┌─ Primitives ┐ ┌─ Interpreters┐│
- RV        │ │- Constraints ││
- Custom    │ │- Inverse    ││
- ┘ └─────────────┘│
- ┌─ Distributions ┐ ┌─ NN ─────┐│
- Continuous   │ │- Attention││
- Discrete    │ │- Bijective││
- ┘ └───────────┘│
- ┘

b) Inference Layer (scoresbibm):
**┌─ Simulation-Based Inference ────┐**
- ┌─ Tasks ─┐ ┌─ Methods ───────┐│
- SBIBM  │ │- Score SBI     ││
- Custom │ │- Transformers  ││
- ┘ └────────────────┘│
- ┌─ Evaluation ┐ ┌─ Config ───┐│
- Metrics   │ │- Hydra     ││
- Analysis  │ │- YAML      ││
- ┘ └────────────┘│
- ┘

##### Key Elements to Highlight

- Data flow from simulation tasks through the inference methods
- Transformer architecture's role
- Configuration management's influence
- Evaluation feedback loops

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef core fill:#b3d1ff,stroke:#333,stroke-width:2px
    classDef inference fill:#98fb98,stroke:#333,stroke-width:2px
    classDef task fill:#ffeb99,stroke:#333,stroke-width:2px
    classDef eval fill:#ffc266,stroke:#333,stroke-width:2px
    classDef config fill:#e6b3ff,stroke:#333,stroke-width:2px
    classDef util fill:#e6e6e6,stroke:#333,stroke-width:2px

    %% Core Framework Layer
    subgraph CoreFramework["Core Framework Layer"]
        Primitives["Custom Primitives"]:::core
        Interpreters["Interpreters"]:::core
        JAXProp["JAX Propagation"]:::core
        Distributions["Distributions"]:::core
        NeuralNet["Neural Network Components"]:::core
        InferenceMethods["Inference Methods"]:::core
    end

    %% SBI Layer
    subgraph SBILayer["Simulation-Based Inference Layer"]
        Tasks["Tasks"]:::task
        Methods["Methods"]:::inference
        Evaluation["Evaluation"]:::eval
    end

    %% Configuration
    Config["Configuration Management"]:::config

    %% Relationships
    Tasks --> Methods
    Methods <--> Evaluation
    Methods --> InferenceMethods
    Methods --> NeuralNet
    Methods --> Distributions
    Config --> Tasks
    Config --> Methods
    Config --> Evaluation
    
    %% Component Mappings
    click Primitives "https://github.com/mackelab/simformer/tree/main/src/probjax/probjax/core/custom_primitives/"
    click Interpreters "https://github.com/mackelab/simformer/tree/main/src/probjax/probjax/core/interpreters/"
    click JAXProp "https://github.com/mackelab/simformer/tree/main/src/probjax/probjax/core/jaxpr_propagation/"
    click Distributions "https://github.com/mackelab/simformer/tree/main/src/probjax/probjax/distributions/"
    click NeuralNet "https://github.com/mackelab/simformer/tree/main/src/probjax/probjax/nn/"
    click InferenceMethods "https://github.com/mackelab/simformer/tree/main/src/probjax/probjax/inference/"
    click Tasks "https://github.com/mackelab/simformer/tree/main/src/scoresbibm/scoresbibm/tasks/"
    click Methods "https://github.com/mackelab/simformer/tree/main/src/scoresbibm/scoresbibm/methods/"
    click Evaluation "https://github.com/mackelab/simformer/tree/main/src/scoresbibm/scoresbibm/evaluation/"
    click Config "https://github.com/mackelab/simformer/tree/main/src/scoresbibm/config/"

    %% Legend
    subgraph Legend
        L1["Core Framework"]:::core
        L2["Inference"]:::inference
        L3["Tasks"]:::task
        L4["Evaluation"]:::eval
        L5["Configuration"]:::config
    end
```
