# andromeda784/aml architecture

> Architecture diagram of the GitHub repository andromeda784/aml, 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/andromeda784/aml
- Repository: https://github.com/andromeda784/aml

## Overview

AML trains and evaluates an emotion classifier on Empathetic Dialogues or GoEmotions. The main script loads CSV splits, tokenizes examples, builds a CrossEncoder, runs supervised and adversarial training, selects a checkpoint using validation results, then tests and saves metrics. The model also encodes label descriptions and uses clustering-based contrastive loss. The graph reflects shown calls and README capabilities; unsampled details are not inferred beyond the dataset files and documented workflow.

Main entry points: [`src/main.py`](https://github.com/andromeda784/aml/blob/main/src/main.py) (Experiment runner), [`src/datasets.py`](https://github.com/andromeda784/aml/blob/main/src/datasets.py) (Dataset loader), [`src/models.py`](https://github.com/andromeda784/aml/blob/main/src/models.py) (CrossEncoder), [`src/utils.py`](https://github.com/andromeda784/aml/blob/main/src/utils.py) (Adversarial loss)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Training workflow"]
  node_runner["Experiment runner<br/>[main.py]"]
  node_tokenizer["Text tokenizer"]
end

subgraph group_data["Datasets and labels"]
  node_dataset_loader["Dataset loader<br/>[datasets.py]"]
  node_ed_data[("ED CSV splits")]
  node_go_data[("GoEmotions CSV splits")]
  node_label_maps["Emotion label maps<br/>[datasets.py]"]
  node_label_descriptions["Label descriptions<br/>[description.py]"]
end

subgraph group_model["Classifier and losses"]
  node_classifier["CrossEncoder<br/>[models.py]"]
  node_encoder["Pretrained text encoder"]
  node_cluster_loss["Cluster contrastive loss<br/>[utils.py]"]
  node_discriminator["Pair discriminator<br/>[utils.py]"]
  node_pair_mining["Hard-pair mining<br/>[utils.py]"]
  node_adversarial_loss["Adversarial loss<br/>[utils.py]"]
end

subgraph group_results["Evaluation and results"]
  node_early_stopping["Early stopping<br/>[utils.py]"]
  node_result_logger["Result logger<br/>[main.py]"]
  node_result_file["Saved metrics"]
end

node_user(("Researcher"))

node_user -->|"starts run"| node_runner
node_runner -->|"loads tokenizer"| node_tokenizer
node_runner -->|"builds splits"| node_dataset_loader
node_dataset_loader -->|"reads CSVs"| node_ed_data
node_dataset_loader -->|"reads CSVs"| node_go_data
node_dataset_loader -->|"tokenizes batches"| node_tokenizer
node_runner -->|"selects labels"| node_label_maps
node_runner -->|"constructs and trains"| node_classifier
node_classifier -->|"loads pretrained model"| node_encoder
node_classifier -->|"encodes descriptions"| node_label_descriptions
node_classifier -->|"computes contrastive loss"| node_cluster_loss
node_runner -->|"mines hard pairs"| node_pair_mining
node_runner -->|"computes adversarial loss"| node_adversarial_loss
node_adversarial_loss -->|"scores pairs"| node_discriminator
node_runner -->|"checks validation"| node_early_stopping
node_runner -->|"records metrics"| node_result_logger
node_result_logger -->|"saves results"| node_result_file

click node_runner "https://github.com/andromeda784/aml/blob/main/src/main.py"
click node_dataset_loader "https://github.com/andromeda784/aml/blob/main/src/datasets.py"
click node_ed_data "https://github.com/andromeda784/aml/tree/main/data/ED"
click node_go_data "https://github.com/andromeda784/aml/tree/main/data/go_emotion"
click node_label_maps "https://github.com/andromeda784/aml/blob/main/src/datasets.py"
click node_label_descriptions "https://github.com/andromeda784/aml/blob/main/src/description.py"
click node_classifier "https://github.com/andromeda784/aml/blob/main/src/models.py"
click node_cluster_loss "https://github.com/andromeda784/aml/blob/main/src/utils.py"
click node_discriminator "https://github.com/andromeda784/aml/blob/main/src/utils.py"
click node_pair_mining "https://github.com/andromeda784/aml/blob/main/src/utils.py"
click node_adversarial_loss "https://github.com/andromeda784/aml/blob/main/src/utils.py"
click node_early_stopping "https://github.com/andromeda784/aml/blob/main/src/utils.py"
click node_result_logger "https://github.com/andromeda784/aml/blob/main/src/main.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_runner,node_tokenizer toneBlue
class node_dataset_loader,node_ed_data,node_go_data,node_label_maps,node_label_descriptions toneAmber
class node_classifier,node_encoder,node_cluster_loss,node_discriminator,node_pair_mining,node_adversarial_loss toneMint
class node_early_stopping,node_result_logger,node_result_file toneRose
class node_user toneIndigo
```

## Components

### Training workflow

- [Experiment runner](https://github.com/andromeda784/aml/blob/main/src/main.py): `src/main.py`
- **Text tokenizer**

### Datasets and labels

- [Dataset loader](https://github.com/andromeda784/aml/blob/main/src/datasets.py): `src/datasets.py`
- [ED CSV splits](https://github.com/andromeda784/aml/tree/main/data/ED): `data/ED`
- [GoEmotions CSV splits](https://github.com/andromeda784/aml/tree/main/data/go_emotion): `data/go_emotion`
- [Emotion label maps](https://github.com/andromeda784/aml/blob/main/src/datasets.py): `src/datasets.py`
- [Label descriptions](https://github.com/andromeda784/aml/blob/main/src/description.py): `src/description.py`

### Classifier and losses

- [CrossEncoder](https://github.com/andromeda784/aml/blob/main/src/models.py): `src/models.py`
- **Pretrained text encoder**
- [Cluster contrastive loss](https://github.com/andromeda784/aml/blob/main/src/utils.py): `src/utils.py`
- [Pair discriminator](https://github.com/andromeda784/aml/blob/main/src/utils.py): `src/utils.py`
- [Hard-pair mining](https://github.com/andromeda784/aml/blob/main/src/utils.py): `src/utils.py`
- [Adversarial loss](https://github.com/andromeda784/aml/blob/main/src/utils.py): `src/utils.py`

### Evaluation and results

- [Early stopping](https://github.com/andromeda784/aml/blob/main/src/utils.py): `src/utils.py`
- [Result logger](https://github.com/andromeda784/aml/blob/main/src/main.py): `src/main.py`
- **Saved metrics**

### Other components

- **Researcher**

## Connections

- Researcher → Experiment runner: starts run (evidence: `README.md`)
- Experiment runner → Text tokenizer: loads tokenizer (evidence: `src/main.py`)
- Experiment runner → Dataset loader: builds splits (evidence: `src/main.py`)
- Dataset loader → ED CSV splits: reads CSVs (evidence: `src/datasets.py`)
- Dataset loader → GoEmotions CSV splits: reads CSVs (evidence: `src/datasets.py`)
- Dataset loader → Text tokenizer: tokenizes batches (evidence: `src/datasets.py`)
- Experiment runner → Emotion label maps: selects labels (evidence: `src/main.py`)
- Experiment runner → CrossEncoder: constructs and trains (evidence: `src/main.py`)
- CrossEncoder → Pretrained text encoder: loads pretrained model (evidence: `src/models.py`)
- CrossEncoder → Label descriptions: encodes descriptions (evidence: `src/models.py`)
- CrossEncoder → Cluster contrastive loss: computes contrastive loss (evidence: `src/models.py`)
- Experiment runner → Hard-pair mining: mines hard pairs (evidence: `src/main.py`)
- Experiment runner → Adversarial loss: computes adversarial loss (evidence: `src/main.py`)
- Adversarial loss → Pair discriminator: scores pairs (evidence: `src/utils.py`)
- Experiment runner → Early stopping: checks validation (evidence: `src/main.py`)
- Experiment runner → Result logger: records metrics (evidence: `src/main.py`)
- Result logger → Saved metrics: saves results (evidence: `src/main.py`)
