# fakhahmed/fine-tuning-slm architecture

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

- Interactive diagram: https://gitdiagram.com/fakhahmed/fine-tuning-slm
- Repository: https://github.com/fakhahmed/fine-tuning-slm

## Overview

Le dépôt met en œuvre une chaîne de sentiment financier : préparation et versionnement des données, fine-tuning LoRA, suivi des expériences et inférence web. Le code de téléchargement, d’entraînement et de serving est visible dans `src/`; le notebook et les intégrations cloud sont décrits par le README, sans être inspectés ici. Les liens documentés uniquement par le README sont indiqués comme tels dans leurs preuves.

Main entry points: [`src/train.py`](https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/train.py) (Fine-tuning LoRA), [`src/app.py`](https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/app.py) (Interface Gradio), [`data/financial_dataset.jsonl.dvc`](https://github.com/fakhahmed/fine-tuning-slm/blob/main/data/financial_dataset.jsonl.dvc) (Dataset JSONL), [`src/download_data.py`](https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/download_data.py) (Téléchargement et formatage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Données financières"]
  node_source_dataset[("FinancialPhraseBank")]
  node_download["Téléchargement et formatage<br/>[download_data.py]"]
  node_dataset[("Dataset JSONL")]
  node_dvc["Versionnement DVC"]
  node_gcs[("Google Cloud Storage")]
end

subgraph group_training["Fine-tuning"]
  node_notebook["Laboratoire d’entraînement"]
  node_trainer["Fine-tuning LoRA<br/>[train.py]"]
  node_base_model["Llama 3 quantifié"]
  node_adapter["Adaptateur LoRA<br/>[train.py]"]
end

subgraph group_tracking["Suivi des expériences"]
  node_mlflow["Tracking MLflow<br/>[train.py]"]
  node_cloud_tracking["MLflow sur Cloud Run"]
  node_cloud_sql[("Cloud SQL")]
end

subgraph group_serving["Inférence"]
  node_app["Interface Gradio<br/>[app.py]"]
  node_inference_model["Modèle assemblé<br/>[app.py]"]
  node_hub_adapter["Adaptateur Hugging Face"]
  node_spaces["Hugging Face Spaces"]
  node_sentiment["Sentiment prédit<br/>[app.py]"]
end

node_user(("Utilisateur"))
node_visitor(("Visiteur web"))

node_source_dataset -->|"fournit les données"| node_download
node_download -->|"écrit JSONL"| node_dataset
node_dataset -->|"versionné par"| node_dvc
node_dvc -->|"stocké sur"| node_gcs
node_notebook -.->|"orchestre l’entraînement"| node_trainer
node_trainer -->|"charge le dataset"| node_dataset
node_trainer -->|"charge le modèle"| node_base_model
node_trainer -->|"entraîne et sauvegarde"| node_adapter
node_trainer -->|"enregistre les métriques"| node_mlflow
node_mlflow -->|"utilise le serveur distant"| node_cloud_tracking
node_cloud_tracking -->|"stocke les expériences"| node_cloud_sql
node_visitor -->|"soumet une phrase"| node_app
node_app -->|"charge le modèle de base"| node_base_model
node_app -->|"charge l’adaptateur"| node_hub_adapter
node_app -->|"assemble et interroge"| node_inference_model
node_inference_model -->|"génère une prédiction"| node_sentiment
node_app -->|"hébergée sur"| node_spaces
node_hub_adapter -.->|"publie le modèle fine-tuné"| node_adapter

click node_download "https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/download_data.py"
click node_dataset "https://github.com/fakhahmed/fine-tuning-slm/blob/main/data/financial_dataset.jsonl.dvc"
click node_dvc "https://github.com/fakhahmed/fine-tuning-slm/blob/main/data/financial_dataset.jsonl.dvc"
click node_notebook "https://github.com/fakhahmed/fine-tuning-slm/blob/main/notebooks/finetuning_slm.ipynb"
click node_trainer "https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/train.py"
click node_adapter "https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/train.py"
click node_mlflow "https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/train.py"
click node_app "https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/app.py"
click node_inference_model "https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/app.py"
click node_sentiment "https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/app.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_source_dataset,node_download,node_dataset,node_dvc,node_gcs toneBlue
class node_notebook,node_trainer,node_base_model,node_adapter toneAmber
class node_mlflow,node_cloud_tracking,node_cloud_sql toneMint
class node_app,node_inference_model,node_hub_adapter,node_spaces,node_sentiment toneRose
class node_user,node_visitor toneIndigo
```

## Components

### Données financières

- **FinancialPhraseBank**
- [Téléchargement et formatage](https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/download_data.py): `src/download_data.py`
- [Dataset JSONL](https://github.com/fakhahmed/fine-tuning-slm/blob/main/data/financial_dataset.jsonl.dvc): `data/financial_dataset.jsonl.dvc`
- [Versionnement DVC](https://github.com/fakhahmed/fine-tuning-slm/blob/main/data/financial_dataset.jsonl.dvc): `data/financial_dataset.jsonl.dvc`
- **Google Cloud Storage**

### Fine-tuning

- [Laboratoire d’entraînement](https://github.com/fakhahmed/fine-tuning-slm/blob/main/notebooks/finetuning_slm.ipynb): `notebooks/finetuning_slm.ipynb`
- [Fine-tuning LoRA](https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/train.py): `src/train.py`
- **Llama 3 quantifié**
- [Adaptateur LoRA](https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/train.py): `src/train.py`

### Suivi des expériences

- [Tracking MLflow](https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/train.py): `src/train.py`
- **MLflow sur Cloud Run**
- **Cloud SQL**

### Inférence

- [Interface Gradio](https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/app.py): `src/app.py`
- [Modèle assemblé](https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/app.py): `src/app.py`
- **Adaptateur Hugging Face**
- **Hugging Face Spaces**
- [Sentiment prédit](https://github.com/fakhahmed/fine-tuning-slm/blob/main/src/app.py): `src/app.py`

### Other components

- **Utilisateur**
- **Visiteur web**

## Connections

- FinancialPhraseBank → Téléchargement et formatage: fournit les données (evidence: `src/download_data.py`)
- Téléchargement et formatage → Dataset JSONL: écrit JSONL (evidence: `src/download_data.py`)
- Dataset JSONL → Versionnement DVC: versionné par (evidence: `README.md`)
- Versionnement DVC → Google Cloud Storage: stocké sur (evidence: `README.md`)
- Laboratoire d’entraînement → Fine-tuning LoRA: orchestre l’entraînement (evidence: `README.md`)
- Fine-tuning LoRA → Dataset JSONL: charge le dataset (evidence: `src/train.py`)
- Fine-tuning LoRA → Llama 3 quantifié: charge le modèle (evidence: `src/train.py`)
- Fine-tuning LoRA → Adaptateur LoRA: entraîne et sauvegarde (evidence: `src/train.py`)
- Fine-tuning LoRA → Tracking MLflow: enregistre les métriques (evidence: `src/train.py`)
- Tracking MLflow → MLflow sur Cloud Run: utilise le serveur distant (evidence: `README.md`)
- MLflow sur Cloud Run → Cloud SQL: stocke les expériences (evidence: `README.md`)
- Visiteur web → Interface Gradio: soumet une phrase (evidence: `src/app.py`)
- Interface Gradio → Llama 3 quantifié: charge le modèle de base (evidence: `src/app.py`)
- Interface Gradio → Adaptateur Hugging Face: charge l’adaptateur (evidence: `src/app.py`)
- Interface Gradio → Modèle assemblé: assemble et interroge (evidence: `src/app.py`)
- Modèle assemblé → Sentiment prédit: génère une prédiction (evidence: `src/app.py`)
- Interface Gradio → Hugging Face Spaces: hébergée sur (evidence: `README.md`)
- Adaptateur Hugging Face → Adaptateur LoRA: publie le modèle fine-tuné (evidence: `README.md`)
