taesiri commited on
Commit
0ec0046
1 Parent(s): ed1f48a
app.py CHANGED
@@ -7,6 +7,13 @@ from matplotlib.colors import ListedColormap, BoundaryNorm
7
  from glob import glob
8
  import os
9
 
 
 
 
 
 
 
 
10
  # Load text benchmark results
11
  csv_results = glob("results/*.pkl")
12
  # Load vision benchmark results
@@ -16,6 +23,7 @@ cot_text_results = glob("results-cot/*.pkl")
16
  # Load CoT vision benchmark results
17
  # cot_vision_results = glob("results-vision-CoT/*.pkl")
18
 
 
19
  # Function to load data, add model type and name
20
  def load_data(files, model_type):
21
  data = []
@@ -62,6 +70,18 @@ cot_text_data = {file: pd.read_pickle(file) for file in cot_text_results}
62
  # cot_vision_data = {file: pd.read_pickle(file) for file in cot_vision_results}
63
 
64
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  def calculate_accuracy(df):
66
  return df["parsed_judge_response"].mean() * 100
67
 
@@ -90,6 +110,7 @@ column_names = [
90
  "Level 4 Accuracy",
91
  ]
92
 
 
93
  # Function to process data
94
  def process_data(data):
95
  data_for_df = []
@@ -113,6 +134,7 @@ vision_accuracy_df = pd.DataFrame(vision_data_for_df, columns=column_names)
113
  cot_text_accuracy_df = pd.DataFrame(cot_text_data_for_df, columns=column_names)
114
  # cot_vision_accuracy_df = pd.DataFrame(cot_vision_data_for_df, columns=column_names)
115
 
 
116
  # Function to finalize DataFrame
117
  def finalize_df(df):
118
  df = df.round(1) # Round to one decimal place
@@ -327,6 +349,63 @@ def generate_heatmap_for_specific_model_cot(model_name):
327
  return fig
328
 
329
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  def show_constraint_heatmap(evt: gr.SelectData):
331
  model_name = evt.value
332
  return generate_heatmap_for_specific_model(model_name)
@@ -337,6 +416,11 @@ def show_constraint_heatmap_cot(evt: gr.SelectData):
337
  return generate_heatmap_for_specific_model_cot(model_name)
338
 
339
 
 
 
 
 
 
340
  with gr.Blocks() as demo:
341
  gr.Markdown("# FSM Benchmark Leaderboard")
342
  with gr.Tab("Text-only Benchmark"):
@@ -417,6 +501,13 @@ with gr.Blocks() as demo:
417
  constrained_leader_board_text_cot = gr.Dataframe()
418
  constrained_leader_board_plot_cot = gr.Plot()
419
 
 
 
 
 
 
 
 
420
  included_models_cot.select(
421
  fn=calculate_order_by_first_substring_cot,
422
  inputs=[included_models_cot],
@@ -436,4 +527,8 @@ with gr.Blocks() as demo:
436
  fn=show_constraint_heatmap_cot, outputs=[constrained_leader_board_plot_cot]
437
  )
438
 
 
 
 
 
439
  demo.launch()
 
7
  from glob import glob
8
  import os
9
 
10
+
11
+ import matplotlib.pyplot as plt
12
+ import seaborn as sns
13
+ from matplotlib.colors import ListedColormap, BoundaryNorm
14
+ import pandas as pd
15
+
16
+
17
  # Load text benchmark results
18
  csv_results = glob("results/*.pkl")
19
  # Load vision benchmark results
 
23
  # Load CoT vision benchmark results
24
  # cot_vision_results = glob("results-vision-CoT/*.pkl")
25
 
26
+
27
  # Function to load data, add model type and name
28
  def load_data(files, model_type):
29
  data = []
 
70
  # cot_vision_data = {file: pd.read_pickle(file) for file in cot_vision_results}
71
 
72
 
73
+ intersection_df = pd.read_pickle(
74
+ "./intersection_results/gpt-3.5-judge-by_Qwen_5times_intersection_subset_1.pkl"
75
+ )
76
+ # accuracy for each model
77
+ intersection_df_acc = (
78
+ intersection_df.groupby("model_name")["parsed_judge_response"].mean().reset_index()
79
+ )
80
+ intersection_df_acc["Accuracy"] = intersection_df_acc["parsed_judge_response"] * 100
81
+ intersection_df_acc.drop("parsed_judge_response", axis=1, inplace=True)
82
+ intersection_df_acc.sort_values("Accuracy", ascending=False, inplace=True)
83
+
84
+
85
  def calculate_accuracy(df):
86
  return df["parsed_judge_response"].mean() * 100
