# rachtsingh/ibp_vae architecture

> Architecture diagram of the GitHub repository rachtsingh/ibp_vae, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rachtsingh/ibp_vae
- Repository: https://github.com/rachtsingh/ibp_vae

## Overview

This is a research implementation of structured variational autoencoders for beta–Bernoulli/Indian Buffet Process latent-variable models. The main workflow selects a dataset and one of four model/trainer variants, trains and evaluates it with ELBO or IWAE objectives, and saves model checkpoints and metric curves. The graph preserves the four documented-by-code model variants and shared inference/math layers. Relationships for unsampled modules rely on the SOURCE INDEX or README; uncertain implementation details are omitted.

Main entry points: [`scripts/common.py`](https://github.com/rachtsingh/ibp_vae/blob/master/scripts/common.py) (Experiment runner), [`src/training/common.py`](https://github.com/rachtsingh/ibp_vae/blob/master/src/training/common.py) (Training objectives), [`src/models/MFBBVI.py`](https://github.com/rachtsingh/ibp_vae/blob/master/src/models/MFBBVI.py) (MF BBVI model), [`src/models/S_IBP_BBVI.py`](https://github.com/rachtsingh/ibp_vae/blob/master/src/models/S_IBP_BBVI.py) (S-IBP BBVI model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Training workflow"]
  node_entrypoints["Run entrypoints"]
  node_runner["Experiment runner<br/>[common.py]"]
  node_mfbbvi_train["MF BBVI training<br/>[mf_bbvi.py]"]
  node_mfconcrete_train["MF Concrete training<br/>[mf_concrete.py]"]
  node_sibpbbvi_train["S-IBP BBVI training<br/>[s_ibp_bbvi.py]"]
  node_sibpconcrete_train["S-IBP Concrete training<br/>[s_ibp_concrete.py]"]
  node_checkpoint["Checkpoints and curves<br/>[utils.py]"]
end

subgraph group_data["Data sources"]
  node_fixed_data["Binarized MNIST"]
  node_omniglot["Omniglot data<br/>[omniglot.py]"]
  node_other_datasets["Other dataset loaders"]
end

subgraph group_models["Latent-variable models"]
  node_mfbbvi_model["MF BBVI model<br/>[MFBBVI.py]"]
  node_mfconcrete_model["MF Concrete model<br/>[MFConcrete.py]"]
  node_sibpbbvi_model["S-IBP BBVI model<br/>[S_IBP_BBVI.py]"]
  node_sibpconcrete_model["S-IBP Concrete model<br/>[S_IBP_Concrete.py]"]
  node_model_common["Latent sampling helpers<br/>[common.py]"]
end

subgraph group_inference["Inference and math"]
  node_objectives["Training objectives<br/>[common.py]"]
  node_bbvi["BBVI estimators<br/>[bbvi.py]"]
  node_beta_math["Beta special functions<br/>[beta.py]"]
  node_lgamma_backend["Gamma backend<br/>[internals.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"runs experiment"| node_entrypoints
node_entrypoints -->|"dispatches to"| node_runner
node_runner -->|"loads MNIST"| node_fixed_data
node_runner -->|"loads Omniglot"| node_omniglot
node_runner -->|"selects model"| node_mfbbvi_model
node_runner -->|"selects model"| node_mfconcrete_model
node_runner -->|"selects model"| node_sibpbbvi_model
node_runner -->|"selects model"| node_sibpconcrete_model
node_runner -->|"dispatches training"| node_mfbbvi_train
node_runner -->|"dispatches training"| node_mfconcrete_train
node_runner -->|"dispatches training"| node_sibpbbvi_train
node_runner -->|"dispatches training"| node_sibpconcrete_train
node_runner -->|"saves results"| node_checkpoint
node_mfbbvi_train -->|"trains model"| node_mfbbvi_model
node_sibpbbvi_train -->|"trains model"| node_sibpbbvi_model
node_mfconcrete_train -->|"uses objectives"| node_objectives
node_sibpconcrete_train -->|"uses objectives"| node_objectives
node_mfbbvi_train -->|"uses objectives"| node_objectives
node_sibpbbvi_train -->|"uses objectives"| node_objectives
node_mfbbvi_model -->|"samples latents"| node_bbvi
node_sibpbbvi_model -->|"samples latents"| node_bbvi
node_mfbbvi_model -->|"uses sampling helpers"| node_model_common
node_mfconcrete_model -->|"uses sampling helpers"| node_model_common
node_sibpbbvi_model -->|"uses sampling helpers"| node_model_common
node_sibpconcrete_model -->|"uses sampling helpers"| node_model_common
node_objectives -->|"computes Beta terms"| node_beta_math
node_beta_math -->|"calls special functions"| node_lgamma_backend
node_bbvi -->|"samples Beta"| node_lgamma_backend
node_runner -.->|"supports loaders"| node_other_datasets

click node_entrypoints "https://github.com/rachtsingh/ibp_vae/blob/master/scripts/run_s_ibp_concrete.py"
click node_runner "https://github.com/rachtsingh/ibp_vae/blob/master/scripts/common.py"
click node_mfbbvi_train "https://github.com/rachtsingh/ibp_vae/blob/master/src/training/mf_bbvi.py"
click node_mfconcrete_train "https://github.com/rachtsingh/ibp_vae/blob/master/src/training/mf_concrete.py"
click node_sibpbbvi_train "https://github.com/rachtsingh/ibp_vae/blob/master/src/training/s_ibp_bbvi.py"
click node_sibpconcrete_train "https://github.com/rachtsingh/ibp_vae/blob/master/src/training/s_ibp_concrete.py"
click node_checkpoint "https://github.com/rachtsingh/ibp_vae/blob/master/src/utils.py"
click node_fixed_data "https://github.com/rachtsingh/ibp_vae/blob/master/src/datasets/fixed_binarization.py"
click node_omniglot "https://github.com/rachtsingh/ibp_vae/blob/master/src/datasets/omniglot.py"
click node_other_datasets "https://github.com/rachtsingh/ibp_vae/tree/master/src/datasets"
click node_mfbbvi_model "https://github.com/rachtsingh/ibp_vae/blob/master/src/models/MFBBVI.py"
click node_mfconcrete_model "https://github.com/rachtsingh/ibp_vae/blob/master/src/models/MFConcrete.py"
click node_sibpbbvi_model "https://github.com/rachtsingh/ibp_vae/blob/master/src/models/S_IBP_BBVI.py"
click node_sibpconcrete_model "https://github.com/rachtsingh/ibp_vae/blob/master/src/models/S_IBP_Concrete.py"
click node_model_common "https://github.com/rachtsingh/ibp_vae/blob/master/src/models/common.py"
click node_objectives "https://github.com/rachtsingh/ibp_vae/blob/master/src/training/common.py"
click node_bbvi "https://github.com/rachtsingh/ibp_vae/blob/master/src/bbvi.py"
click node_beta_math "https://github.com/rachtsingh/ibp_vae/blob/master/src/lgamma/beta.py"
click node_lgamma_backend "https://github.com/rachtsingh/ibp_vae/blob/master/src/lgamma/internals.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entrypoints,node_runner,node_mfbbvi_train,node_mfconcrete_train,node_sibpbbvi_train,node_sibpconcrete_train,node_checkpoint toneBlue
class node_fixed_data,node_omniglot,node_other_datasets toneAmber
class node_mfbbvi_model,node_mfconcrete_model,node_sibpbbvi_model,node_sibpconcrete_model,node_model_common toneMint
class node_objectives,node_bbvi,node_beta_math,node_lgamma_backend toneRose
class node_researcher toneIndigo
```

## Components

### Training workflow

- [Run entrypoints](https://github.com/rachtsingh/ibp_vae/blob/master/scripts/run_s_ibp_concrete.py): `scripts/run_s_ibp_concrete.py`
- [Experiment runner](https://github.com/rachtsingh/ibp_vae/blob/master/scripts/common.py): `scripts/common.py`
- [MF BBVI training](https://github.com/rachtsingh/ibp_vae/blob/master/src/training/mf_bbvi.py): `src/training/mf_bbvi.py`
- [MF Concrete training](https://github.com/rachtsingh/ibp_vae/blob/master/src/training/mf_concrete.py): `src/training/mf_concrete.py`
- [S-IBP BBVI training](https://github.com/rachtsingh/ibp_vae/blob/master/src/training/s_ibp_bbvi.py): `src/training/s_ibp_bbvi.py`
- [S-IBP Concrete training](https://github.com/rachtsingh/ibp_vae/blob/master/src/training/s_ibp_concrete.py): `src/training/s_ibp_concrete.py`
- [Checkpoints and curves](https://github.com/rachtsingh/ibp_vae/blob/master/src/utils.py): `src/utils.py`

### Data sources

- [Binarized MNIST](https://github.com/rachtsingh/ibp_vae/blob/master/src/datasets/fixed_binarization.py): `src/datasets/fixed_binarization.py`
- [Omniglot data](https://github.com/rachtsingh/ibp_vae/blob/master/src/datasets/omniglot.py): `src/datasets/omniglot.py`
- [Other dataset loaders](https://github.com/rachtsingh/ibp_vae/tree/master/src/datasets): `src/datasets`

### Latent-variable models

- [MF BBVI model](https://github.com/rachtsingh/ibp_vae/blob/master/src/models/MFBBVI.py): `src/models/MFBBVI.py`
- [MF Concrete model](https://github.com/rachtsingh/ibp_vae/blob/master/src/models/MFConcrete.py): `src/models/MFConcrete.py`
- [S-IBP BBVI model](https://github.com/rachtsingh/ibp_vae/blob/master/src/models/S_IBP_BBVI.py): `src/models/S_IBP_BBVI.py`
- [S-IBP Concrete model](https://github.com/rachtsingh/ibp_vae/blob/master/src/models/S_IBP_Concrete.py): `src/models/S_IBP_Concrete.py`
- [Latent sampling helpers](https://github.com/rachtsingh/ibp_vae/blob/master/src/models/common.py): `src/models/common.py`

### Inference and math

- [Training objectives](https://github.com/rachtsingh/ibp_vae/blob/master/src/training/common.py): `src/training/common.py`
- [BBVI estimators](https://github.com/rachtsingh/ibp_vae/blob/master/src/bbvi.py): `src/bbvi.py`
- [Beta special functions](https://github.com/rachtsingh/ibp_vae/blob/master/src/lgamma/beta.py): `src/lgamma/beta.py`
- [Gamma backend](https://github.com/rachtsingh/ibp_vae/blob/master/src/lgamma/internals.py): `src/lgamma/internals.py`

### Other components

- **Researcher**

## Connections

- Researcher → Run entrypoints: runs experiment (evidence: `README.md`)
- Run entrypoints → Experiment runner: dispatches to (evidence: `scripts/run_s_ibp_concrete.py`)
- Experiment runner → Binarized MNIST: loads MNIST (evidence: `scripts/common.py`)
- Experiment runner → Omniglot data: loads Omniglot (evidence: `scripts/common.py`)
- Experiment runner → MF BBVI model: selects model (evidence: `scripts/common.py`)
- Experiment runner → MF Concrete model: selects model (evidence: `scripts/common.py`)
- Experiment runner → S-IBP BBVI model: selects model (evidence: `scripts/common.py`)
- Experiment runner → S-IBP Concrete model: selects model (evidence: `scripts/common.py`)
- Experiment runner → MF BBVI training: dispatches training (evidence: `scripts/common.py`)
- Experiment runner → MF Concrete training: dispatches training (evidence: `scripts/common.py`)
- Experiment runner → S-IBP BBVI training: dispatches training (evidence: `scripts/common.py`)
- Experiment runner → S-IBP Concrete training: dispatches training (evidence: `scripts/common.py`)
- Experiment runner → Checkpoints and curves: saves results (evidence: `scripts/common.py`)
- MF BBVI training → MF BBVI model: trains model (evidence: `src/training/mf_bbvi.py`)
- S-IBP BBVI training → S-IBP BBVI model: trains model (evidence: `src/training/s_ibp_bbvi.py`)
- MF Concrete training → Training objectives: uses objectives (evidence: `src/training/mf_concrete.py`)
- S-IBP Concrete training → Training objectives: uses objectives (evidence: `src/training/s_ibp_concrete.py`)
- MF BBVI training → Training objectives: uses objectives (evidence: `src/training/mf_bbvi.py`)
- S-IBP BBVI training → Training objectives: uses objectives (evidence: `src/training/s_ibp_bbvi.py`)
- MF BBVI model → BBVI estimators: samples latents (evidence: `src/models/MFBBVI.py`)
- S-IBP BBVI model → BBVI estimators: samples latents (evidence: `src/models/S_IBP_BBVI.py`)
- MF BBVI model → Latent sampling helpers: uses sampling helpers (evidence: `src/models/MFBBVI.py`)
- MF Concrete model → Latent sampling helpers: uses sampling helpers (evidence: `src/models/MFConcrete.py`)
- S-IBP BBVI model → Latent sampling helpers: uses sampling helpers (evidence: `src/models/S_IBP_BBVI.py`)
- S-IBP Concrete model → Latent sampling helpers: uses sampling helpers (evidence: `src/models/S_IBP_Concrete.py`)
- Training objectives → Beta special functions: computes Beta terms (evidence: `src/training/common.py`)
- Beta special functions → Gamma backend: calls special functions (evidence: `src/lgamma/beta.py`)
- BBVI estimators → Gamma backend: samples Beta (evidence: `src/bbvi.py`)
- Experiment runner → Other dataset loaders: supports loaders (evidence: `scripts/common.py`)
