Create train_advanced.py
Browse files- train_advanced.py +29 -0
train_advanced.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import wandb
|
| 3 |
+
from transformers import TrainerCallback
|
| 4 |
+
|
| 5 |
+
# Setup logging
|
| 6 |
+
logging.basicConfig(
|
| 7 |
+
level=logging.INFO,
|
| 8 |
+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
| 9 |
+
handlers=[
|
| 10 |
+
logging.FileHandler('training.log'),
|
| 11 |
+
logging.StreamHandler()
|
| 12 |
+
]
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
class CustomCallback(TrainerCallback):
|
| 16 |
+
def on_log(self, args, state, control, logs=None, **kwargs):
|
| 17 |
+
if logs:
|
| 18 |
+
logging.info(f"Step {state.global_step}: {logs}")
|
| 19 |
+
|
| 20 |
+
def on_epoch_end(self, args, state, control, **kwargs):
|
| 21 |
+
logging.info(f"Epoch {state.epoch} completed")
|
| 22 |
+
|
| 23 |
+
def setup_wandb():
|
| 24 |
+
wandb.init(project="OrcaleSeek", entity="your-username")
|
| 25 |
+
wandb.config = {
|
| 26 |
+
"learning_rate": 2e-5,
|
| 27 |
+
"architecture": "OrcaleSeek",
|
| 28 |
+
"dataset": "Your-Dataset",
|
| 29 |
+
}
|