# thienandinh29/financial-sentiment-dl architecture

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

- Interactive diagram: https://gitdiagram.com/thienandinh29/financial-sentiment-dl
- Repository: https://github.com/thienandinh29/financial-sentiment-dl

## Overview

This repository is a research pipeline for classifying English financial-news headlines as bearish, neutral, or bullish, with emphasis on leakage-resistant experiments and measured generalization. The main workflow prepares and splits data, trains configured classifiers, records predictions and run metadata, then scores validation and compares results statistically; the README also describes 2026 out-of-distribution and PhraseBank evaluation. The graph includes the documented labeling and inference/demo branches, though their implementation is absent or unsampled here. Edges reflect explicit README workflow statements or shown calls/import references; unverified optional branches are dashed.

Main entry points: [`train/run.py`](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/train/run.py) (Experiment Runner), [`evaluate/metrics.py`](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/evaluate/metrics.py) (Classification Metrics), [`results`](https://github.com/thienandinh29/financial-sentiment-dl/tree/main/results) (Run Predictions), [`scripts/eda.py`](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/scripts/eda.py) (Data Preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data and Integrity"]
  node_sources[("Headline Datasets<br/>[README.md]")]
  node_prep["Data Preparation<br/>[eda.py]"]
  node_dedup["Near-Duplicate Analysis<br/>[dedup.py]"]
  node_splits["Leakage-Resistant Splits<br/>[make_splits.py]"]
  node_splitdata["Verified Split Loader<br/>[data.py]"]
end

subgraph group_learning["Models and Training"]
  node_configs["Experiment Configs<br/>[E0.yaml]"]
  node_tokenizer["Text Tokenization<br/>[tokenizer.py]"]
  node_embeddings["Vocabulary and Embeddings<br/>[embeddings.py]"]
  node_classifiers["Neural Classifiers"]
  node_textcnn["TextCNN<br/>[textcnn.py]"]
  node_transformer["Transformer Models<br/>[transformer.py]"]
  node_softlabels["LLM Soft Labels<br/>[llm_soft_labels.py]"]
  node_losses["Training Losses<br/>[losses.py]"]
  node_trainer["Experiment Runner<br/>[run.py]"]
  node_loop["Training Loop<br/>[loop.py]"]
  node_runlog["Run Provenance<br/>[runlog.py]"]
end

subgraph group_evaluation["Evaluation and Research"]
  node_predictions[("Run Predictions")]
  node_metrics["Classification Metrics<br/>[metrics.py]"]
  node_stats["Statistical Comparisons<br/>[stats.py]"]
  node_results[("Experiment Results")]
end

subgraph group_product["Labeling and Serving"]
  node_labeling["Human Labeling<br/>[GUIDE.md]"]
  node_inference["Inference API"]
  node_demo["Gradio Demo"]
end

node_researcher(("Researcher"))
node_llm{{"External LLM"}}
node_ood[("2026 OOD Headlines")]
node_phrasebank[("PhraseBank Test Set")]

node_researcher -->|"prepares data"| node_prep
node_sources -->|"supplies datasets"| node_prep
node_prep -.->|"analyzes duplicates"| node_dedup
node_dedup -.->|"informs grouping"| node_splits
node_splits -->|"writes ID splits"| node_splitdata
node_researcher -->|"runs experiments"| node_trainer
node_configs -->|"configures runs"| node_trainer
node_splitdata -->|"provides examples"| node_trainer
node_trainer -->|"builds embeddings"| node_embeddings
node_embeddings -->|"tokenizes text"| node_tokenizer
node_trainer -->|"builds registered model"| node_classifiers
node_trainer -->|"builds registered model"| node_textcnn
node_trainer -.->|"runs transformer"| node_transformer
node_trainer -->|"builds loss"| node_losses
node_trainer -->|"trains model"| node_loop
node_trainer -->|"records provenance"| node_runlog
node_loop -->|"optimizes model"| node_classifiers
node_trainer -->|"writes predictions"| node_predictions
node_researcher -->|"scores validation"| node_metrics
node_predictions -->|"provides predictions"| node_metrics
node_metrics -->|"loads gold labels"| node_splitdata
node_metrics -.->|"reports scores"| node_results
node_researcher -->|"compares experiments"| node_stats
node_predictions -.->|"supplies paired outputs"| node_stats
node_researcher -->|"annotates headlines"| node_labeling
node_ood -.->|"receives annotations"| node_labeling
node_llm -.->|"generates soft labels"| node_softlabels
node_softlabels -.->|"supports distillation"| node_trainer
node_ood -.->|"evaluates out-of-domain"| node_metrics
node_phrasebank -.->|"evaluates out-of-domain"| node_metrics
node_trainer -.->|"exports model"| node_inference
node_researcher -.->|"uses demo"| node_demo
node_demo -.->|"calls inference"| node_inference

click node_sources "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/data/README.md"
click node_prep "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/scripts/eda.py"
click node_dedup "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/scripts/dedup.py"
click node_splits "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/scripts/make_splits.py"
click node_splitdata "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/train/data.py"
click node_configs "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/configs/E0.yaml"
click node_tokenizer "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/models/tokenizer.py"
click node_embeddings "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/models/embeddings.py"
click node_classifiers "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/models/bilstm_attention.py"
click node_textcnn "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/models/textcnn.py"
click node_transformer "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/models/transformer.py"
click node_softlabels "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/models/llm_soft_labels.py"
click node_losses "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/train/losses.py"
click node_trainer "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/train/run.py"
click node_loop "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/train/loop.py"
click node_runlog "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/train/runlog.py"
click node_predictions "https://github.com/thienandinh29/financial-sentiment-dl/tree/main/results"
click node_metrics "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/evaluate/metrics.py"
click node_stats "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/evaluate/stats.py"
click node_results "https://github.com/thienandinh29/financial-sentiment-dl/tree/main/results"
click node_labeling "https://github.com/thienandinh29/financial-sentiment-dl/blob/main/labeling/GUIDE.md"
click node_inference "https://github.com/thienandinh29/financial-sentiment-dl/tree/main/inference"
click node_demo "https://github.com/thienandinh29/financial-sentiment-dl/tree/main/app"

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_sources,node_prep,node_dedup,node_splits,node_splitdata toneBlue
class node_configs,node_tokenizer,node_embeddings,node_classifiers,node_textcnn,node_transformer,node_softlabels,node_losses,node_trainer,node_loop,node_runlog,node_ood,node_phrasebank toneAmber
class node_predictions,node_metrics,node_stats,node_results toneMint
class node_labeling,node_inference,node_demo toneRose
class node_researcher,node_llm toneIndigo
```

## Components

### Data and Integrity

- [Headline Datasets](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/data/README.md): `data/README.md`
- [Data Preparation](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/scripts/eda.py): `scripts/eda.py`
- [Near-Duplicate Analysis](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/scripts/dedup.py): `scripts/dedup.py`
- [Leakage-Resistant Splits](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/scripts/make_splits.py): `scripts/make_splits.py`
- [Verified Split Loader](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/train/data.py): `train/data.py`

### Models and Training

- [Experiment Configs](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/configs/E0.yaml): `configs/E0.yaml`
- [Text Tokenization](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/models/tokenizer.py): `models/tokenizer.py`
- [Vocabulary and Embeddings](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/models/embeddings.py): `models/embeddings.py`
- [Neural Classifiers](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/models/bilstm_attention.py): `models/bilstm_attention.py`
- [TextCNN](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/models/textcnn.py): `models/textcnn.py`
- [Transformer Models](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/models/transformer.py): `models/transformer.py`
- [LLM Soft Labels](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/models/llm_soft_labels.py): `models/llm_soft_labels.py`
- [Training Losses](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/train/losses.py): `train/losses.py`
- [Experiment Runner](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/train/run.py): `train/run.py`
- [Training Loop](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/train/loop.py): `train/loop.py`
- [Run Provenance](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/train/runlog.py): `train/runlog.py`

### Evaluation and Research

- [Run Predictions](https://github.com/thienandinh29/financial-sentiment-dl/tree/main/results): `results`
- [Classification Metrics](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/evaluate/metrics.py): `evaluate/metrics.py`
- [Statistical Comparisons](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/evaluate/stats.py): `evaluate/stats.py`
- [Experiment Results](https://github.com/thienandinh29/financial-sentiment-dl/tree/main/results): `results`

### Labeling and Serving

- [Human Labeling](https://github.com/thienandinh29/financial-sentiment-dl/blob/main/labeling/GUIDE.md): `labeling/GUIDE.md`
- [Inference API](https://github.com/thienandinh29/financial-sentiment-dl/tree/main/inference): `inference`
- [Gradio Demo](https://github.com/thienandinh29/financial-sentiment-dl/tree/main/app): `app`

### Other components

- **Researcher**
- **External LLM**
- **2026 OOD Headlines**
- **PhraseBank Test Set**

## Connections

- Researcher → Data Preparation: prepares data (evidence: `README.md`)
- Headline Datasets → Data Preparation: supplies datasets (evidence: `README.md`)
- Data Preparation → Near-Duplicate Analysis: analyzes duplicates
- Near-Duplicate Analysis → Leakage-Resistant Splits: informs grouping
- Leakage-Resistant Splits → Verified Split Loader: writes ID splits (evidence: `scripts/make_splits.py`)
- Researcher → Experiment Runner: runs experiments (evidence: `README.md`)
- Experiment Configs → Experiment Runner: configures runs (evidence: `train/run.py`)
- Verified Split Loader → Experiment Runner: provides examples (evidence: `train/run.py`)
- Experiment Runner → Vocabulary and Embeddings: builds embeddings (evidence: `train/run.py`)
- Vocabulary and Embeddings → Text Tokenization: tokenizes text (evidence: `models/embeddings.py`)
- Experiment Runner → Neural Classifiers: builds registered model (evidence: `train/run.py`)
- Experiment Runner → TextCNN: builds registered model (evidence: `train/run.py`)
- Experiment Runner → Transformer Models: runs transformer
- Experiment Runner → Training Losses: builds loss (evidence: `train/run.py`)
- Experiment Runner → Training Loop: trains model (evidence: `train/run.py`)
- Experiment Runner → Run Provenance: records provenance (evidence: `train/run.py`)
- Training Loop → Neural Classifiers: optimizes model (evidence: `train/loop.py`)
- Experiment Runner → Run Predictions: writes predictions (evidence: `train/run.py`)
- Researcher → Classification Metrics: scores validation (evidence: `README.md`)
- Run Predictions → Classification Metrics: provides predictions (evidence: `evaluate/metrics.py`)
- Classification Metrics → Verified Split Loader: loads gold labels (evidence: `evaluate/metrics.py`)
- Classification Metrics → Experiment Results: reports scores
- Researcher → Statistical Comparisons: compares experiments (evidence: `README.md`)
- Run Predictions → Statistical Comparisons: supplies paired outputs
- Researcher → Human Labeling: annotates headlines (evidence: `README.md`)
- 2026 OOD Headlines → Human Labeling: receives annotations
- External LLM → LLM Soft Labels: generates soft labels
- LLM Soft Labels → Experiment Runner: supports distillation
- 2026 OOD Headlines → Classification Metrics: evaluates out-of-domain
- PhraseBank Test Set → Classification Metrics: evaluates out-of-domain
- Experiment Runner → Inference API: exports model
- Researcher → Gradio Demo: uses demo
- Gradio Demo → Inference API: calls inference
