# wenyiwy99/sdsp architecture

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

- Interactive diagram: https://gitdiagram.com/wenyiwy99/sdsp
- Repository: https://github.com/wenyiwy99/sdsp

## Overview

SDSP is a research implementation of multi-domain recommendation that selects similar domains while training recommendation models. The documented user workflow is to launch a dataset-specific script; the Amazon excerpt shows CSV loading, feature construction, and train/validation/test splitting, while the trainer excerpt shows model training, per-domain evaluation, and selector-driven updates. The graph also preserves the PLE/MMOE model options and dataset-preparation branches visible in the tree. Several runner and model files were not sampled, so uncertain connections are omitted.

Main entry points: [`run_amazon.py`](https://github.com/wenyiwy99/sdsp/blob/main/run_amazon.py) (Amazon runner), [`basic/layers.py`](https://github.com/wenyiwy99/sdsp/blob/main/basic/layers.py) (Embedding layers), [`basic/features.py`](https://github.com/wenyiwy99/sdsp/blob/main/basic/features.py) (Feature definitions), [`trainers/ctr_trainer.py`](https://github.com/wenyiwy99/sdsp/blob/main/trainers/ctr_trainer.py) (CTR trainer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Experiment entrypoints"]
  node_amazon_run["Amazon runner<br/>[run_amazon.py]"]
  node_douban_run["Douban runner<br/>[run_douban.py]"]
  node_movielens_run["MovieLens runner<br/>[run_movielens.py]"]
end

subgraph group_datasets["Dataset preparation"]
  node_amazon_prep["Amazon preparation<br/>[data_process.py]"]
  node_douban_prep["Douban preparation<br/>[data_process.py]"]
  node_amazon_csv["Amazon interactions<br/>[amazon.csv]"]
  node_douban_csv["Douban interactions<br/>[douban.csv]"]
  node_movie_csv["MovieLens interactions<br/>[ml-1m.csv]"]
end

subgraph group_modeling["Recommendation modeling"]
  node_features["Feature definitions<br/>[features.py]"]
  node_embeddings["Embedding layers<br/>[layers.py]"]
  node_initializers["Embedding initializers<br/>[initializers.py]"]
  node_activations["Activations<br/>[activation.py]"]
  node_ple["PLE model<br/>[PLE_SDSP.py]"]
  node_mmoe["MMOE model<br/>[MMOE_SDSP.py]"]
  node_loss["Loss functions<br/>[loss_func.py]"]
  node_metrics["Metrics<br/>[metric.py]"]
end

subgraph group_training["Training and selection"]
  node_data_loader["Data loading<br/>[data.py]"]
  node_trainer["CTR trainer<br/>[ctr_trainer.py]"]
  node_selector["Domain selector<br/>[domain_selector.py]"]
  node_callbacks["Early stopping<br/>[callback.py]"]
end

node_user(("Research user"))

node_user -->|"launches"| node_amazon_run
node_user -->|"launches"| node_douban_run
node_user -->|"launches"| node_movielens_run
node_amazon_prep -->|"writes"| node_amazon_csv
node_douban_prep -->|"writes"| node_douban_csv
node_amazon_run -->|"reads"| node_amazon_csv
node_amazon_run -->|"constructs"| node_features
node_features -->|"uses"| node_initializers
node_embeddings -->|"handles"| node_features
node_embeddings -->|"uses"| node_activations
node_ple -->|"embeds features"| node_embeddings
node_trainer -->|"updates states"| node_selector
node_trainer -->|"uses"| node_callbacks

click node_amazon_run "https://github.com/wenyiwy99/sdsp/blob/main/run_amazon.py"
click node_douban_run "https://github.com/wenyiwy99/sdsp/blob/main/run_douban.py"
click node_movielens_run "https://github.com/wenyiwy99/sdsp/blob/main/run_movielens.py"
click node_amazon_prep "https://github.com/wenyiwy99/sdsp/blob/main/data/amazon_5_core/data_process.py"
click node_douban_prep "https://github.com/wenyiwy99/sdsp/blob/main/data/douban/data_process.py"
click node_amazon_csv "https://github.com/wenyiwy99/sdsp/blob/main/data/amazon_5_core/amazon.csv"
click node_douban_csv "https://github.com/wenyiwy99/sdsp/blob/main/data/douban/douban.csv"
click node_movie_csv "https://github.com/wenyiwy99/sdsp/blob/main/data/ml-1m/ml-1m.csv"
click node_features "https://github.com/wenyiwy99/sdsp/blob/main/basic/features.py"
click node_embeddings "https://github.com/wenyiwy99/sdsp/blob/main/basic/layers.py"
click node_initializers "https://github.com/wenyiwy99/sdsp/blob/main/basic/initializers.py"
click node_activations "https://github.com/wenyiwy99/sdsp/blob/main/basic/activation.py"
click node_ple "https://github.com/wenyiwy99/sdsp/blob/main/model/PLE_SDSP.py"
click node_mmoe "https://github.com/wenyiwy99/sdsp/blob/main/model/MMOE_SDSP.py"
click node_loss "https://github.com/wenyiwy99/sdsp/blob/main/basic/loss_func.py"
click node_metrics "https://github.com/wenyiwy99/sdsp/blob/main/basic/metric.py"
click node_data_loader "https://github.com/wenyiwy99/sdsp/blob/main/basic/data.py"
click node_trainer "https://github.com/wenyiwy99/sdsp/blob/main/trainers/ctr_trainer.py"
click node_selector "https://github.com/wenyiwy99/sdsp/blob/main/model/domain_selector.py"
click node_callbacks "https://github.com/wenyiwy99/sdsp/blob/main/basic/callback.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_amazon_run,node_douban_run,node_movielens_run,node_user toneBlue
class node_amazon_prep,node_douban_prep,node_amazon_csv,node_douban_csv,node_movie_csv toneAmber
class node_features,node_embeddings,node_initializers,node_activations,node_ple,node_mmoe,node_loss,node_metrics toneMint
class node_data_loader,node_trainer,node_selector,node_callbacks toneRose
```

## Components

### Experiment entrypoints

- [Amazon runner](https://github.com/wenyiwy99/sdsp/blob/main/run_amazon.py): `run_amazon.py`
- [Douban runner](https://github.com/wenyiwy99/sdsp/blob/main/run_douban.py): `run_douban.py`
- [MovieLens runner](https://github.com/wenyiwy99/sdsp/blob/main/run_movielens.py): `run_movielens.py`

### Dataset preparation

- [Amazon preparation](https://github.com/wenyiwy99/sdsp/blob/main/data/amazon_5_core/data_process.py): `data/amazon_5_core/data_process.py`
- [Douban preparation](https://github.com/wenyiwy99/sdsp/blob/main/data/douban/data_process.py): `data/douban/data_process.py`
- [Amazon interactions](https://github.com/wenyiwy99/sdsp/blob/main/data/amazon_5_core/amazon.csv): `data/amazon_5_core/amazon.csv`
- [Douban interactions](https://github.com/wenyiwy99/sdsp/blob/main/data/douban/douban.csv): `data/douban/douban.csv`
- [MovieLens interactions](https://github.com/wenyiwy99/sdsp/blob/main/data/ml-1m/ml-1m.csv): `data/ml-1m/ml-1m.csv`

### Recommendation modeling

- [Feature definitions](https://github.com/wenyiwy99/sdsp/blob/main/basic/features.py): `basic/features.py`
- [Embedding layers](https://github.com/wenyiwy99/sdsp/blob/main/basic/layers.py): `basic/layers.py`
- [Embedding initializers](https://github.com/wenyiwy99/sdsp/blob/main/basic/initializers.py): `basic/initializers.py`
- [Activations](https://github.com/wenyiwy99/sdsp/blob/main/basic/activation.py): `basic/activation.py`
- [PLE model](https://github.com/wenyiwy99/sdsp/blob/main/model/PLE_SDSP.py): `model/PLE_SDSP.py`
- [MMOE model](https://github.com/wenyiwy99/sdsp/blob/main/model/MMOE_SDSP.py): `model/MMOE_SDSP.py`
- [Loss functions](https://github.com/wenyiwy99/sdsp/blob/main/basic/loss_func.py): `basic/loss_func.py`
- [Metrics](https://github.com/wenyiwy99/sdsp/blob/main/basic/metric.py): `basic/metric.py`

### Training and selection

- [Data loading](https://github.com/wenyiwy99/sdsp/blob/main/basic/data.py): `basic/data.py`
- [CTR trainer](https://github.com/wenyiwy99/sdsp/blob/main/trainers/ctr_trainer.py): `trainers/ctr_trainer.py`
- [Domain selector](https://github.com/wenyiwy99/sdsp/blob/main/model/domain_selector.py): `model/domain_selector.py`
- [Early stopping](https://github.com/wenyiwy99/sdsp/blob/main/basic/callback.py): `basic/callback.py`

### Other components

- **Research user**

## Connections

- Research user → Amazon runner: launches (evidence: `README.md`)
- Research user → Douban runner: launches (evidence: `README.md`)
- Research user → MovieLens runner: launches (evidence: `README.md`)
- Amazon preparation → Amazon interactions: writes (evidence: `data/amazon_5_core/data_process.py`)
- Douban preparation → Douban interactions: writes (evidence: `data/douban/data_process.py`)
- Amazon runner → Amazon interactions: reads (evidence: `run_amazon.py`)
- Amazon runner → Feature definitions: constructs (evidence: `run_amazon.py`)
- Feature definitions → Embedding initializers: uses (evidence: `basic/features.py`)
- Embedding layers → Feature definitions: handles (evidence: `basic/layers.py`)
- Embedding layers → Activations: uses (evidence: `basic/layers.py`)
- PLE model → Embedding layers: embeds features (evidence: `model/PLE_SDSP.py`)
- CTR trainer → Domain selector: updates states (evidence: `trainers/ctr_trainer.py`)
- CTR trainer → Early stopping: uses (evidence: `trainers/ctr_trainer.py`)
