sumitrwk commited on
Commit
cb61920
·
verified ·
1 Parent(s): 3669ab5

Delete benchmarks.py

Browse files
Files changed (1) hide show
  1. benchmarks.py +0 -87
benchmarks.py DELETED
@@ -1,87 +0,0 @@
1
- import torch
2
- import random
3
- import zlib
4
-
5
- class BenchmarkSuite:
6
- def __init__(self, model, tokenizer, device="cpu", model_id="unknown"):
7
- self.model = model
8
- self.tokenizer = tokenizer
9
- self.device = device
10
- self.model_id = model_id
11
-
12
- def _get_deterministic_score(self, benchmark_name, min_val, max_val):
13
- """
14
- Generates a consistent 'fake' score based on the model name.
15
- This ensures Qwen-0.6B always gets the same score, even in simulation mode.
16
- """
17
- # Create a seed from the model ID + benchmark name
18
- seed_str = f"{self.model_id}_{benchmark_name}"
19
- # Use adler32 for a consistent integer hash
20
- seed_val = zlib.adler32(seed_str.encode('utf-8'))
21
- random.seed(seed_val)
22
- return random.uniform(min_val, max_val)
23
-
24
- def run_benchmark(self, benchmark_name, simulation_mode=True):
25
- metrics = {
26
- "ARC-C": self._run_arc_c,
27
- "ARC-E": self._run_arc_e,
28
- "GSM8K": self._run_gsm8k,
29
- "MMLU": self._run_mmlu,
30
- "HellaSwag": self._run_hellaswag,
31
- "PIQA": self._run_piqa,
32
- "Perplexity": self._run_perplexity
33
- }
34
-
35
- if benchmark_name in metrics:
36
- return metrics[benchmark_name](simulation_mode)
37
- return {"score": 0.0, "rating": "Unknown"}
38
-
39
- def _evaluate_result(self, score, threshold_good, threshold_bad, lower_is_better=False):
40
- if lower_is_better:
41
- if score < threshold_good: return "Excellent 🟢"
42
- if score < threshold_bad: return "Average 🟡"
43
- return "Poor 🔴"
44
- else:
45
- if score > threshold_good: return "Excellent 🟢"
46
- if score > threshold_bad: return "Average 🟡"
47
- return "Poor 🔴"
48
-
49
- # --- Benchmarks ---
50
-
51
- def _run_perplexity(self, sim):
52
- if sim:
53
- # Deterministic Simulation
54
- val = self._get_deterministic_score("perplexity", 8.0, 45.0)
55
- return {
56
- "score": val,
57
- "rating": self._evaluate_result(val, 15.0, 30.0, lower_is_better=True),
58
- "unit": "PPL"
59
- }
60
- else:
61
- # REAL Logic (from Step 1)
62
- # Warning: This is slow!
63
- return {"score": 25.4, "rating": "Real (Mocked)", "unit": "PPL"}
64
-
65
- def _run_mmlu(self, sim):
66
- val = self._get_deterministic_score("mmlu", 25.0, 80.0)
67
- return {"score": val, "rating": self._evaluate_result(val, 60.0, 40.0), "unit": "%"}
68
-
69
- def _run_gsm8k(self, sim):
70
- val = self._get_deterministic_score("gsm8k", 10.0, 70.0)
71
- return {"score": val, "rating": self._evaluate_result(val, 50.0, 25.0), "unit": "%"}
72
-
73
- def _run_arc_c(self, sim):
74
- val = self._get_deterministic_score("arc_c", 30.0, 75.0)
75
- return {"score": val, "rating": self._evaluate_result(val, 60.0, 40.0), "unit": "%"}
76
-
77
- def _run_arc_e(self, sim):
78
- val = self._get_deterministic_score("arc_e", 40.0, 85.0)
79
- return {"score": val, "rating": self._evaluate_result(val, 70.0, 50.0), "unit": "%"}
80
-
81
- def _run_hellaswag(self, sim):
82
- val = self._get_deterministic_score("hellaswag", 40.0, 90.0)
83
- return {"score": val, "rating": self._evaluate_result(val, 75.0, 50.0), "unit": "%"}
84
-
85
- def _run_piqa(self, sim):
86
- val = self._get_deterministic_score("piqa", 50.0, 85.0)
87
- return {"score": val, "rating": self._evaluate_result(val, 75.0, 60.0), "unit": "%"}