CultriX commited on
Commit
0971cfa
·
verified ·
1 Parent(s): 3e2f657

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -177
app.py CHANGED
@@ -12,40 +12,17 @@ from PIL import Image
12
  from io import BytesIO
13
  import tempfile
14
  import sys
 
15
 
 
 
 
16
 
17
- # --------------------------------------------------------------------
18
- # PART 1: YOUR EXISTING (TINY) DATA & PLOTS
19
- # --------------------------------------------------------------------
20
-
21
  data_full = [
22
- ['CultriX/Qwen2.5-14B-SLERPv7', 'https://huggingface.co/CultriX/Qwen2.5-14B-SLERPv7', 0.7205, 0.8272, 0.7541, 0.6581, 0.5, 0.729],
23
- ['djuna/Q2.5-Veltha-14B-0.5', 'https://huggingface.co/djuna/Q2.5-Veltha-14B-0.5', 0.7492, 0.8386, 0.7305, 0.598, 0.43, 0.7817],
24
- ['CultriX/Qwen2.5-14B-FinalMerge', 'https://huggingface.co/CultriX/Qwen2.5-14B-FinalMerge', 0.7248, 0.8277, 0.7113, 0.7052, 0.57, 0.7001],
25
- ['CultriX/Qwen2.5-14B-MultiCultyv2', 'https://huggingface.co/CultriX/Qwen2.5-14B-MultiCultyv2', 0.7295, 0.8359, 0.7363, 0.5767, 0.44, 0.7316],
26
- ['CultriX/Qwen2.5-14B-Brocav7', 'https://huggingface.co/CultriX/Qwen2.5-14B-Brocav7', 0.7445, 0.8353, 0.7508, 0.6292, 0.46, 0.7629],
27
- ['CultriX/Qwen2.5-14B-Broca', 'https://huggingface.co/CultriX/Qwen2.5-14B-Broca', 0.7456, 0.8352, 0.748, 0.6034, 0.44, 0.7716],
28
- ['CultriX/Qwen2.5-14B-Brocav3', 'https://huggingface.co/CultriX/Qwen2.5-14B-Brocav3', 0.7395, 0.8388, 0.7393, 0.6405, 0.47, 0.7659],
29
- ['CultriX/Qwen2.5-14B-Brocav4', 'https://huggingface.co/CultriX/Qwen2.5-14B-Brocav4', 0.7432, 0.8377, 0.7444, 0.6277, 0.48, 0.758],
30
- ['CultriX/Qwen2.5-14B-Brocav2', 'https://huggingface.co/CultriX/Qwen2.5-14B-Brocav2', 0.7492, 0.8302, 0.7508, 0.6377, 0.51, 0.7478],
31
- ['CultriX/Qwen2.5-14B-Brocav5', 'https://huggingface.co/CultriX/Qwen2.5-14B-Brocav5', 0.7445, 0.8313, 0.7547, 0.6376, 0.5, 0.7304],
32
- ['CultriX/Qwen2.5-14B-Brocav6', 'https://huggingface.co/CultriX/Qwen2.5-14B-Brocav6', 0.7179, 0.8354, 0.7531, 0.6378, 0.49, 0.7524],
33
- ['CultriX/Qwenfinity-2.5-14B', 'https://huggingface.co/CultriX/Qwenfinity-2.5-14B', 0.7347, 0.8254, 0.7279, 0.7267, 0.56, 0.697],
34
- ['CultriX/Qwen2.5-14B-Emergedv2', 'https://huggingface.co/CultriX/Qwen2.5-14B-Emergedv2', 0.7137, 0.8335, 0.7363, 0.5836, 0.44, 0.7344],
35
- ['CultriX/Qwen2.5-14B-Unity', 'https://huggingface.co/CultriX/Qwen2.5-14B-Unity', 0.7063, 0.8343, 0.7423, 0.682, 0.57, 0.7498],
36
- ['CultriX/Qwen2.5-14B-MultiCultyv3', 'https://huggingface.co/CultriX/Qwen2.5-14B-MultiCultyv3', 0.7132, 0.8216, 0.7395, 0.6792, 0.55, 0.712],
37
- ['CultriX/Qwen2.5-14B-Emergedv3', 'https://huggingface.co/CultriX/Qwen2.5-14B-Emergedv3', 0.7436, 0.8312, 0.7519, 0.6585, 0.55, 0.7068],
38
- ['CultriX/SeQwence-14Bv1', 'https://huggingface.co/CultriX/SeQwence-14Bv1', 0.7278, 0.841, 0.7541, 0.6816, 0.52, 0.7539],
39
- ['CultriX/Qwen2.5-14B-Wernickev2', 'https://huggingface.co/CultriX/Qwen2.5-14B-Wernickev2', 0.7391, 0.8168, 0.7273, 0.622, 0.45, 0.7572],
40
- ['CultriX/Qwen2.5-14B-Wernickev3', 'https://huggingface.co/CultriX/Qwen2.5-14B-Wernickev3', 0.7357, 0.8148, 0.7245, 0.7023, 0.55, 0.7869],
41
- ['CultriX/Qwen2.5-14B-Wernickev4', 'https://huggingface.co/CultriX/Qwen2.5-14B-Wernickev4', 0.7355, 0.829, 0.7497, 0.6306, 0.48, 0.7635],
42
- ['CultriX/SeQwential-14B-v1', 'https://huggingface.co/CultriX/SeQwential-14B-v1', 0.7355, 0.8205, 0.7549, 0.6367, 0.48, 0.7626],
43
- ['CultriX/Qwen2.5-14B-Wernickev5', 'https://huggingface.co/CultriX/Qwen2.5-14B-Wernickev5', 0.7224, 0.8272, 0.7541, 0.679, 0.51, 0.7578],
44
- ['CultriX/Qwen2.5-14B-Wernickev6', 'https://huggingface.co/CultriX/Qwen2.5-14B-Wernickev6', 0.6994, 0.7549, 0.5816, 0.6991, 0.58, 0.7267],
45
- ['CultriX/Qwen2.5-14B-Wernickev7', 'https://huggingface.co/CultriX/Qwen2.5-14B-Wernickev7', 0.7147, 0.7599, 0.6097, 0.7056, 0.57, 0.7164],
46
- ['CultriX/Qwen2.5-14B-FinalMerge-tmp2', 'https://huggingface.co/CultriX/Qwen2.5-14B-FinalMerge-tmp2', 0.7255, 0.8192, 0.7535, 0.6671, 0.5, 0.7612],
47
- ['CultriX/Qwen2.5-14B-BrocaV8', 'https://huggingface.co/CultriX/Qwen2.5-14B-BrocaV8', 0.7415, 0.8396, 0.7334, 0.5785, 0.4300, 0.7646],
48
  ]
 
