Theskywalker07 commited on
Commit
690ae41
·
verified ·
1 Parent(s): 1ecc8b5

Upload GPT-2 Strict-Small 16k BPE model, checkpoints, and logs

Browse files
Files changed (1) hide show
  1. run_lightning_eval.py +42 -44
run_lightning_eval.py CHANGED
@@ -1,9 +1,10 @@
1
  """
2
  Lightning AI Evaluation Runner for BabyLM 2026 Strict-Small Track
3
- Follows exact order requested:
 
4
  1. Full Zero-Shot Evaluation
5
- 2. Fine-Tuning Evaluation
6
- 3. Fast Evaluation & Score Collating / Zipping
7
  """
8
 
9
  import os
@@ -11,9 +12,9 @@ import sys
11
  import shutil
12
  import subprocess
13
 
14
- def run_cmd(cmd, cwd=None):
15
  print(f"\n[RUNNING] {cmd}")
16
- res = subprocess.run(cmd, shell=True, cwd=cwd)
17
  print(f"[STATUS] Exit Code: {res.returncode}")
18
  return res.returncode
19
 
@@ -43,23 +44,21 @@ def main():
43
  if not os.path.exists(eval_repo_dir):
44
  run_cmd("git clone https://github.com/babylm-org/babylm-eval.git", cwd=base_dir)
45
 
 
 
 
 
 
 
 
 
46
  # 2. Install dependencies via requirements.txt
47
  print("\n[Setup] Installing dependencies...")
48
  req_file = find_script(eval_repo_dir, ["requirements.txt"])
49
  if req_file:
50
- run_cmd(f"pip install -r {req_file}", cwd=os.path.dirname(req_file))
51
  else:
52
- run_cmd("pip install evaluate scikit-learn lm-eval datasets transformers", cwd=eval_repo_dir)
53
-
54
- # List structure of babylm-eval for debugging transparency
55
- print("\n[Inspection] Discovered files inside babylm-eval:")
56
- found_files = []
57
- for root, _, files in os.walk(eval_repo_dir):
58
- for f in files:
59
- rel = os.path.relpath(os.path.join(root, f), eval_repo_dir)
60
- if not rel.startswith(".git"):
61
- found_files.append(rel)
62
- print(f" - {rel}")
63
 
64
  # ------------------------------------------------------------
65
  # STEP 1: FULL ZERO-SHOT EVALUATION FIRST
@@ -68,39 +67,32 @@ def main():
68
  print(" STEP 1: FULL ZERO-SHOT EVALUATION")
69
  print("="*65)
70
 
71
- zeroshot_py = find_script(eval_repo_dir, ["eval_pipeline.py", "eval_zero_shot.py", "zeroshot.py", "eval_model.py"])
72
- zeroshot_sh = find_script(eval_repo_dir, ["zeroshot_model.sh", "run_zeroshot.sh"])
73
-
74
- if zeroshot_py:
75
- script_dir = os.path.dirname(zeroshot_py)
76
- script_name = os.path.basename(zeroshot_py)
77
- run_cmd(f"python {script_name} --model_path {checkpoint_dir} --task causal --type zeroshot", cwd=script_dir)
78
- elif zeroshot_sh:
79
- script_dir = os.path.dirname(zeroshot_sh)
80
- script_name = os.path.basename(zeroshot_sh)
81
- run_cmd(f"bash {script_name} {checkpoint_dir} causal strict_small", cwd=script_dir)
82
  else:
83
  print("[Notice] Running fallback zero-shot lm-eval on checkpoints...")
84
- run_cmd(f"lm_eval --model hf --model_args pretrained={checkpoint_dir}/main --tasks blimp --batch_size 16", cwd=eval_repo_dir)
85
 
86
  # ------------------------------------------------------------
87
- # STEP 2: FINE-TUNING (GLUE / CLASSIFICATION) EVALUATION SECOND
88
  # ------------------------------------------------------------
89
  print("\n" + "="*65)
90
  print(" STEP 2: FINE-TUNING (GLUE CLASSIFICATION) EVALUATION")
91
  print("="*65)
