# snap-research/graphless-neural-networks architecture

> Architecture diagram of the GitHub repository snap-research/graphless-neural-networks, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/snap-research/graphless-neural-networks
- Repository: https://github.com/snap-research/graphless-neural-networks

## Overview

##### Project type and purpose
- This is a machine-learning research codebase implementing “Graph-less Neural Networks” (GLNN).
- Purpose: Provide a distillation framework that trains graph-based teacher models (e.g., GCN, GraphSAGE) on graph datasets and then distills their knowledge into standard MLP student models to achieve fast inference with near-GNN accuracy.
- It is an open-source experimentation framework, not a web service or full-stack app.

##### File structure
- Top level
- data_preprocess.py – feature noise / preprocessing scripts
- dataloader.py – unified data-loading logic for OGB, CPF, BGNN, NonHom datasets
- models.py – defines Model class with teacher and student architectures (GCN, SAGE, MLP, etc.)
- train_teacher.py – script to train a teacher GNN
- train_student.py – script to train the student MLP via distillation (uses pretrained teacher outputs)
- train_and_eval.py – orchestrates full training and evaluation in one go
- prepare_env.sh + requirements.txt – environment setup (conda, dependencies)
- train.conf.yaml – configuration file for default hyperparameters
- utils.py – shared utilities (logging, checkpointing, metric computation)
- experiments/ – shell scripts for batch runs (ablation studies, dataset variations)
- LICENSE, README.md, .gitignore
- Patterns & architecture
- Modular ML pipeline: Data loading → preprocessing → teacher training → student distillation → evaluation
- Experiment orchestration separated into scripts under experiments/
- Config files (YAML) to decouple hyperparameters from code

##### README for additional insights
- Lists supported datasets and how they’re loaded (automatic download vs manual placement)
- Usage examples for train_teacher.py and train_student.py
- Emphasis on reproducibility via experiments/ scripts

##### Elements
- data flow (Data→Preprocess→Train)
- control flow (Experiment scripts triggering training scripts)
- artifact flow (Teacher checkpoint → Student input)
- Python scripts vs. config files vs. external libraries/services
- ML components vs. orchestration vs. environment setup

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Environment Setup"
        E1["prepare_env.sh"]:::script
        E2["requirements.txt"]:::config
        E3["train.conf.yaml"]:::config
    end

    subgraph "Data Layer"
        D1["dataloader.py"]:::module
    end

    subgraph "Preprocessing Module"
        P1["data_preprocess.py"]:::module
    end

    subgraph "Teacher Model Module"
        T1["models.py"]:::module
        T2["train_teacher.py"]:::script
    end

    subgraph "Student Model Module"
        S1["train_student.py"]:::script
    end

    subgraph "Orchestration & Evaluation"
        O1["train_and_eval.py"]:::script
        O2["utils.py"]:::module
    end

    subgraph "Experiment Runner"
        EXP["experiments/"]:::script
    end

    subgraph "Diagrams & References"
        IMG["imgs/"]:::external
    end

    subgraph "External Libraries"
        LIB1["PyTorch"]:::external
        LIB2["DGL"]:::external
        LIB3["OGB"]:::external
        LIB4["CPF"]:::external
    end

    %% Data flow
    E1 --> D1
    E2 --> D1
    E3 --> D1
    D1 --> P1
    P1 --> T2
    T2 -->|"uses models.py"| T1
    T2 -->|"checkpoint & log-probs"| S1
    S1 -->|"uses models.py"| T1
    T2 --> O1
    S1 --> O1
    O1 --> O2

    %% External libs usage
    D1 --> LIB3
    D1 --> LIB4
    T1 --> LIB1
    T1 --> LIB2
    S1 --> LIB1

    %% Experiment orchestration
    EXP --> T2
    EXP --> S1
    EXP --> O1

    %% References
    IMG --- O1

    %% Click Events
    click E1 "https://github.com/snap-research/graphless-neural-networks/blob/main/prepare_env.sh"
    click E2 "https://github.com/snap-research/graphless-neural-networks/blob/main/requirements.txt"
    click E3 "https://github.com/snap-research/graphless-neural-networks/blob/main/train.conf.yaml"
    click D1 "https://github.com/snap-research/graphless-neural-networks/blob/main/dataloader.py"
    click P1 "https://github.com/snap-research/graphless-neural-networks/blob/main/data_preprocess.py"
    click T1 "https://github.com/snap-research/graphless-neural-networks/blob/main/models.py"
    click T2 "https://github.com/snap-research/graphless-neural-networks/blob/main/train_teacher.py"
    click S1 "https://github.com/snap-research/graphless-neural-networks/blob/main/train_student.py"
    click O1 "https://github.com/snap-research/graphless-neural-networks/blob/main/train_and_eval.py"
    click O2 "https://github.com/snap-research/graphless-neural-networks/blob/main/utils.py"
    click EXP "https://github.com/snap-research/graphless-neural-networks/tree/main/experiments/"
    click IMG "https://github.com/snap-research/graphless-neural-networks/tree/main/imgs/"

    %% Styles
    classDef script fill:#D6EAF8,stroke:#2980B9,color:#154360;
    classDef config fill:#D5F5E3,stroke:#27AE60,color:#145A32;
    classDef module fill:#FCF3CF,stroke:#D4AC0D,color:#7D6608;
    classDef external fill:#F2F3F4,stroke:#7F8C8D,color:#566573;
```