49
  columns = ["Model Configuration", "Model Link", "tinyArc", "tinyHellaswag",
50
  "tinyMMLU", "tinyTruthfulQA", "tinyTruthfulQA_mc1", "tinyWinogrande"]
51
  df_full = pd.DataFrame(data_full, columns=columns)
@@ -127,7 +104,7 @@ def plot_task_specific_top_models():
127
 
128
  def plot_heatmap():
129
  plt.figure(figsize=(14, 10))
130
- sns.heatmap(df_full.iloc[:, 2:], annot=True, cmap="YlGnBu",
131
  xticklabels=columns[2:], yticklabels=df_full["Model Configuration"])
132
  plt.title("Performance Heatmap", fontsize=16)
133
  plt.tight_layout()
@@ -143,13 +120,16 @@ def plot_heatmap():
143
  return pil_image, temp_image_file.name
144
 
145
  def scrape_mergekit_config(model_name):
 
 
 
146
  model_link = df_full.loc[df_full["Model Configuration"] == model_name, "Model Link"].values[0]
147
  response = requests.get(model_link)
148
  if response.status_code != 200:
149
  return f"Failed to fetch model page for {model_name}. Please check the link."
150
 
151
  soup = BeautifulSoup(response.text, "html.parser")
152
- yaml_config = soup.find("pre") # Assume YAML is in <pre> tags
153
  if yaml_config:
154
  return yaml_config.text.strip()
155
  return f"No YAML configuration found for {model_name}."
@@ -206,163 +186,41 @@ def download_all_data():
206
  image_bytes.seek(0)
207
  zf.writestr(filename, image_bytes.read())
208
 
209
- # Also try scraping each model for a YAML config
210
  for model_name in df_full["Model Configuration"].to_list():
211
  yaml_content = scrape_mergekit_config(model_name)
212
  if ("No YAML configuration found" not in yaml_content) and ("Failed to fetch model page" not in yaml_content):
213
- zf.writestr(f"{model_name.replace('/', '_')}_config.yaml", yaml_content.encode())
214
 
215
  zip_buffer.seek(0)
216
  return zip_buffer, "analysis_data.zip"
217
 
218
 