92
 
93
- finetune_py = find_script(eval_repo_dir, ["finetune_all.py", "eval_glue.py", "finetune.py", "eval_pipeline.py"])
94
  finetune_sh = find_script(eval_repo_dir, ["finetune_model.sh", "run_finetune.sh"])
95
-
96
- if finetune_py:
97
- script_dir = os.path.dirname(finetune_py)
98
- script_name = os.path.basename(finetune_py)
99
- run_cmd(f"python {script_name} --model_path {checkpoint_dir} --task causal --type finetune", cwd=script_dir)
100
  elif finetune_sh:
101
  script_dir = os.path.dirname(finetune_sh)
102
  script_name = os.path.basename(finetune_sh)
103
- run_cmd(f"bash {script_name} {checkpoint_dir} causal strict_small", cwd=script_dir)
104
 
105
  # ------------------------------------------------------------
106
  # STEP 3: FAST EVALUATION & SCORE COLLATING THIRD
@@ -110,16 +102,16 @@ def main():
110
  print("="*65)
111
 
112
  collate_sh = find_script(eval_repo_dir, ["collate_preds.sh", "collate_results.sh"])
113
- collate_py = find_script(eval_repo_dir, ["collate_results.py", "collate.py", "eval_pipeline.py"])
114
-
115
  if collate_sh:
116
  script_dir = os.path.dirname(collate_sh)
117
  script_name = os.path.basename(collate_sh)
118
- run_cmd(f"bash {script_name} gpt2_strict_small causal strict_small", cwd=script_dir)
119
- elif collate_py:
120
- script_dir = os.path.dirname(collate_py)
121
- script_name = os.path.basename(collate_py)
122
- run_cmd(f"python {script_name} --model_path {checkpoint_dir} --task causal --fast", cwd=script_dir)
 
 
123
 
124
  # ------------------------------------------------------------
125
  # PACKAGING & ZIPPING RESULTS FOR LEADERBOARD SUBMISSION
@@ -130,6 +122,12 @@ def main():
130
  results_dir = os.path.join(root, "results")
131
  break
132
 
 
 
 
 
 
 
133
  if results_dir and os.path.exists(results_dir):
134
  zip_path = os.path.join(base_dir, "results.zip")
135
  print(f"\n[Packaging] Zipping results directory '{results_dir}' to {zip_path}...")
 
1
  """
2
  Lightning AI Evaluation Runner for BabyLM 2026 Strict-Small Track
3
+ Fixes PYTHONPATH and argument formatting for babylm-eval.
4
+ Order:
5
  1. Full Zero-Shot Evaluation
6
+ 2. Fine-Tuning (GLUE Sequence Classification) Evaluation
7
+ 3. Fast Evaluation & Prediction Collating
8
  """
9
 
10
  import os
 
12
  import shutil
13
  import subprocess
14
 
15
+ def run_cmd(cmd, cwd=None, env=None):
16
  print(f"\n[RUNNING] {cmd}")
17
+ res = subprocess.run(cmd, shell=True, cwd=cwd, env=env)
18
  print(f"[STATUS] Exit Code: {res.returncode}")
19
  return res.returncode
20
 
 
44
  if not os.path.exists(eval_repo_dir):
45
  run_cmd("git clone https://github.com/babylm-org/babylm-eval.git", cwd=base_dir)
46
 
47
+ # Prepare environment with PYTHONPATH pointing to babylm-eval root and subfolders
48
+ custom_env = os.environ.copy()
49
+ pythonpath = eval_repo_dir
50
+ for root, dirs, _ in os.walk(eval_repo_dir):
51
+ if not root.startswith(os.path.join(eval_repo_dir, ".git")):
52
+ pythonpath += ":" + root
53
+ custom_env["PYTHONPATH"] = pythonpath + ":" + custom_env.get("PYTHONPATH", "")
54
+
55
  # 2. Install dependencies via requirements.txt
56
  print("\n[Setup] Installing dependencies...")
57
  req_file = find_script(eval_repo_dir, ["requirements.txt"])
58
  if req_file:
