# clinfo/helm-bert architecture

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

- Interactive diagram: https://gitdiagram.com/clinfo/helm-bert
- Repository: https://github.com/clinfo/helm-bert

## Overview

HELM-BERT is a HELM peptide language model and downstream peptide permeability/PPI predictor. The workflow spans peptide-data preparation, MLM pretraining, and task-specific prediction with evidential uncertainty; PPI additionally combines peptide and protein encoders, with optional cached embeddings. The README documents split regimes, benchmark evaluation, and split visualizations, so these appear as distinct capabilities. Edges are limited to README statements and source-index references or shown calls; unsampled preprocessing and training internals are represented conservatively.

Main entry points: [`src/models/ppi_lightning.py`](https://github.com/clinfo/helm-bert/blob/main/src/models/ppi_lightning.py) (Dual-encoder PPI model), [`src/models/regression_lightning.py`](https://github.com/clinfo/helm-bert/blob/main/src/models/regression_lightning.py) (Regression model), [`src/datamodules/ppi_datamodule.py`](https://github.com/clinfo/helm-bert/blob/main/src/datamodules/ppi_datamodule.py) (PPI data module), [`scripts/train_mlm.py`](https://github.com/clinfo/helm-bert/blob/main/scripts/train_mlm.py) (MLM training entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Data preparation"]
  node_prepsteps["HELM and split preparation"]
  node_prephelpers["Dataset utilities"]
  node_splitdata[("Task split data")]
end

subgraph group_pretrain["MLM pretraining"]
  node_mlmentry["MLM training entry<br/>[train_mlm.py]"]
  node_mlmdata["MLM data module<br/>[mlm_datamodule.py]"]
  node_masking["Span masking and collators<br/>[span_masking.py]"]
  node_mlmmodel["MLM model<br/>[mlm_lightning.py]"]
end

subgraph group_tasks["Downstream prediction"]
  node_permentry["Permeability training"]
  node_permdata["Permeability data module"]
  node_regmodel["Regression model"]
  node_ppi_entry["PPI training<br/>[train_ppi.py]"]
  node_ppidata["PPI data module<br/>[ppi_datamodule.py]"]
  node_dualdata["Dual-sequence dataset"]
  node_embeddata["Cached-embedding dataset"]
  node_ppi_model["Dual-encoder PPI model<br/>[ppi_lightning.py]"]
  node_visuals["Split visualizations<br/>[visualization.py]"]
end

subgraph group_shared["Shared runtime"]
  node_wsd["WSD scheduler<br/>[scheduler.py]"]
  node_cache[("Embedding cache<br/>[embedding_cache.py]")]
  node_generator["Embedding generation"]
  node_mlp["Prediction MLP<br/>[mlp_net.py]"]
  node_evidential["Evidential losses<br/>[evidential.py]"]
  node_metrics["Task metrics<br/>[metrics.py]"]
end

node_researcher(("Researcher"))
node_sources[("Peptide datasets")]
node_outputs["Predictions and uncertainty"]
node_huggingface["Pretrained model hub"]
node_esm["ESM-2 protein encoder"]

node_researcher -->|"prepares data"| node_prepsteps
node_sources -->|"supplies datasets"| node_prepsteps
node_prepsteps -->|"uses utilities"| node_prephelpers
node_prepsteps -->|"creates splits"| node_splitdata
node_researcher -->|"starts pretraining"| node_mlmentry
node_mlmentry -->|"configures"| node_mlmdata
node_mlmdata -->|"uses masking"| node_masking
node_mlmdata -.->|"reads data"| node_splitdata
node_mlmentry -->|"trains"| node_mlmmodel
node_mlmmodel -->|"uses schedule"| node_wsd
node_mlmentry -->|"loads checkpoint"| node_huggingface
node_researcher -->|"starts training"| node_permentry
node_permentry -.->|"configures"| node_permdata
node_permdata -.->|"reads data"| node_splitdata
node_permentry -.->|"trains"| node_regmodel
node_regmodel -->|"computes loss"| node_evidential
node_regmodel -->|"computes metrics"| node_metrics
node_regmodel -->|"uses schedule"| node_wsd
node_researcher -->|"starts training"| node_ppi_entry
node_ppi_entry -->|"configures"| node_ppidata
node_ppidata -->|"builds dataset"| node_dualdata
node_ppidata -->|"serves embeddings"| node_embeddata
node_ppidata -->|"reads and writes"| node_cache
node_ppidata -->|"generates missing"| node_generator
node_generator -->|"saves embeddings"| node_cache
node_ppi_entry -->|"trains"| node_ppi_model
node_ppi_model -->|"uses head"| node_mlp
node_ppi_model -->|"computes loss"| node_evidential
node_ppi_model -->|"computes metrics"| node_metrics
node_ppi_model -->|"loads peptide encoder"| node_huggingface
node_ppi_model -->|"uses target encoder"| node_esm
node_regmodel -->|"returns uncertainty"| node_outputs
node_ppi_model -->|"returns uncertainty"| node_outputs
node_researcher -->|"visualizes splits"| node_visuals
node_visuals -.->|"saves figures"| node_outputs

click node_prepsteps "https://github.com/clinfo/helm-bert/tree/main/scripts/preprocessing"
click node_prephelpers "https://github.com/clinfo/helm-bert/tree/main/scripts/preprocessing/helpers"
click node_splitdata "https://github.com/clinfo/helm-bert/tree/main/scripts/preprocessing"
click node_mlmentry "https://github.com/clinfo/helm-bert/blob/main/scripts/train_mlm.py"
click node_mlmdata "https://github.com/clinfo/helm-bert/blob/main/src/datamodules/mlm_datamodule.py"
click node_masking "https://github.com/clinfo/helm-bert/blob/main/src/datamodules/span_masking.py"
click node_mlmmodel "https://github.com/clinfo/helm-bert/blob/main/src/models/mlm_lightning.py"
click node_wsd "https://github.com/clinfo/helm-bert/blob/main/src/utils/scheduler.py"
click node_permentry "https://github.com/clinfo/helm-bert/blob/main/scripts/train_regression.py"
click node_permdata "https://github.com/clinfo/helm-bert/blob/main/src/datamodules/permeability_datamodule.py"
click node_regmodel "https://github.com/clinfo/helm-bert/blob/main/src/models/regression_lightning.py"
click node_ppi_entry "https://github.com/clinfo/helm-bert/blob/main/scripts/train_ppi.py"
click node_ppidata "https://github.com/clinfo/helm-bert/blob/main/src/datamodules/ppi_datamodule.py"
click node_dualdata "https://github.com/clinfo/helm-bert/blob/main/src/datamodules/dual_sequence_dataset.py"
click node_embeddata "https://github.com/clinfo/helm-bert/blob/main/src/datamodules/embedding_only_dataset.py"
click node_cache "https://github.com/clinfo/helm-bert/blob/main/src/utils/embedding_cache.py"
click node_generator "https://github.com/clinfo/helm-bert/blob/main/src/utils/embedding_generator.py"
click node_ppi_model "https://github.com/clinfo/helm-bert/blob/main/src/models/ppi_lightning.py"
click node_mlp "https://github.com/clinfo/helm-bert/blob/main/src/heads/mlp_net.py"
click node_evidential "https://github.com/clinfo/helm-bert/blob/main/src/losses/evidential.py"
click node_metrics "https://github.com/clinfo/helm-bert/blob/main/src/utils/metrics.py"
click node_visuals "https://github.com/clinfo/helm-bert/blob/main/scripts/helpers/visualization.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_prepsteps,node_prephelpers,node_splitdata toneBlue
class node_mlmentry,node_mlmdata,node_masking,node_mlmmodel,node_sources toneAmber
class node_permentry,node_permdata,node_regmodel,node_ppi_entry,node_ppidata,node_dualdata,node_embeddata,node_ppi_model,node_visuals toneMint
class node_wsd,node_cache,node_generator,node_mlp,node_evidential,node_metrics toneRose
class node_researcher,node_outputs,node_huggingface,node_esm toneIndigo
```

## Components

### Data preparation

- [HELM and split preparation](https://github.com/clinfo/helm-bert/tree/main/scripts/preprocessing): `scripts/preprocessing`
- [Dataset utilities](https://github.com/clinfo/helm-bert/tree/main/scripts/preprocessing/helpers): `scripts/preprocessing/helpers`
- [Task split data](https://github.com/clinfo/helm-bert/tree/main/scripts/preprocessing): `scripts/preprocessing`

### MLM pretraining

- [MLM training entry](https://github.com/clinfo/helm-bert/blob/main/scripts/train_mlm.py): `scripts/train_mlm.py`
- [MLM data module](https://github.com/clinfo/helm-bert/blob/main/src/datamodules/mlm_datamodule.py): `src/datamodules/mlm_datamodule.py`
- [Span masking and collators](https://github.com/clinfo/helm-bert/blob/main/src/datamodules/span_masking.py): `src/datamodules/span_masking.py`
- [MLM model](https://github.com/clinfo/helm-bert/blob/main/src/models/mlm_lightning.py): `src/models/mlm_lightning.py`

### Downstream prediction

- [Permeability training](https://github.com/clinfo/helm-bert/blob/main/scripts/train_regression.py): `scripts/train_regression.py`
- [Permeability data module](https://github.com/clinfo/helm-bert/blob/main/src/datamodules/permeability_datamodule.py): `src/datamodules/permeability_datamodule.py`
- [Regression model](https://github.com/clinfo/helm-bert/blob/main/src/models/regression_lightning.py): `src/models/regression_lightning.py`
- [PPI training](https://github.com/clinfo/helm-bert/blob/main/scripts/train_ppi.py): `scripts/train_ppi.py`
- [PPI data module](https://github.com/clinfo/helm-bert/blob/main/src/datamodules/ppi_datamodule.py): `src/datamodules/ppi_datamodule.py`
- [Dual-sequence dataset](https://github.com/clinfo/helm-bert/blob/main/src/datamodules/dual_sequence_dataset.py): `src/datamodules/dual_sequence_dataset.py`
- [Cached-embedding dataset](https://github.com/clinfo/helm-bert/blob/main/src/datamodules/embedding_only_dataset.py): `src/datamodules/embedding_only_dataset.py`
- [Dual-encoder PPI model](https://github.com/clinfo/helm-bert/blob/main/src/models/ppi_lightning.py): `src/models/ppi_lightning.py`
- [Split visualizations](https://github.com/clinfo/helm-bert/blob/main/scripts/helpers/visualization.py): `scripts/helpers/visualization.py`

### Shared runtime

- [WSD scheduler](https://github.com/clinfo/helm-bert/blob/main/src/utils/scheduler.py): `src/utils/scheduler.py`
- [Embedding cache](https://github.com/clinfo/helm-bert/blob/main/src/utils/embedding_cache.py): `src/utils/embedding_cache.py`
- [Embedding generation](https://github.com/clinfo/helm-bert/blob/main/src/utils/embedding_generator.py): `src/utils/embedding_generator.py`
- [Prediction MLP](https://github.com/clinfo/helm-bert/blob/main/src/heads/mlp_net.py): `src/heads/mlp_net.py`
- [Evidential losses](https://github.com/clinfo/helm-bert/blob/main/src/losses/evidential.py): `src/losses/evidential.py`
- [Task metrics](https://github.com/clinfo/helm-bert/blob/main/src/utils/metrics.py): `src/utils/metrics.py`

### Other components

- **Researcher**
- **Peptide datasets**
- **Predictions and uncertainty**
- **Pretrained model hub**
- **ESM-2 protein encoder**

## Connections

- Researcher → HELM and split preparation: prepares data (evidence: `README.md`)
- Peptide datasets → HELM and split preparation: supplies datasets (evidence: `README.md`)
- HELM and split preparation → Dataset utilities: uses utilities (evidence: `scripts/preprocessing/11_prepare_ppi_acsm.py`)
- HELM and split preparation → Task split data: creates splits (evidence: `README.md`)
- Researcher → MLM training entry: starts pretraining (evidence: `README.md`)
- MLM training entry → MLM data module: configures (evidence: `scripts/train_mlm.py`)
- MLM data module → Span masking and collators: uses masking (evidence: `src/datamodules/mlm_datamodule.py`)
- MLM data module → Task split data: reads data
- MLM training entry → MLM model: trains (evidence: `scripts/train_mlm.py`)
- MLM model → WSD scheduler: uses schedule (evidence: `src/models/mlm_lightning.py`)
- MLM training entry → Pretrained model hub: loads checkpoint (evidence: `README.md`)
- Researcher → Permeability training: starts training (evidence: `README.md`)
- Permeability training → Permeability data module: configures
- Permeability data module → Task split data: reads data
- Permeability training → Regression model: trains
- Regression model → Evidential losses: computes loss (evidence: `src/models/regression_lightning.py`)
- Regression model → Task metrics: computes metrics (evidence: `src/models/regression_lightning.py`)
- Regression model → WSD scheduler: uses schedule (evidence: `src/models/regression_lightning.py`)
- Researcher → PPI training: starts training (evidence: `README.md`)
- PPI training → PPI data module: configures (evidence: `scripts/train_ppi.py`)
- PPI data module → Dual-sequence dataset: builds dataset (evidence: `src/datamodules/ppi_datamodule.py`)
- PPI data module → Cached-embedding dataset: serves embeddings (evidence: `src/datamodules/ppi_datamodule.py`)
- PPI data module → Embedding cache: reads and writes (evidence: `src/datamodules/ppi_datamodule.py`)
- PPI data module → Embedding generation: generates missing (evidence: `src/datamodules/ppi_datamodule.py`)
- Embedding generation → Embedding cache: saves embeddings (evidence: `src/utils/embedding_generator.py`)
- PPI training → Dual-encoder PPI model: trains (evidence: `scripts/train_ppi.py`)
- Dual-encoder PPI model → Prediction MLP: uses head (evidence: `src/models/ppi_lightning.py`)
- Dual-encoder PPI model → Evidential losses: computes loss (evidence: `src/models/ppi_lightning.py`)
- Dual-encoder PPI model → Task metrics: computes metrics (evidence: `src/models/ppi_lightning.py`)
- Dual-encoder PPI model → Pretrained model hub: loads peptide encoder (evidence: `README.md`)
- Dual-encoder PPI model → ESM-2 protein encoder: uses target encoder (evidence: `README.md`)
- Regression model → Predictions and uncertainty: returns uncertainty (evidence: `README.md`)
- Dual-encoder PPI model → Predictions and uncertainty: returns uncertainty (evidence: `README.md`)
- Researcher → Split visualizations: visualizes splits (evidence: `README.md`)
- Split visualizations → Predictions and uncertainty: saves figures