219
- # --------------------------------------------------------------------
220
- # PART 2: FULL "DATA START" SNIPPET (RANKS 44–105) + Parser
221
- # --------------------------------------------------------------------
222
- benchmark_data = [
223
- # The entire dataset from your "DATA START", rank 44..105
224
- # (the code you posted with "knowledge of config" or scraping logic)
225
- {
226
- "rank": 44,
227
- "name": "sometimesanotion/Qwen2.5-14B-Vimarckoso-v3",
228
- "scores": {
229
- "average": 40.10,
230
- "IFEval": 72.57,
231
- "BBH": 48.58,
232
- "MATH": 34.44,
233
- "GPQA": 17.34,
234
- "MUSR": 19.39,
235
- "MMLU-PRO": 48.26
236
- },
237
- "hf_url": "https://huggingface.co/sometimesanotion/Qwen2.5-14B-Vimarckoso-v3",
238
- "known_config": {
239
- "models": [
240
- {"model": "CultriX/SeQwence-14Bv1"},
241
- {"model": "allknowingroger/Qwenslerp5-14B"}
242
- ],
243
- "merge_method": "slerp",
244
- "base_model": "CultriX/SeQwence-14Bv1",
245
- "dtype": "bfloat16",
246
- "parameters": {
247
- "t": [0, 0.5, 1, 0.5, 0]
248
- }
249
- }
250
- },
251
- # ... rest of the snippet ...
252
- # (Exactly copy/paste your big block from rank=44 to rank=105)
253
- ]
254
-
255
 
256
- def snippet_scrape_model_page(url):
257
  """
258
- Same as scrape_model_page, but we keep it separate for clarity.
259
- """
260
- return scrape_model_page(url)
261
-
262
- def snippet_print_benchmark_and_config_info(model_info):
263
  """
264
- Prints an overview for each model (your "DATA START" logic),
265
- either known config or scraping snippet.
266
- """
267
- print(f"---\nModel Rank: {model_info['rank']}")
268
- print(f"Model Name: {model_info['name']}")
269
- print(f"Model average score across benchmarks in %: {model_info['scores']['average']}")
270
- print(f"Models average score on IFEval benchmarks in %: {model_info['scores']['IFEval']}")
271
- print(f"Models average score on BBH benchmarks in %: {model_info['scores']['BBH']}")
272
- print(f"Models average score on MATH benchmarks in %: {model_info['scores']['MATH']}")
273
- print(f"Models average score in GPQA benchmarks in %: {model_info['scores']['GPQA']}")
274
- print(f"Models average score in MUSR benchmarks in %: {model_info['scores']['MUSR']}")
275
- print(f"Models average score in MMLU-PRO benchmarks in %: {model_info['scores']['MMLU-PRO']}")
276
-
277
- # If there's a known_config, print it as YAML
278
- if model_info["known_config"] is not None:
279
- print("###")
280
- print("models:")
281
- for m in model_info["known_config"]["models"]:
282
- print(f" - model: {m['model']}")
283
- print(f"merge_method: {model_info['known_config']['merge_method']}")
284
- print(f"base_model: {model_info['known_config']['base_model']}")
285
- print(f"dtype: {model_info['known_config']['dtype']}")
286
- print("parameters:")
287
- print(f" t: {model_info['known_config']['parameters']['t']} # V shaped curve: Hermes for input & output, WizardMath in the middle layers")
288
- print("###")
289
- return
290
-
291
- # Otherwise, scrape
292
- scraped = snippet_scrape_model_page(model_info["hf_url"])
293
- if isinstance(scraped, str):
294
- # Means it's an error string or something
295
- if "Error:" in scraped:
296
- print("(No MergeKit configuration found or error occurred.)\n")
297
- # optionally print snippet
298
- else:
299
- print(scraped)
300
- return
301
- else:
302
- # It's presumably a dict: { "yaml_configuration": "...", "metadata": "..." }
303
- if ("No YAML configuration found." in scraped["yaml_configuration"]):
304
- print("(No MergeKit configuration found.)\n")
305
- # Print your snippet code
306
- print("You can try the following Python script to scrape the model page:\n")
307
- print("#" * 70)
308
- print(f'''import requests
309
- from bs4 import BeautifulSoup
310
-
311
- def scrape_model_page(model_url):
312
  try:
313
- response = requests.get(model_url)
314
- if response.status_code != 200:
315
- return f"Error: Unable to fetch the page (Status Code: {{response.status_code}})"
316
-
317
- soup = BeautifulSoup(response.text, "html.parser")
318
-
319
- yaml_config = soup.find("pre")
320
- yaml_text = yaml_config.text.strip() if yaml_config else "No YAML configuration found."
321
-
322
- metadata_section = soup.find("div", class_="metadata")
323
- metadata_text = metadata_section.text.strip() if metadata_section else "No metadata found."
324
-
325
- return {{
326
- "yaml_configuration": yaml_text,
327
- "metadata": metadata_text
328
- }}
329
-
330
  except Exception as e:
331
- return f"Error: {{str(e)}}"
332
-
333
- if __name__ == "__main__":
334
- model_url = "{model_info['hf_url']}"
335
- result = scrape_model_page(model_url)
336
- print(result)''')
337
- print("#" * 70)
338
- else:
339
- print("###")
340
- print(scraped["yaml_configuration"])
341
- print("###")
342
-
343
- def run_non_tiny_benchmarks():
344
- """
345
- Captures the stdout from printing each model in benchmark_data
346
- (ranks 44 to 105), returning a single string for Gradio to display.
347
- """
348
- old_stdout = sys.stdout
349
- buffer = io.StringIO()
350
- sys.stdout = buffer
351
 
