Ani-404 commited on
Commit
39c18ce
·
1 Parent(s): 0194fbd

updated training script

Browse files
Files changed (1) hide show
  1. 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 Environment ---
31
- # This path points directly to the file inside your Google Drive
32
- data_path = "/content/drive/MyDrive/Colab_Data/emotion_dataset.csv"
33
- # This is where the final trained model will be saved in your Google Drive
34
- output_dir = "/content/drive/MyDrive/Colab_Data/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 '/content/drive/MyDrive/Colab_Data/'.")
42
- print("Please make sure you have uploaded the file to the correct Google Drive folder.")
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, # Safe batch size for Colab GPU
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",