# marjanhs/prnn architecture

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

- Interactive diagram: https://gitdiagram.com/marjanhs/prnn
- Repository: https://github.com/marjanhs/prnn

## Overview

This repository is an authorship-verification experiment: it compares two documents and predicts whether they share an author. The implemented workflow loads embeddings and paired-document data, prepares sequences, runs stratified cross-validation with a parallel recurrent model, and reports metrics while saving intermediate outputs. The README also describes a transformation-encoder approach, but the sampled runtime source implements only the recurrent model; that documented capability is shown separately. Dataset wiring and the transformation approach are documented or represented incompletely, so unsupported runtime links are omitted.

Main entry points: [`main.py`](https://github.com/marjanhs/prnn/blob/master/main.py) (Cross-validation), [`util.py`](https://github.com/marjanhs/prnn/blob/master/util.py) (Pair data loader), [`model.py`](https://github.com/marjanhs/prnn/blob/master/model.py) (Parallel recurrent model), [`data`](https://github.com/marjanhs/prnn/tree/master/data) (Verification datasets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Inputs"]
  node_datasets["Verification datasets"]
  node_glove["GloVe embeddings"]
end

subgraph group_prep["Data preparation"]
  node_embedding_loader["Embedding loader<br/>[util.py]"]
  node_pair_loader["Pair data loader<br/>[util.py]"]
  node_text_prep["Text preprocessing<br/>[util.py]"]
  node_sequence_prep["Sequence encoding<br/>[util.py]"]
end

subgraph group_verification["Verification models"]
  node_rnn_model["Parallel recurrent model<br/>[model.py]"]
  node_fusion_metrics["Pairwise metrics<br/>[util.py]"]
  node_classifier["Similarity classifier<br/>[model.py]"]
  node_transform_encoder["Transformation encoder<br/>[README.md]"]
end

subgraph group_evaluation["Training and evaluation"]
  node_cv["Cross-validation<br/>[main.py]"]
  node_fit_eval["Fit and evaluate<br/>[main.py]"]
  node_fold_results["Fold metrics<br/>[main.py]"]
  node_intermediate_outputs["Intermediate outputs<br/>[main.py]"]
end

node_operator(("Experiment runner"))

node_operator -->|"starts CV"| node_cv
node_cv -->|"loads embeddings"| node_embedding_loader
node_embedding_loader -->|"reads vectors"| node_glove
node_cv -->|"loads pairs"| node_pair_loader
node_pair_loader -->|"extracts text"| node_text_prep
node_pair_loader -.->|"reads dataset files"| node_datasets
node_pair_loader -->|"encodes pairs"| node_sequence_prep
node_cv -->|"constructs model"| node_rnn_model
node_rnn_model -->|"uses pair metrics"| node_fusion_metrics
node_rnn_model -->|"feeds similarity"| node_classifier
node_cv -->|"trains folds"| node_fit_eval
node_fit_eval -->|"fits and predicts"| node_rnn_model
node_fit_eval -->|"reports metrics"| node_fold_results
node_fit_eval -->|"writes activations"| node_intermediate_outputs

click node_datasets "https://github.com/marjanhs/prnn/tree/master/data"
click node_embedding_loader "https://github.com/marjanhs/prnn/blob/master/util.py"
click node_pair_loader "https://github.com/marjanhs/prnn/blob/master/util.py"
click node_text_prep "https://github.com/marjanhs/prnn/blob/master/util.py"
click node_sequence_prep "https://github.com/marjanhs/prnn/blob/master/util.py"
click node_cv "https://github.com/marjanhs/prnn/blob/master/main.py"
click node_rnn_model "https://github.com/marjanhs/prnn/blob/master/model.py"
click node_fusion_metrics "https://github.com/marjanhs/prnn/blob/master/util.py"
click node_classifier "https://github.com/marjanhs/prnn/blob/master/model.py"
click node_fit_eval "https://github.com/marjanhs/prnn/blob/master/main.py"
click node_fold_results "https://github.com/marjanhs/prnn/blob/master/main.py"
click node_intermediate_outputs "https://github.com/marjanhs/prnn/blob/master/main.py"
click node_transform_encoder "https://github.com/marjanhs/prnn/blob/master/README.md"

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_datasets,node_glove toneBlue
class node_embedding_loader,node_pair_loader,node_text_prep,node_sequence_prep toneAmber
class node_rnn_model,node_fusion_metrics,node_classifier,node_transform_encoder toneMint
class node_cv,node_fit_eval,node_fold_results,node_intermediate_outputs toneRose
class node_operator toneIndigo
```

## Components

### Inputs

- [Verification datasets](https://github.com/marjanhs/prnn/tree/master/data): `data`
- **GloVe embeddings**

### Data preparation

- [Embedding loader](https://github.com/marjanhs/prnn/blob/master/util.py): `util.py`
- [Pair data loader](https://github.com/marjanhs/prnn/blob/master/util.py): `util.py`
- [Text preprocessing](https://github.com/marjanhs/prnn/blob/master/util.py): `util.py`
- [Sequence encoding](https://github.com/marjanhs/prnn/blob/master/util.py): `util.py`

### Verification models

- [Parallel recurrent model](https://github.com/marjanhs/prnn/blob/master/model.py): `model.py`
- [Pairwise metrics](https://github.com/marjanhs/prnn/blob/master/util.py): `util.py`
- [Similarity classifier](https://github.com/marjanhs/prnn/blob/master/model.py): `model.py`
- [Transformation encoder](https://github.com/marjanhs/prnn/blob/master/README.md): `README.md`

### Training and evaluation

- [Cross-validation](https://github.com/marjanhs/prnn/blob/master/main.py): `main.py`
- [Fit and evaluate](https://github.com/marjanhs/prnn/blob/master/main.py): `main.py`
- [Fold metrics](https://github.com/marjanhs/prnn/blob/master/main.py): `main.py`
- [Intermediate outputs](https://github.com/marjanhs/prnn/blob/master/main.py): `main.py`

### Other components

- **Experiment runner**

## Connections

- Experiment runner → Cross-validation: starts CV (evidence: `main.py`)
- Cross-validation → Embedding loader: loads embeddings (evidence: `main.py`)
- Embedding loader → GloVe embeddings: reads vectors (evidence: `util.py`)
- Cross-validation → Pair data loader: loads pairs (evidence: `main.py`)
- Pair data loader → Text preprocessing: extracts text (evidence: `util.py`)
- Pair data loader → Verification datasets: reads dataset files
- Pair data loader → Sequence encoding: encodes pairs (evidence: `util.py`)
- Cross-validation → Parallel recurrent model: constructs model (evidence: `main.py`)
- Parallel recurrent model → Pairwise metrics: uses pair metrics (evidence: `model.py`)
- Parallel recurrent model → Similarity classifier: feeds similarity (evidence: `model.py`)
- Cross-validation → Fit and evaluate: trains folds (evidence: `main.py`)
- Fit and evaluate → Parallel recurrent model: fits and predicts (evidence: `main.py`)
- Fit and evaluate → Fold metrics: reports metrics (evidence: `main.py`)
- Fit and evaluate → Intermediate outputs: writes activations (evidence: `main.py`)