352
- for model in benchmark_data:
353
- snippet_print_benchmark_and_config_info(model)
354
 
355
- sys.stdout = old_stdout
356
- return buffer.getvalue()
 
357
 
358
-
359
- # --------------------------------------------------------------------
360
- # PART 3: GRADIO APP (Your existing UI plus the "Parse Non-Tiny" button)
361
- # --------------------------------------------------------------------
362
  with gr.Blocks() as demo:
363
  gr.Markdown("# Comprehensive Model Performance Analysis with Hugging Face Links")
364
 
365
- # The existing UI
366
  with gr.Row():
367
  btn1 = gr.Button("Show Average Performance")
368
  img1 = gr.Image(type="pil", label="Average Performance Plot")
@@ -387,6 +245,7 @@ with gr.Blocks() as demo:
387
  heatmap_download = gr.File(label="Download Heatmap")
388
  btn4.click(plot_heatmap, outputs=[heatmap_img, heatmap_download])
389
 
 
390
  with gr.Row():
391
  model_selector = gr.Dropdown(choices=df_full["Model Configuration"].tolist(), label="Select a Model")
392
  with gr.Column():
@@ -398,12 +257,13 @@ with gr.Blocks() as demo:
398
  yaml_download = gr.File(label="Download MergeKit Configuration")
399
  save_yaml_btn.click(download_yaml, inputs=[yaml_output, model_selector], outputs=yaml_download)
400
 
 
401
  with gr.Row():
402
  download_all_btn = gr.Button("Download Everything")
403
  all_downloads = gr.File(label="Download All Data")
404
  download_all_btn.click(download_all_data, outputs=all_downloads)
405
-
406
- # Live scraping feature
407
  gr.Markdown("## Live Scraping Features")
408
  with gr.Row():
409
  url_input = gr.Textbox(label="Enter Hugging Face Model URL", placeholder="https://huggingface.co/<model>")
@@ -411,11 +271,12 @@ with gr.Blocks() as demo:
411
  live_scrape_output = gr.Textbox(label="Scraped Data", lines=15)
412
  live_scrape_btn.click(display_scraped_model_data, inputs=url_input, outputs=live_scrape_output)
413
 
414
- # NEW: Non-Tiny Benchmarks button
415
- gr.Markdown("## Non-Tiny Benchmark Parser (Ranks 44–105)")
416
  with gr.Row():
417
- parse_non_tiny_btn = gr.Button("Parse Non-Tiny Benchmarks")
418
- parse_non_tiny_output = gr.Textbox(label="Non-Tiny Benchmark Output", lines=30)
419
- parse_non_tiny_btn.click(fn=run_non_tiny_benchmarks, outputs=parse_non_tiny_output)
420
 
 
421
  demo.launch()
 
12
  from io import BytesIO
13
  import tempfile
14
  import sys
15
+ import subprocess
16
 
17
+ #############################################
18
+ # PART 1: YOUR EXISTING PLOTS & FUNCTIONALITY
19
+ #############################################
20
 
21
+ # For demonstration, assume you have a small data_full for "tiny" benchmarks:
 
 
 