59
+ run_cmd(f"pip install -r {req_file}", cwd=os.path.dirname(req_file), env=custom_env)
60
  else:
61
+ run_cmd("pip install evaluate scikit-learn lm-eval datasets transformers", cwd=eval_repo_dir, env=custom_env)
 
 
 
 
 
 
 
 
 
 
62
 
63
  # ------------------------------------------------------------
64
  # STEP 1: FULL ZERO-SHOT EVALUATION FIRST
 
67
  print(" STEP 1: FULL ZERO-SHOT EVALUATION")
68
  print("="*65)
69
 
70
+ eval_model_py = find_script(eval_repo_dir, ["eval_model.py", "eval_pipeline.py"])
71
+ if eval_model_py:
72
+ script_dir = os.path.dirname(eval_model_py)
73
+ script_name = os.path.basename(eval_model_py)
74
+ run_cmd(f"python {script_name} --model_path {checkpoint_dir} --task causal", cwd=script_dir, env=custom_env)
 
 
 
 
 
 
75
  else:
76
  print("[Notice] Running fallback zero-shot lm-eval on checkpoints...")
77
+ run_cmd(f"lm_eval --model hf --model_args pretrained={checkpoint_dir}/main --tasks blimp --batch_size 16", cwd=eval_repo_dir, env=custom_env)
78
 
79
  # ------------------------------------------------------------
80
+ # STEP 2: FINE-TUNING (GLUE CLASSIFICATION) EVALUATION SECOND
81
  # ------------------------------------------------------------
82
  print("\n" + "="*65)
83
  print(" STEP 2: FINE-TUNING (GLUE CLASSIFICATION) EVALUATION")
84
  print("="*65)
85
 
 
86
  finetune_sh = find_script(eval_repo_dir, ["finetune_model.sh", "run_finetune.sh"])
87
+ if eval_model_py:
88
+ script_dir = os.path.dirname(eval_model_py)
89
+ script_name = os.path.basename(eval_model_py)
90
+ # Run eval_model.py for finetune tasks
91
+ run_cmd(f"python {script_name} --model_path {checkpoint_dir} --task causal --finetune", cwd=script_dir, env=custom_env)
92
  elif finetune_sh:
93
  script_dir = os.path.dirname(finetune_sh)
94
  script_name = os.path.basename(finetune_sh)
95
+ run_cmd(f"bash {script_name} --model_path {checkpoint_dir} --task causal", cwd=script_dir, env=custom_env)
96
 
97
  # ------------------------------------------------------------
98
  # STEP 3: FAST EVALUATION & SCORE COLLATING THIRD
 
102
  print("="*65)
103
 
104
  collate_sh = find_script(eval_repo_dir, ["collate_preds.sh", "collate_results.sh"])
 
 
105
  if collate_sh:
106
  script_dir = os.path.dirname(collate_sh)
107
  script_name = os.path.basename(collate_sh)
108
+ # Run collate script with PYTHONPATH properly exported
109
+ run_cmd(f"bash {script_name} gpt2_strict_small causal strict_small", cwd=script_dir, env=custom_env)
110
+
111
+ if eval_model_py:
112
+ script_dir = os.path.dirname(eval_model_py)
113
+ script_name = os.path.basename(eval_model_py)
114
+ run_cmd(f"python {script_name} --model_path {checkpoint_dir} --task causal --fast", cwd=script_dir, env=custom_env)
115
 
116
  # ------------------------------------------------------------
117
  # PACKAGING & ZIPPING RESULTS FOR LEADERBOARD SUBMISSION
 
122
  results_dir = os.path.join(root, "results")
123
  break
124
 
125
+ if not results_dir or not os.path.exists(results_dir):
126
+ for root, dirs, _ in os.walk(base_dir):
127
+ if "results" in dirs and "babylm" in root:
128
+ results_dir = os.path.join(root, "results")
129
+ break
130
+
131
  if results_dir and os.path.exists(results_dir):
132
  zip_path = os.path.join(base_dir, "results.zip")
133
  print(f"\n[Packaging] Zipping results directory '{results_dir}' to {zip_path}...")