# leeyejin1231/rv-hate architecture

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

- Interactive diagram: https://gitdiagram.com/leeyejin1231/rv-hate
- Repository: https://github.com/leeyejin1231/rv-hate

## Overview

RV-HATE detects implicit hate speech through contrastive representation learning and an adaptive multi-module voting design. Its data workflow clusters and preprocesses dataset examples, builds tokenized training batches, trains base or hard-negative models, then evaluates module predictions. The README also describes target tagging and cluster-based outlier removal as specialized capabilities. The source index supports the main training, loading, model, and evaluation links; connections among voting and reinforcement-learning internals are limited to README-level evidence because those implementations were not excerpted.

Main entry points: [`model/model.py`](https://github.com/leeyejin1231/rv-hate/blob/main/model/model.py) (Text encoder), [`train.py`](https://github.com/leeyejin1231/rv-hate/blob/main/train.py) (Contrastive trainer), [`train_hard_negative.py`](https://github.com/leeyejin1231/rv-hate/blob/main/train_hard_negative.py) (Hard-negative trainer), [`utils/shared_semantics.py`](https://github.com/leeyejin1231/rv-hate/blob/main/utils/shared_semantics.py) (Semantic preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data_prep["Data preparation"]
  node_semantic_prep["Semantic preparation"]
  node_clustering["Context clustering<br/>[clustering.py]"]
  node_preprocessing["Dataset preprocessing"]
  node_loader["Dataset loader<br/>[dataset_loader.py]"]
  node_collation["Batch collation"]
end

subgraph group_training["Model training"]
  node_train_config["Training settings<br/>[train_config.py]"]
  node_hard_config["Hard-negative settings"]
  node_trainer["Contrastive trainer<br/>[train.py]"]
  node_hard_trainer["Hard-negative trainer"]
end

subgraph group_modules["Detection modules"]
  node_encoder["Text encoder<br/>[model.py]"]
  node_contrastive_loss["Contrastive losses<br/>[loss_sharedcon.py]"]
  node_target_tagging["Target tagging"]
  node_outlier_removal["Outlier removal"]
  node_hard_negative_sampling["Hard-negative sampling"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluation_config["Evaluation settings<br/>[eval_config.py]"]
  node_standard_eval["Model evaluation<br/>[eval.py]"]
  node_voting_eval["Voting evaluation"]
  node_soft_voting["Soft voting"]
  node_rl_eval["Reinforcement evaluation<br/>[ppo_eval.py]"]
end

node_user(("Researcher"))

node_user -->|"prepares data"| node_semantic_prep
node_semantic_prep -->|"uses clustering"| node_clustering
node_user -->|"tokenizes data"| node_preprocessing
node_preprocessing -->|"supplies datasets"| node_loader
node_loader -->|"selects collator"| node_collation
node_user -->|"starts training"| node_trainer
node_trainer -->|"loads settings"| node_train_config
node_trainer -->|"loads batches"| node_loader
node_trainer -->|"encodes text"| node_encoder
node_trainer -->|"computes loss"| node_contrastive_loss
node_user -->|"trains module"| node_hard_trainer
node_hard_trainer -->|"loads settings"| node_hard_config
node_hard_trainer -->|"loads batches"| node_loader
node_hard_trainer -->|"encodes text"| node_encoder
node_hard_trainer -->|"maintains queue"| node_hard_negative_sampling
node_user -->|"evaluates models"| node_standard_eval
node_standard_eval -->|"loads settings"| node_evaluation_config
node_standard_eval -->|"uses model"| node_encoder
node_user -->|"runs voting"| node_voting_eval
node_voting_eval -->|"loads settings"| node_evaluation_config
node_voting_eval -->|"uses model"| node_encoder
node_user -->|"runs voting"| node_soft_voting
node_soft_voting -->|"loads settings"| node_evaluation_config
node_soft_voting -->|"uses model"| node_encoder
node_user -->|"runs evaluation"| node_rl_eval
node_rl_eval -->|"loads settings"| node_evaluation_config
node_rl_eval -->|"uses model"| node_encoder
node_semantic_prep -.->|"tags targets"| node_target_tagging
node_semantic_prep -.->|"removes outliers"| node_outlier_removal
node_rl_eval -.->|"optimizes voting"| node_voting_eval

click node_semantic_prep "https://github.com/leeyejin1231/rv-hate/blob/main/utils/shared_semantics.py"
click node_clustering "https://github.com/leeyejin1231/rv-hate/blob/main/utils/clustering.py"
click node_preprocessing "https://github.com/leeyejin1231/rv-hate/blob/main/utils/preprocess_dataset.py"
click node_loader "https://github.com/leeyejin1231/rv-hate/blob/main/utils/dataset_loader.py"
click node_collation "https://github.com/leeyejin1231/rv-hate/blob/main/utils/collate_fns_sharedcon.py"
click node_train_config "https://github.com/leeyejin1231/rv-hate/blob/main/config/train_config.py"
click node_hard_config "https://github.com/leeyejin1231/rv-hate/blob/main/config/train_hard_negative_config.py"
click node_trainer "https://github.com/leeyejin1231/rv-hate/blob/main/train.py"
click node_hard_trainer "https://github.com/leeyejin1231/rv-hate/blob/main/train_hard_negative.py"
click node_encoder "https://github.com/leeyejin1231/rv-hate/blob/main/model/model.py"
click node_contrastive_loss "https://github.com/leeyejin1231/rv-hate/blob/main/model/loss_sharedcon.py"
click node_target_tagging "https://github.com/leeyejin1231/rv-hate/blob/main/utils/shared_semantics.py"
click node_outlier_removal "https://github.com/leeyejin1231/rv-hate/blob/main/utils/shared_semantics.py"
click node_hard_negative_sampling "https://github.com/leeyejin1231/rv-hate/blob/main/train_hard_negative.py"
click node_evaluation_config "https://github.com/leeyejin1231/rv-hate/blob/main/config/eval_config.py"
click node_standard_eval "https://github.com/leeyejin1231/rv-hate/blob/main/eval.py"
click node_voting_eval "https://github.com/leeyejin1231/rv-hate/blob/main/eval_hard_voting.py"
click node_soft_voting "https://github.com/leeyejin1231/rv-hate/blob/main/eval_soft_voting.py"
click node_rl_eval "https://github.com/leeyejin1231/rv-hate/blob/main/ppo_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_semantic_prep,node_clustering,node_preprocessing,node_loader,node_collation toneBlue
class node_train_config,node_hard_config,node_trainer,node_hard_trainer toneAmber
class node_encoder,node_contrastive_loss,node_target_tagging,node_outlier_removal,node_hard_negative_sampling toneMint
class node_evaluation_config,node_standard_eval,node_voting_eval,node_soft_voting,node_rl_eval toneRose
class node_user toneIndigo
```

## Components

### Data preparation

- [Semantic preparation](https://github.com/leeyejin1231/rv-hate/blob/main/utils/shared_semantics.py): `utils/shared_semantics.py`
- [Context clustering](https://github.com/leeyejin1231/rv-hate/blob/main/utils/clustering.py): `utils/clustering.py`
- [Dataset preprocessing](https://github.com/leeyejin1231/rv-hate/blob/main/utils/preprocess_dataset.py): `utils/preprocess_dataset.py`
- [Dataset loader](https://github.com/leeyejin1231/rv-hate/blob/main/utils/dataset_loader.py): `utils/dataset_loader.py`
- [Batch collation](https://github.com/leeyejin1231/rv-hate/blob/main/utils/collate_fns_sharedcon.py): `utils/collate_fns_sharedcon.py`

### Model training

- [Training settings](https://github.com/leeyejin1231/rv-hate/blob/main/config/train_config.py): `config/train_config.py`
- [Hard-negative settings](https://github.com/leeyejin1231/rv-hate/blob/main/config/train_hard_negative_config.py): `config/train_hard_negative_config.py`
- [Contrastive trainer](https://github.com/leeyejin1231/rv-hate/blob/main/train.py): `train.py`
- [Hard-negative trainer](https://github.com/leeyejin1231/rv-hate/blob/main/train_hard_negative.py): `train_hard_negative.py`

### Detection modules

- [Text encoder](https://github.com/leeyejin1231/rv-hate/blob/main/model/model.py): `model/model.py`
- [Contrastive losses](https://github.com/leeyejin1231/rv-hate/blob/main/model/loss_sharedcon.py): `model/loss_sharedcon.py`
- [Target tagging](https://github.com/leeyejin1231/rv-hate/blob/main/utils/shared_semantics.py): `utils/shared_semantics.py`
- [Outlier removal](https://github.com/leeyejin1231/rv-hate/blob/main/utils/shared_semantics.py): `utils/shared_semantics.py`
- [Hard-negative sampling](https://github.com/leeyejin1231/rv-hate/blob/main/train_hard_negative.py): `train_hard_negative.py`

### Evaluation

- [Evaluation settings](https://github.com/leeyejin1231/rv-hate/blob/main/config/eval_config.py): `config/eval_config.py`
- [Model evaluation](https://github.com/leeyejin1231/rv-hate/blob/main/eval.py): `eval.py`
- [Voting evaluation](https://github.com/leeyejin1231/rv-hate/blob/main/eval_hard_voting.py): `eval_hard_voting.py`
- [Soft voting](https://github.com/leeyejin1231/rv-hate/blob/main/eval_soft_voting.py): `eval_soft_voting.py`
- [Reinforcement evaluation](https://github.com/leeyejin1231/rv-hate/blob/main/ppo_eval.py): `ppo_eval.py`

### Other components

- **Researcher**

## Connections

- Researcher → Semantic preparation: prepares data (evidence: `README.md`)
- Semantic preparation → Context clustering: uses clustering (evidence: `utils/shared_semantics.py`)
- Researcher → Dataset preprocessing: tokenizes data (evidence: `README.md`)
- Dataset preprocessing → Dataset loader: supplies datasets (evidence: `README.md`)
- Dataset loader → Batch collation: selects collator (evidence: `utils/dataset_loader.py`)
- Researcher → Contrastive trainer: starts training (evidence: `README.md`)
- Contrastive trainer → Training settings: loads settings (evidence: `train.py`)
- Contrastive trainer → Dataset loader: loads batches (evidence: `train.py`)
- Contrastive trainer → Text encoder: encodes text (evidence: `train.py`)
- Contrastive trainer → Contrastive losses: computes loss (evidence: `train.py`)
- Researcher → Hard-negative trainer: trains module (evidence: `README.md`)
- Hard-negative trainer → Hard-negative settings: loads settings (evidence: `train_hard_negative.py`)
- Hard-negative trainer → Dataset loader: loads batches (evidence: `train_hard_negative.py`)
- Hard-negative trainer → Text encoder: encodes text (evidence: `train_hard_negative.py`)
- Hard-negative trainer → Hard-negative sampling: maintains queue (evidence: `train_hard_negative.py`)
- Researcher → Model evaluation: evaluates models (evidence: `README.md`)
- Model evaluation → Evaluation settings: loads settings (evidence: `eval.py`)
- Model evaluation → Text encoder: uses model (evidence: `eval.py`)
- Researcher → Voting evaluation: runs voting (evidence: `README.md`)
- Voting evaluation → Evaluation settings: loads settings (evidence: `eval_hard_voting.py`)
- Voting evaluation → Text encoder: uses model (evidence: `eval_hard_voting.py`)
- Researcher → Soft voting: runs voting (evidence: `README.md`)
- Soft voting → Evaluation settings: loads settings (evidence: `eval_soft_voting.py`)
- Soft voting → Text encoder: uses model (evidence: `eval_soft_voting.py`)
- Researcher → Reinforcement evaluation: runs evaluation (evidence: `README.md`)
- Reinforcement evaluation → Evaluation settings: loads settings (evidence: `ppo_eval.py`)
- Reinforcement evaluation → Text encoder: uses model (evidence: `ppo_eval.py`)
- Semantic preparation → Target tagging: tags targets (evidence: `utils/shared_semantics.py`)
- Semantic preparation → Outlier removal: removes outliers (evidence: `utils/shared_semantics.py`)
- Reinforcement evaluation → Voting evaluation: optimizes voting (evidence: `README.md`)
