# spyysalo/finbert-text-classification architecture

> Architecture diagram of the GitHub repository spyysalo/finbert-text-classification, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/spyysalo/finbert-text-classification
- Repository: https://github.com/spyysalo/finbert-text-classification

## Overview

This repository runs Finnish text-classification experiments with BERT for the Yle and Ylilauta tasks. The main workflow reads labeled corpus splits, selects task labels, and runs training, evaluation, and/or prediction; prediction writes results to the configured output directory. Separate utilities summarize experiment logs and select the best parameter sets. The classifier excerpt shows calls into the bundled BERT code, but the BERT implementation and corpus contents were not sampled, so their internal stages and finer-grained data flow are not represented.

Main entry points: [`run_classifier.py`](https://github.com/spyysalo/finbert-text-classification/blob/master/run_classifier.py) (BERT classifier), [`select_params.py`](https://github.com/spyysalo/finbert-text-classification/blob/master/select_params.py) (Parameter selector), [`summarize.py`](https://github.com/spyysalo/finbert-text-classification/blob/master/summarize.py) (Log summarizer), [`bert`](https://github.com/spyysalo/finbert-text-classification/tree/master/bert) (BERT toolkit)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_classification["Classification"]
  node_classifier["BERT classifier<br/>[run_classifier.py]"]
  node_bert["BERT toolkit"]
end

subgraph group_data["Data"]
  node_task_labels["Task labels<br/>[task_config.py]"]
  node_yle_corpus["Yle corpus"]
  node_ylilauta_corpus["Ylilauta corpus"]
end

subgraph group_analysis["Experiment analysis"]
  node_summarizer["Log summarizer<br/>[summarize.py]"]
  node_selector["Parameter selector<br/>[select_params.py]"]
end

node_user(("Experiment operator"))
node_tensorflow["TensorFlow runtime"]
node_checkpoint["BERT checkpoint"]
node_predictions["Prediction results"]
node_log_files["Experiment logs"]

node_user -->|"runs"| node_classifier
node_classifier -->|"reads splits"| node_yle_corpus
node_classifier -->|"reads splits"| node_ylilauta_corpus
node_classifier -->|"loads labels"| node_task_labels
node_classifier -->|"calls APIs"| node_bert
node_classifier -->|"runs estimator"| node_tensorflow
node_classifier -->|"loads checkpoint"| node_checkpoint
node_classifier -->|"writes results"| node_predictions
node_user -->|"runs"| node_summarizer
node_summarizer -->|"reads logs"| node_log_files
node_user -->|"runs"| node_selector
node_selector -->|"reads logs"| node_log_files
node_selector -->|"calls log reader"| node_summarizer

click node_classifier "https://github.com/spyysalo/finbert-text-classification/blob/master/run_classifier.py"
click node_bert "https://github.com/spyysalo/finbert-text-classification/tree/master/bert"
click node_task_labels "https://github.com/spyysalo/finbert-text-classification/blob/master/task_config.py"
click node_yle_corpus "https://github.com/spyysalo/finbert-text-classification/tree/master/yle-corpus"
click node_ylilauta_corpus "https://github.com/spyysalo/finbert-text-classification/tree/master/ylilauta-corpus"
click node_summarizer "https://github.com/spyysalo/finbert-text-classification/blob/master/summarize.py"
click node_selector "https://github.com/spyysalo/finbert-text-classification/blob/master/select_params.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_classifier,node_bert toneBlue
class node_task_labels,node_yle_corpus,node_ylilauta_corpus toneAmber
class node_summarizer,node_selector toneMint
class node_user,node_tensorflow,node_checkpoint,node_predictions,node_log_files toneIndigo
```

## Components

### Classification

- [BERT classifier](https://github.com/spyysalo/finbert-text-classification/blob/master/run_classifier.py): `run_classifier.py`
- [BERT toolkit](https://github.com/spyysalo/finbert-text-classification/tree/master/bert): `bert`

### Data

- [Task labels](https://github.com/spyysalo/finbert-text-classification/blob/master/task_config.py): `task_config.py`
- [Yle corpus](https://github.com/spyysalo/finbert-text-classification/tree/master/yle-corpus): `yle-corpus`
- [Ylilauta corpus](https://github.com/spyysalo/finbert-text-classification/tree/master/ylilauta-corpus): `ylilauta-corpus`

### Experiment analysis

- [Log summarizer](https://github.com/spyysalo/finbert-text-classification/blob/master/summarize.py): `summarize.py`
- [Parameter selector](https://github.com/spyysalo/finbert-text-classification/blob/master/select_params.py): `select_params.py`

### Other components

- **Experiment operator**
- **TensorFlow runtime**
- **BERT checkpoint**
- **Prediction results**
- **Experiment logs**

## Connections

- Experiment operator → BERT classifier: runs
- BERT classifier → Yle corpus: reads splits
- BERT classifier → Ylilauta corpus: reads splits
- BERT classifier → Task labels: loads labels
- BERT classifier → BERT toolkit: calls APIs
- BERT classifier → TensorFlow runtime: runs estimator
- BERT classifier → BERT checkpoint: loads checkpoint
- BERT classifier → Prediction results: writes results
- Experiment operator → Log summarizer: runs
- Log summarizer → Experiment logs: reads logs
- Experiment operator → Parameter selector: runs
- Parameter selector → Experiment logs: reads logs
- Parameter selector → Log summarizer: calls log reader