22
  data_full = [
23
+ # your existing data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  ]
25
+
26
  columns = ["Model Configuration", "Model Link", "tinyArc", "tinyHellaswag",
27
  "tinyMMLU", "tinyTruthfulQA", "tinyTruthfulQA_mc1", "tinyWinogrande"]
28
  df_full = pd.DataFrame(data_full, columns=columns)
 
104
 
105
  def plot_heatmap():
106
  plt.figure(figsize=(14, 10))
107
+ sns.heatmap(df_full.iloc[:, 2:], annot=True, cmap="YlGnBu",
108
  xticklabels=columns[2:], yticklabels=df_full["Model Configuration"])
109
  plt.title("Performance Heatmap", fontsize=16)
110
  plt.tight_layout()
 
120
  return pil_image, temp_image_file.name
121
 
122
  def scrape_mergekit_config(model_name):
123
+ """
124
+ Example from your code that tries to find <pre> blocks on the model page.
125
+ """
126
  model_link = df_full.loc[df_full["Model Configuration"] == model_name, "Model Link"].values[0]
127
  response = requests.get(model_link)
128
  if response.status_code != 200:
129
  return f"Failed to fetch model page for {model_name}. Please check the link."
130
 
131
  soup = BeautifulSoup(response.text, "html.parser")
132
+ yaml_config = soup.find("pre")
133
  if yaml_config:
134
  return yaml_config.text.strip()
135
  return f"No YAML configuration found for {model_name}."
 
186
  image_bytes.seek(0)
187
  zf.writestr(filename, image_bytes.read())
188
 
189
+ # Optionally, scrape each model for a YAML config:
190
  for model_name in df_full["Model Configuration"].to_list():
191
  yaml_content = scrape_mergekit_config(model_name)
192
  if ("No YAML configuration found" not in yaml_content) and ("Failed to fetch model page" not in yaml_content):
193
+ zf.writestr(f"{model_name.replace('/', '_')}_config.yaml", yaml_content.encode())
194
 
195
  zip_buffer.seek(0)
196
  return zip_buffer, "analysis_data.zip"
197
 
198
 
199
+ #############################################
200
+ # PART 2: RUNNING `scrape-leaderboard.py`
201
+ #############################################
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
 
203
+ def run_scrape_leaderboard():
204
  """
205
+ Uses Python's `subprocess` to call the external script: `scrape-leaderboard.py`
206
+ capturing whatever the script prints to stdout.
 
 
 
207
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  try:
209
+ # Make sure 'scrape-leaderboard.py' is in the same folder or give the full path
210
+ result = subprocess.run(["python", "scrape-leaderboard.py"], capture_output=True, text=True)
211
+ # Return the combined stdout/stderr or just stdout
212
+ return result.stdout if result.stdout else result.stderr
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  except Exception as e:
214
+ return f"Error running script: {str(e)}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
 
 
216
 
217
+ ###############################
218
+ # PART 3: YOUR GRADIO INTERFACE
219
+ ###############################
220
 
 
 
 
 
221
  with gr.Blocks() as demo:
222
  gr.Markdown("# Comprehensive Model Performance Analysis with Hugging Face Links")
223
 
 
224
  with gr.Row():
225
  btn1 = gr.Button("Show Average Performance")
226
  img1 = gr.Image(type="pil", label="Average Performance Plot")
 
245
  heatmap_download = gr.File(label="Download Heatmap")
246
  btn4.click(plot_heatmap, outputs=[heatmap_img, heatmap_download])
247
 
248
+ # Drop-down to pick a model, scrape for config
249
  with gr.Row():
250
  model_selector = gr.Dropdown(choices=df_full["Model Configuration"].tolist(), label="Select a Model")
251
  with gr.Column():
 
257
  yaml_download = gr.File(label="Download MergeKit Configuration")
258
  save_yaml_btn.click(download_yaml, inputs=[yaml_output, model_selector], outputs=yaml_download)
259
 
260
+ # Button to download everything (CSV + plots)
261
  with gr.Row():
262
  download_all_btn = gr.Button("Download Everything")
263
  all_downloads = gr.File(label="Download All Data")
264
  download_all_btn.click(download_all_data, outputs=all_downloads)
265
+
266
+ # Live scraping of any model URL
267
  gr.Markdown("## Live Scraping Features")
268
  with gr.Row():
269
  url_input = gr.Textbox(label="Enter Hugging Face Model URL", placeholder="https://huggingface.co/<model>")
 
271
  live_scrape_output = gr.Textbox(label="Scraped Data", lines=15)
272
  live_scrape_btn.click(display_scraped_model_data, inputs=url_input, outputs=live_scrape_output)
273
 
274
+ # NEW: Button that runs the external script 'scrape-leaderboard.py'
275
+ gr.Markdown("## Run `scrape-leaderboard.py` Externally")
276
  with gr.Row():
277
+ run_script_btn = gr.Button("Run 'scrape-leaderboard.py'")
278
+ run_script_output = gr.Textbox(label="Script Output", lines=25)
279
+ run_script_btn.click(fn=run_scrape_leaderboard, outputs=run_script_output)
280
 
281
+ # Finally, launch the app
282
  demo.launch()