# asma-jamali/spectral-molecular-kernels architecture

> Architecture diagram of the GitHub repository asma-jamali/spectral-molecular-kernels, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/asma-jamali/spectral-molecular-kernels
- Repository: https://github.com/asma-jamali/spectral-molecular-kernels
- Video tour (about a minute): https://gitdiagram.com/asma-jamali/spectral-molecular-kernels/video

## Overview

Kermol is a molecular-property kernel-ridge regression toolkit focused on kernel spectra. Its documented workflow loads QM9 data, prepares labels and molecular representations, builds kernels, fits/evaluates KRR, and analyzes spectral metrics; optional analyses include rank truncation and feature ablation. The README establishes the example-level workflow and capabilities; sampled source confirms core data, representation, kernel, spectral, truncation, and output responsibilities, but not every example’s internal wiring.

Main entry points: [`Kermol/kernels/kernels.py`](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/kernels/kernels.py) (Kernel construction and KRR), [`Kermol/data/features.py`](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/features.py) (Feature generators), [`Kermol/data/qm9.py`](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/qm9.py) (QM9 preparation), [`Kermol/data/loader.py`](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/loader.py) (QM9 loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_qm9prep["QM9 preparation<br/>[qm9.py]"]
  node_loader["QM9 loader<br/>[loader.py]"]
  node_labels["Property labels<br/>[properties.py]"]
end

subgraph group_represent["Molecular representations"]
  node_features["Feature generators<br/>[features.py]"]
  node_mbdf["MBDF descriptors<br/>[mbdf.py]"]
  node_storedreps["Precomputed embeddings<br/>[features.py]"]
  node_embeddinggen["Transformer embeddings"]
end

subgraph group_analysis["Kernel analysis"]
  node_kernels["Kernel construction and KRR<br/>[kernels.py]"]
  node_kernelfactory["Kernel generator<br/>[gen_kernel.py]"]
  node_spectral["Spectral metrics<br/>[spectral.py]"]
  node_truncate["Rank truncation<br/>[truncate.py]"]
  node_ablation["Feature ablation<br/>[ablation_study.py]"]
end

subgraph group_results["Results and outputs"]
  node_outputs["Analysis outputs<br/>[io_utils.py]"]
end

node_researcher(("Researcher"))
node_qm9files[("QM9 archive")]
node_hfmodels["Hugging Face models"]

node_researcher -->|"prepares dataset"| node_qm9prep
node_qm9prep -->|"downloads QM9"| node_qm9files
node_researcher -->|"loads data"| node_loader
node_loader -.->|"supplies properties"| node_labels
node_researcher -->|"generates features"| node_features
node_features -->|"calls generator"| node_mbdf
node_researcher -->|"loads embeddings"| node_storedreps
node_researcher -->|"generates embeddings"| node_embeddinggen
node_embeddinggen -->|"loads model"| node_hfmodels
node_features -.->|"provides representations"| node_kernels
node_storedreps -->|"provides vectors"| node_kernels
node_kernels -.->|"analyzes training kernel"| node_spectral
node_researcher -->|"builds and fits"| node_kernels
node_kernels -->|"uses KRR predictor"| node_truncate
node_researcher -->|"sweeps rank"| node_truncate
node_researcher -->|"removes features"| node_ablation
node_spectral -.->|"saves metrics"| node_outputs
node_researcher -.->|"saves results"| node_outputs

click node_qm9prep "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/qm9.py"
click node_loader "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/loader.py"
click node_labels "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/properties.py"
click node_features "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/features.py"
click node_mbdf "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/mbdf.py"
click node_storedreps "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/features.py"
click node_kernels "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/kernels/kernels.py"
click node_kernelfactory "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/kernels/gen_kernel.py"
click node_spectral "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/kernels/spectral.py"
click node_truncate "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/kernels/truncate.py"
click node_ablation "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/examples/ablation_study.py"
click node_embeddinggen "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/examples/generate_llm_embeddings.py"
click node_outputs "https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/io_utils.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_qm9prep,node_loader,node_labels toneBlue
class node_features,node_mbdf,node_storedreps,node_embeddinggen,node_qm9files toneAmber
class node_kernels,node_kernelfactory,node_spectral,node_truncate,node_ablation toneMint
class node_outputs toneRose
class node_researcher,node_hfmodels toneIndigo
```

## Components

### Data preparation

- [QM9 preparation](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/qm9.py): `Kermol/data/qm9.py`
- [QM9 loader](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/loader.py): `Kermol/data/loader.py`
- [Property labels](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/properties.py): `Kermol/data/properties.py`

### Molecular representations

- [Feature generators](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/features.py): `Kermol/data/features.py`
- [MBDF descriptors](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/mbdf.py): `Kermol/data/mbdf.py`
- [Precomputed embeddings](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/data/features.py): `Kermol/data/features.py`
- [Transformer embeddings](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/examples/generate_llm_embeddings.py): `examples/generate_llm_embeddings.py`

### Kernel analysis

- [Kernel construction and KRR](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/kernels/kernels.py): `Kermol/kernels/kernels.py`
- [Kernel generator](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/kernels/gen_kernel.py): `Kermol/kernels/gen_kernel.py`
- [Spectral metrics](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/kernels/spectral.py): `Kermol/kernels/spectral.py`
- [Rank truncation](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/kernels/truncate.py): `Kermol/kernels/truncate.py`
- [Feature ablation](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/examples/ablation_study.py): `examples/ablation_study.py`

### Results and outputs

- [Analysis outputs](https://github.com/asma-jamali/spectral-molecular-kernels/blob/main/Kermol/io_utils.py): `Kermol/io_utils.py`

### Other components

- **Researcher**
- **QM9 archive**
- **Hugging Face models**

## Connections

- Researcher → QM9 preparation: prepares dataset (evidence: `README.md`)
- QM9 preparation → QM9 archive: downloads QM9 (evidence: `Kermol/data/qm9.py`)
- Researcher → QM9 loader: loads data (evidence: `README.md`)
- QM9 loader → Property labels: supplies properties
- Researcher → Feature generators: generates features (evidence: `README.md`)
- Feature generators → MBDF descriptors: calls generator (evidence: `Kermol/data/features.py`)
- Researcher → Precomputed embeddings: loads embeddings (evidence: `README.md`)
- Researcher → Transformer embeddings: generates embeddings (evidence: `README.md`)
- Transformer embeddings → Hugging Face models: loads model
- Feature generators → Kernel construction and KRR: provides representations
- Precomputed embeddings → Kernel construction and KRR: provides vectors (evidence: `README.md`)
- Kernel construction and KRR → Spectral metrics: analyzes training kernel
- Researcher → Kernel construction and KRR: builds and fits (evidence: `README.md`)
- Kernel construction and KRR → Rank truncation: uses KRR predictor (evidence: `Kermol/kernels/truncate.py`)
- Researcher → Rank truncation: sweeps rank (evidence: `README.md`)
- Researcher → Feature ablation: removes features (evidence: `README.md`)
- Spectral metrics → Analysis outputs: saves metrics
- Researcher → Analysis outputs: saves results
