updated training script
Browse files- finance/train_finbert.py +8 -8
finance/train_finbert.py
CHANGED
|
@@ -27,19 +27,19 @@ def compute_metrics(p):
|
|
| 27 |
|
| 28 |
def main():
|
| 29 |
"""Main function to load data, fine-tune the FinBERT model, and save it."""
|
| 30 |
-
# --- 1. Define Paths for Colab
|
| 31 |
-
# This path points
|
| 32 |
-
data_path = "/content/
|
| 33 |
-
#
|
| 34 |
-
output_dir = "/content/
|
| 35 |
|
| 36 |
# --- 2. Load and Prepare the Dataset ---
|
| 37 |
print(f"Loading dataset from: {data_path}")
|
| 38 |
try:
|
| 39 |
df = pd.read_csv(data_path)
|
| 40 |
except FileNotFoundError:
|
| 41 |
-
print("ERROR: 'emotion_dataset.csv' not found in
|
| 42 |
-
print("Please make sure you have uploaded the file
|
| 43 |
return
|
| 44 |
|
| 45 |
print("Dataset loaded successfully. Preprocessing data...")
|
|
@@ -83,7 +83,7 @@ def main():
|
|
| 83 |
training_args = TrainingArguments(
|
| 84 |
output_dir=output_dir,
|
| 85 |
num_train_epochs=1,
|
| 86 |
-
per_device_train_batch_size=16,
|
| 87 |
per_device_eval_batch_size=16,
|
| 88 |
logging_steps=100,
|
| 89 |
evaluation_strategy="epoch",
|
|
|
|
| 27 |
|
| 28 |
def main():
|
| 29 |
"""Main function to load data, fine-tune the FinBERT model, and save it."""
|
| 30 |
+
# --- 1. Define Paths for Colab's Temporary Session Storage ---
|
| 31 |
+
# This path points to the file you just uploaded.
|
| 32 |
+
data_path = "/content/emotion_dataset.csv"
|
| 33 |
+
# The final model will be saved here, in the temporary storage.
|
| 34 |
+
output_dir = "/content/finbert_emotion_model"
|
| 35 |
|
| 36 |
# --- 2. Load and Prepare the Dataset ---
|
| 37 |
print(f"Loading dataset from: {data_path}")
|
| 38 |
try:
|
| 39 |
df = pd.read_csv(data_path)
|
| 40 |
except FileNotFoundError:
|
| 41 |
+
print("ERROR: 'emotion_dataset.csv' not found in the Colab session storage.")
|
| 42 |
+
print("Please make sure you have uploaded the file using the folder icon on the left.")
|
| 43 |
return
|
| 44 |
|
| 45 |
print("Dataset loaded successfully. Preprocessing data...")
|
|
|
|
| 83 |
training_args = TrainingArguments(
|
| 84 |
output_dir=output_dir,
|
| 85 |
num_train_epochs=1,
|
| 86 |
+
per_device_train_batch_size=16,
|
| 87 |
per_device_eval_batch_size=16,
|
| 88 |
logging_steps=100,
|
| 89 |
evaluation_strategy="epoch",
|