87
 
 
110
  "Level 4 Accuracy",
111
  ]
112
 
113
+
114
  # Function to process data
115
  def process_data(data):
116
  data_for_df = []
 
134
  cot_text_accuracy_df = pd.DataFrame(cot_text_data_for_df, columns=column_names)
135
  # cot_vision_accuracy_df = pd.DataFrame(cot_vision_data_for_df, columns=column_names)
136
 
137
+
138
  # Function to finalize DataFrame
139
  def finalize_df(df):
140
  df = df.round(1) # Round to one decimal place
 
349
  return fig
350
 
351
 
352
+ def generate_heatmap_for_intersection_model(model_name):
353
+ global intersection_df
354
+
355
+ cmap = ListedColormap(["lightblue", "red", "green"])
356
+ bounds = [-1.5, -0.5, 0.5, 1.5]
357
+ norm = BoundaryNorm(bounds, cmap.N)
358
+
359
+ # Filter for a specific model
360
+ model_df = intersection_df[intersection_df["model_name"] == model_name].copy()
361
+
362
+ if model_df.empty:
363
+ print(f"No data found for model {model_name}. Skipping heatmap generation.")
364
+ return None
365
+
366
+ model_df["fsm_info"] = model_df.apply(
367
+ lambda x: f"{x['num_states']} states, {x['num_alphabet']} alphabet", axis=1
368
+ )
369
+ model_df = model_df.sort_values(by=["num_states", "num_alphabet"])
370
+
371
+ pivot_df = (
372
+ model_df.pivot_table(
373
+ index="fsm_info",
374
+ columns="substring_index",
375
+ values="parsed_judge_response",
376
+ aggfunc="first",
377
+ )
378
+ .fillna(-1)
379
+ .astype(float)
380
+ )
381
+
382
+ # Dynamically adjust figure size
383
+ num_rows, num_cols = pivot_df.shape
384
+ fig_width = max(12, num_cols * 0.5)
385
+ fig_height = max(8, num_rows * 0.4)
386
+
387
+ fig, ax = plt.subplots(figsize=(fig_width, fig_height))
388
+ sns.heatmap(
389
+ pivot_df,
390
+ cmap=cmap,
391
+ linewidths=1,
392
+ linecolor="black",
393
+ norm=norm,
394
+ cbar=False,
395
+ square=True,
396
+ ax=ax,
397
+ )
398
+ plt.title(f"Heatmap for Model: {model_name}", fontsize=12)
399
+ plt.xlabel("Substring Index")
400
+ plt.ylabel("FSM (States, Alphabet)")
401
+ plt.xticks(rotation=45)
402
+
403
+ sns.despine(ax=ax, top=True, right=True, left=True, bottom=True)
404
+
405
+ plt.close(fig) # Prevent it from showing immediately
406
+ return fig
407
+
408
+
409
  def show_constraint_heatmap(evt: gr.SelectData):
410
  model_name = evt.value
411
  return generate_heatmap_for_specific_model(model_name)
 
416
  return generate_heatmap_for_specific_model_cot(model_name)
417
 
418
 
419
+ def show_intersection_heatmap(evt: gr.SelectData):
420
+ model_name = evt.value
421
+ return generate_heatmap_for_intersection_model(model_name)
422
+
423
+
424
  with gr.Blocks() as demo:
425
  gr.Markdown("# FSM Benchmark Leaderboard")
426
  with gr.Tab("Text-only Benchmark"):
 
501
  constrained_leader_board_text_cot = gr.Dataframe()
502
  constrained_leader_board_plot_cot = gr.Plot()
503
 
504
+ with gr.Tab("Majority Vote (Subset 1)"):
505
+ gr.Markdown("## Majority Vote (Subset 1)")
506
+ intersection_leader_board = gr.Dataframe(
507
+ intersection_df_acc, headers=headers_with_icons
508
+ )
509
+ heatmap_image = gr.Plot(label="Model Heatmap")
510
+
511
  included_models_cot.select(
512
  fn=calculate_order_by_first_substring_cot,
513
  inputs=[included_models_cot],
 
527
  fn=show_constraint_heatmap_cot, outputs=[constrained_leader_board_plot_cot]
528
  )
529
 
530
+ intersection_leader_board.select(
531
+ fn=show_intersection_heatmap, outputs=[heatmap_image]
532
+ )
533
+
534
  demo.launch()
intersection_results/gpt-3.5-judge-by_Qwen_5times_intersection_subset_1.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1cc52129234d9667a4cc388bd1da3a2021f1bbb7ea556e20ee6d5e159b2b1a8
3
+ size 1482609