Skip to content

Commit b10f0d8

Browse files
committed
bert learning
1 parent b914795 commit b10f0d8

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
1-
# sentimental_analyses
2-
Tweet sentimental analyses
1+
# Sentimental analyses with MLFLOW and models Wrappers
32

3+
Tweet sentimental analyses with different models.
4+
5+
Four wrapper of models:
6+
- Logistic Regression
7+
- Random Forest
8+
- LightGBM
9+
- Bert
10+
- Roberta
11+
- LSTM
12+
13+
MLFlow is used to list all experiments and easily commpare results for several differents configurations and select the bests
14+
15+
Optuna is used to optimise parameters. It run a set of experiments with a variation of parameters and select the best configuration
16+
maximising the accuraty
17+
18+
19+
The app is dockerised and can be installed launching the command
20+
```bash
21+
docker compose up
22+
```
23+
or to run in background
24+
```bash
25+
docker compose up -d
26+
```
27+
28+
## Access and architecture
29+
The application contains alerting system and monitoring on grafana on port 3000
30+
MLFLO
31+
32+
## Installation in dev
433
# Install uv (Rust package to fastly install package)
534
```bash
635
curl -Ls https://astral.sh/uv/install.sh | bash

src/ml.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from sklearn.metrics import confusion_matrix, classification_report
2424
from sklearn.ensemble import RandomForestClassifier
2525
import seaborn as sns
26-
from transformers import AutoTokenizer, AutoModelForSequenceClassification
26+
from transformers import AutoTokenizer, AutoModelForSequenceClassification, get_linear_schedule_with_warmup
2727
import pandas as pd
2828
from skopt import BayesSearchCV, gp_minimize
2929
from skopt.space import Real, Categorical
@@ -421,8 +421,11 @@ def load_checkpoint(self):
421421
self.parralle_model()
422422

423423
self.optimizer = torch.optim.Adam(self.model.parameters(), lr=self.lr)
424-
self.scheduler = torch.optim.lr_scheduler.StepLR(
425-
self.optimizer, step_size=8, gamma=0.248
424+
total_steps = len(self.dataloader) * self.epoch
425+
self.scheduler = get_linear_schedule_with_warmup(
426+
self.optimizer,
427+
num_warmup_steps=int(0.1 * total_steps), # 10% warmup
428+
num_training_steps=total_steps
426429
)
427430
self.criterion = torch.nn.CrossEntropyLoss()
428431

0 commit comments

Comments
 (0)