qingy2024 commited on
Commit
14b6108
·
verified ·
1 Parent(s): e89e89a

Training in progress, step 2000

Browse files
.ipynb_checkpoints/upload-checkpoint.py CHANGED
@@ -23,7 +23,7 @@ TRAINER_STATE_FILENAME = "trainer_state.json"
23
  LOSS_PLOT_FILENAME = "loss.png"
24
 
25
  # Plotting Configuration
26
- LOSS_SMOOTHING_WINDOW = 30
27
 
28
  # Monitoring Configuration
29
  CHECKPOINT_DIR_PATTERN = re.compile(r"^checkpoint-(\d+)$")
@@ -120,10 +120,15 @@ library_name: peft
120
  """.strip()
121
  return readme_template
122
 
 
 
 
 
 
123
  def plot_loss_from_json(
124
  json_file_path: Path,
125
  output_image_path: Path,
126
- smooth_steps: int = LOSS_SMOOTHING_WINDOW
127
  ):
128
  """
129
  Reads training log data from a JSON file (trainer_state.json),
@@ -152,7 +157,7 @@ def plot_loss_from_json(
152
  print(f"An unexpected error occurred while reading {json_file_path}: {e}")
153
  return
154
 
155
- log_history = data.get("log_history") # Use .get for safer access
156
  if not isinstance(log_history, list):
157
  print(f"Error: 'log_history' key not found or not a list in {json_file_path}")
158
  return
@@ -184,23 +189,23 @@ def plot_loss_from_json(
184
  # Calculate Running Average
185
  smoothed_losses = None
186
  smoothed_steps = None
187
- apply_smoothing = smooth_steps > 0 and len(losses) >= smooth_steps
188
 
189
  if apply_smoothing:
190
  try:
191
  weights = np.ones(smooth_steps) / smooth_steps
192
- smoothed_losses = np.convolve(losses, weights, mode='valid')
193
- smoothed_steps = steps[smooth_steps - 1:] # Steps corresponding to the smoothed values
194
  print(f"Calculated smoothed loss over {len(smoothed_steps)} points.")
195
  except Exception as e:
196
  print(f"Warning: Could not calculate smoothed loss. Error: {e}")
197
- apply_smoothing = False # Disable if calculation fails
198
  elif smooth_steps > 0:
199
  print(f"Warning: Not enough data points ({len(losses)}) for smoothing window ({smooth_steps}). Skipping smoothing.")
200
 
201
  # Plotting
202
- plt.style.use('seaborn-v0_8-darkgrid') # Use a nice style
203
- plt.figure(figsize=(10, 6)) # Standard figure size
204
 
205
  plt.plot(steps, losses, linestyle='-', color='skyblue', alpha=0.5, label='Original Loss')
206
 
@@ -212,7 +217,7 @@ def plot_loss_from_json(
212
  plt.ylabel("Loss")
213
  plt.title("Training Loss Progression")
214
  plt.legend()
215
- plt.tight_layout() # Adjust layout
216
 
217
  # Saving
218
  try:
@@ -221,7 +226,7 @@ def plot_loss_from_json(
221
  except Exception as e:
222
  print(f"Error saving plot to {output_image_path}: {e}")
223
  finally:
224
- plt.close() # Ensure figure is closed to free memory
225
 
226
  def prepare_checkpoint_folder(checkpoint_path: Path, checkpoint_number: int):
227
  """
 
23
  LOSS_PLOT_FILENAME = "loss.png"
24
 
25
  # Plotting Configuration
26
+ LOSS_SMOOTHING_WINDOW = 40
27
 
28
  # Monitoring Configuration
29
  CHECKPOINT_DIR_PATTERN = re.compile(r"^checkpoint-(\d+)$")
 
120
  """.strip()
121
  return readme_template
122
 
123
+ import json
124
+ import numpy as np
125
+ import matplotlib.pyplot as plt
126
+ from pathlib import Path
127
+
128
  def plot_loss_from_json(
129
  json_file_path: Path,
130
  output_image_path: Path,
131
+ smooth_steps: int = 10 # Example default value for smooth_steps
132
  ):
133
  """
134
  Reads training log data from a JSON file (trainer_state.json),
 
157
  print(f"An unexpected error occurred while reading {json_file_path}: {e}")
158
  return
159
 
160
+ log_history = data.get("log_history") # Use .get for safer access
161
  if not isinstance(log_history, list):
162
  print(f"Error: 'log_history' key not found or not a list in {json_file_path}")
163
  return
 
189
  # Calculate Running Average
190
  smoothed_losses = None
191
  smoothed_steps = None
192
+ apply_smoothing = smooth_steps > 0
193
 
194
  if apply_smoothing:
195
  try:
196
  weights = np.ones(smooth_steps) / smooth_steps
197
+ smoothed_losses = np.convolve(losses, weights, mode='full')[:len(losses)]
198
+ smoothed_steps = steps # Steps corresponding to the smoothed values
199
  print(f"Calculated smoothed loss over {len(smoothed_steps)} points.")
200
  except Exception as e:
201
  print(f"Warning: Could not calculate smoothed loss. Error: {e}")
202
+ apply_smoothing = False # Disable if calculation fails
203
  elif smooth_steps > 0:
204
  print(f"Warning: Not enough data points ({len(losses)}) for smoothing window ({smooth_steps}). Skipping smoothing.")
205
 
206
  # Plotting
207
+ plt.style.use('seaborn-v0_8-darkgrid') # Use a nice style
208
+ plt.figure(figsize=(10, 6)) # Standard figure size
209
 
210
  plt.plot(steps, losses, linestyle='-', color='skyblue', alpha=0.5, label='Original Loss')
211
 
 
217
  plt.ylabel("Loss")
218
  plt.title("Training Loss Progression")
219
  plt.legend()
220
+ plt.tight_layout() # Adjust layout
221
 
222
  # Saving
223
  try:
 
226
  except Exception as e:
227
  print(f"Error saving plot to {output_image_path}: {e}")
228
  finally:
229
+ plt.close() # Ensure figure is closed to free memory
230
 
231
  def prepare_checkpoint_folder(checkpoint_path: Path, checkpoint_number: int):
232
  """
adapter_config.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "alpha_pattern": {},
3
  "auto_mapping": null,
4
- "base_model_name_or_path": "Qwen/Qwen2.5-7B-Instruct",
5
  "bias": "none",
6
  "eva_config": null,
7
  "exclude_modules": null,
 
1
  {
2
  "alpha_pattern": {},
3
  "auto_mapping": null,
4
+ "base_model_name_or_path": "./Qwen-2.5-7B-Instruct",
5
  "bias": "none",
6
  "eva_config": null,
7
  "exclude_modules": null,
adapter_model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:fcedc657eb350f98486269232f8cd45740cc1f77f201c5bced88439de5d4e75f
3
  size 161533192
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c7b7c7e22d18bb221ca73885bb0c6ded7c4cad69581153ddbe61260268f902cb
3
  size 161533192
upload.py CHANGED
@@ -23,7 +23,7 @@ TRAINER_STATE_FILENAME = "trainer_state.json"
23
  LOSS_PLOT_FILENAME = "loss.png"
24
 
25
  # Plotting Configuration
26
- LOSS_SMOOTHING_WINDOW = 30
27
 
28
  # Monitoring Configuration
29
  CHECKPOINT_DIR_PATTERN = re.compile(r"^checkpoint-(\d+)$")
@@ -120,10 +120,15 @@ library_name: peft
120
  """.strip()
121
  return readme_template
122
 
 
 
 
 
 
123
  def plot_loss_from_json(
124
  json_file_path: Path,
125
  output_image_path: Path,
126
- smooth_steps: int = LOSS_SMOOTHING_WINDOW
127
  ):
128
  """
129
  Reads training log data from a JSON file (trainer_state.json),
@@ -152,7 +157,7 @@ def plot_loss_from_json(
152
  print(f"An unexpected error occurred while reading {json_file_path}: {e}")
153
  return
154
 
155
- log_history = data.get("log_history") # Use .get for safer access
156
  if not isinstance(log_history, list):
157
  print(f"Error: 'log_history' key not found or not a list in {json_file_path}")
158
  return
@@ -184,23 +189,23 @@ def plot_loss_from_json(
184
  # Calculate Running Average
185
  smoothed_losses = None
186
  smoothed_steps = None
187
- apply_smoothing = smooth_steps > 0 and len(losses) >= smooth_steps
188
 
189
  if apply_smoothing:
190
  try:
191
  weights = np.ones(smooth_steps) / smooth_steps
192
- smoothed_losses = np.convolve(losses, weights, mode='valid')
193
- smoothed_steps = steps[smooth_steps - 1:] # Steps corresponding to the smoothed values
194
  print(f"Calculated smoothed loss over {len(smoothed_steps)} points.")
195
  except Exception as e:
196
  print(f"Warning: Could not calculate smoothed loss. Error: {e}")
197
- apply_smoothing = False # Disable if calculation fails
198
  elif smooth_steps > 0:
199
  print(f"Warning: Not enough data points ({len(losses)}) for smoothing window ({smooth_steps}). Skipping smoothing.")
200
 
201
  # Plotting
202
- plt.style.use('seaborn-v0_8-darkgrid') # Use a nice style
203
- plt.figure(figsize=(10, 6)) # Standard figure size
204
 
205
  plt.plot(steps, losses, linestyle='-', color='skyblue', alpha=0.5, label='Original Loss')
206
 
@@ -212,7 +217,7 @@ def plot_loss_from_json(
212
  plt.ylabel("Loss")
213
  plt.title("Training Loss Progression")
214
  plt.legend()
215
- plt.tight_layout() # Adjust layout
216
 
217
  # Saving
218
  try:
@@ -221,7 +226,7 @@ def plot_loss_from_json(
221
  except Exception as e:
222
  print(f"Error saving plot to {output_image_path}: {e}")
223
  finally:
224
- plt.close() # Ensure figure is closed to free memory
225
 
226
  def prepare_checkpoint_folder(checkpoint_path: Path, checkpoint_number: int):
227
  """
 
23
  LOSS_PLOT_FILENAME = "loss.png"
24
 
25
  # Plotting Configuration
26
+ LOSS_SMOOTHING_WINDOW = 40
27
 
28
  # Monitoring Configuration
29
  CHECKPOINT_DIR_PATTERN = re.compile(r"^checkpoint-(\d+)$")
 
120
  """.strip()
121
  return readme_template
122
 
123
+ import json
124
+ import numpy as np
125
+ import matplotlib.pyplot as plt
126
+ from pathlib import Path
127
+
128
  def plot_loss_from_json(
129
  json_file_path: Path,
130
  output_image_path: Path,
131
+ smooth_steps: int = 10 # Example default value for smooth_steps
132
  ):
133
  """
134
  Reads training log data from a JSON file (trainer_state.json),
 
157
  print(f"An unexpected error occurred while reading {json_file_path}: {e}")
158
  return
159
 
160
+ log_history = data.get("log_history") # Use .get for safer access
161
  if not isinstance(log_history, list):
162
  print(f"Error: 'log_history' key not found or not a list in {json_file_path}")
163
  return
 
189
  # Calculate Running Average
190
  smoothed_losses = None
191
  smoothed_steps = None
192
+ apply_smoothing = smooth_steps > 0
193
 
194
  if apply_smoothing:
195
  try:
196
  weights = np.ones(smooth_steps) / smooth_steps
197
+ smoothed_losses = np.convolve(losses, weights, mode='full')[:len(losses)]
198
+ smoothed_steps = steps # Steps corresponding to the smoothed values
199
  print(f"Calculated smoothed loss over {len(smoothed_steps)} points.")
200
  except Exception as e:
201
  print(f"Warning: Could not calculate smoothed loss. Error: {e}")
202
+ apply_smoothing = False # Disable if calculation fails
203
  elif smooth_steps > 0:
204
  print(f"Warning: Not enough data points ({len(losses)}) for smoothing window ({smooth_steps}). Skipping smoothing.")
205
 
206
  # Plotting
207
+ plt.style.use('seaborn-v0_8-darkgrid') # Use a nice style
208
+ plt.figure(figsize=(10, 6)) # Standard figure size
209
 
210
  plt.plot(steps, losses, linestyle='-', color='skyblue', alpha=0.5, label='Original Loss')
211
 
 
217
  plt.ylabel("Loss")
218
  plt.title("Training Loss Progression")
219
  plt.legend()
220
+ plt.tight_layout() # Adjust layout
221
 
222
  # Saving
223
  try:
 
226
  except Exception as e:
227
  print(f"Error saving plot to {output_image_path}: {e}")
228
  finally:
229
+ plt.close() # Ensure figure is closed to free memory
230
 
231
  def prepare_checkpoint_folder(checkpoint_path: Path, checkpoint_number: int):
232
  """