# bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer architecture

> Architecture diagram of the GitHub repository bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer
- Repository: https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer

## Overview

BiHyPE is presented as a time-series anomaly-detection research implementation built around the Anomaly Transformer, with training and test modes over benchmark datasets. Its workflow loads and windows data, runs the model through the Solver, and supports checkpoint-based training or evaluation. The repository also contains a distinct VUS anomaly-detection and evaluation toolkit, including detector implementations, interval metrics, and robustness analysis. README capabilities are included where source excerpts were unavailable; uncertain internal wiring is omitted.

Main entry points: [`solver.py`](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/solver.py) (Experiment solver), [`vus/utils/metrics.py`](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/utils/metrics.py) (Range and VUS metrics), [`vus/models`](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/tree/main/vus/models) (Detector implementations), [`model/AnomalyTransformer.py`](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/model/AnomalyTransformer.py) (Anomaly Transformer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Experiment Workflow"]
  node_entry["CLI entry<br/>[main.py]"]
  node_solver["Experiment solver<br/>[solver.py]"]
  node_datasets[("Benchmark datasets")]
  node_loader["Windowed data loaders<br/>[data_loader.py]"]
  node_checkpoints[("Model checkpoints")]
end

subgraph group_transformer["Transformer Model"]
  node_anomaly_transformer["Anomaly Transformer"]
  node_embedding["Data and position embedding<br/>[embed.py]"]
  node_attention["Association attention<br/>[attn.py]"]
end

subgraph group_vusdetectors["VUS Detectors"]
  node_detector_base["Detector base<br/>[detectorA.py]"]
  node_detector_zoo["Detector implementations"]
  node_model_utilities["Model utilities<br/>[utility.py]"]
  node_distance_scores["Distance scoring<br/>[distance.py]"]
end

subgraph group_vuseval["VUS Evaluation"]
  node_basic_metrics["Basic metrics<br/>[basic_metrics.py]"]
  node_vus_metrics["Range and VUS metrics<br/>[metrics.py]"]
  node_affiliation_metrics["Affiliation metrics<br/>[metrics.py]"]
  node_interval_math["Interval calculations"]
  node_score_analysis["Score computation"]
  node_robustness["Robustness evaluation<br/>[robustness_eval.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"starts run"| node_entry
node_entry -->|"creates solver"| node_solver
node_solver -->|"requests data"| node_loader
node_datasets -->|"supplies series"| node_loader
node_solver -->|"trains or tests"| node_anomaly_transformer
node_anomaly_transformer -->|"embeds windows"| node_embedding
node_anomaly_transformer -->|"computes attention"| node_attention
node_solver -->|"saves or loads"| node_checkpoints
node_detector_zoo -->|"extends base"| node_detector_base
node_detector_zoo -->|"uses utilities"| node_model_utilities
node_detector_zoo -->|"uses measures"| node_distance_scores
node_basic_metrics -->|"provides range metrics"| node_vus_metrics
node_vus_metrics -->|"integrates intervals"| node_interval_math
node_affiliation_metrics -->|"uses interval math"| node_interval_math
node_robustness -->|"evaluates scores"| node_vus_metrics
node_score_analysis -->|"computes metrics"| node_vus_metrics

click node_entry "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/main.py"
click node_solver "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/solver.py"
click node_loader "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/data_factory/data_loader.py"
click node_anomaly_transformer "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/model/AnomalyTransformer.py"
click node_embedding "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/model/embed.py"
click node_attention "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/model/attn.py"
click node_detector_base "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/models/detectorA.py"
click node_detector_zoo "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/tree/main/vus/models"
click node_model_utilities "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/utils/utility.py"
click node_distance_scores "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/models/distance.py"
click node_basic_metrics "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/basic_metrics.py"
click node_vus_metrics "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/utils/metrics.py"
click node_affiliation_metrics "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/affiliation/metrics.py"
click node_interval_math "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/affiliation/_integral_interval.py"
click node_score_analysis "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/analysis/score_computation.py"
click node_robustness "https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/analysis/robustness_eval.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_entry,node_solver,node_datasets,node_loader,node_checkpoints toneBlue
class node_anomaly_transformer,node_embedding,node_attention toneAmber
class node_detector_base,node_detector_zoo,node_model_utilities,node_distance_scores toneMint
class node_basic_metrics,node_vus_metrics,node_affiliation_metrics,node_interval_math,node_score_analysis,node_robustness toneRose
class node_researcher toneIndigo
```

## Components

### Experiment Workflow

- [CLI entry](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/main.py): `main.py`
- [Experiment solver](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/solver.py): `solver.py`
- **Benchmark datasets**
- [Windowed data loaders](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/data_factory/data_loader.py): `data_factory/data_loader.py`
- **Model checkpoints**

### Transformer Model

- [Anomaly Transformer](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/model/AnomalyTransformer.py): `model/AnomalyTransformer.py`
- [Data and position embedding](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/model/embed.py): `model/embed.py`
- [Association attention](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/model/attn.py): `model/attn.py`

### VUS Detectors

- [Detector base](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/models/detectorA.py): `vus/models/detectorA.py`
- [Detector implementations](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/tree/main/vus/models): `vus/models`
- [Model utilities](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/utils/utility.py): `vus/utils/utility.py`
- [Distance scoring](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/models/distance.py): `vus/models/distance.py`

### VUS Evaluation

- [Basic metrics](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/basic_metrics.py): `vus/basic_metrics.py`
- [Range and VUS metrics](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/utils/metrics.py): `vus/utils/metrics.py`
- [Affiliation metrics](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/affiliation/metrics.py): `vus/affiliation/metrics.py`
- [Interval calculations](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/affiliation/_integral_interval.py): `vus/affiliation/_integral_interval.py`
- [Score computation](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/analysis/score_computation.py): `vus/analysis/score_computation.py`
- [Robustness evaluation](https://github.com/bihype-timeseriesanalysis/bihype-tsad-anomaly-transformer/blob/main/vus/analysis/robustness_eval.py): `vus/analysis/robustness_eval.py`

### Other components

- **Researcher**

## Connections

- Researcher → CLI entry: starts run
- CLI entry → Experiment solver: creates solver
- Experiment solver → Windowed data loaders: requests data
- Benchmark datasets → Windowed data loaders: supplies series
- Experiment solver → Anomaly Transformer: trains or tests
- Anomaly Transformer → Data and position embedding: embeds windows
- Anomaly Transformer → Association attention: computes attention
- Experiment solver → Model checkpoints: saves or loads
- Detector implementations → Detector base: extends base
- Detector implementations → Model utilities: uses utilities
- Detector implementations → Distance scoring: uses measures
- Basic metrics → Range and VUS metrics: provides range metrics
- Range and VUS metrics → Interval calculations: integrates intervals
- Affiliation metrics → Interval calculations: uses interval math
- Robustness evaluation → Range and VUS metrics: evaluates scores
- Score computation → Range and VUS metrics: computes metrics
