sherzod-hakimov commited on
Commit
35378f6
1 Parent(s): 40696ae

plotly plot

Browse files
README.md CHANGED
@@ -13,12 +13,21 @@ pinned: false
13
 
14
 
15
  ```
16
- @misc{chalamalasetti2023clembench,
17
- title={Clembench: Using Game Play to Evaluate Chat-Optimized Language Models as Conversational Agents},
18
- author={Kranti Chalamalasetti and Jana Götze and Sherzod Hakimov and Brielen Madureira and Philipp Sadler and David Schlangen},
19
- year={2023},
20
- eprint={2305.13455},
21
- archivePrefix={arXiv},
22
- primaryClass={cs.CL}
 
 
 
 
 
 
 
 
23
  }
 
24
  ```
 
13
 
14
 
15
  ```
16
+ @inproceedings{chalamalasetti-etal-2023-clembench,
17
+ title = "clembench: Using Game Play to Evaluate Chat-Optimized Language Models as Conversational Agents",
18
+ author = {Chalamalasetti, Kranti and
19
+ G{\"o}tze, Jana and
20
+ Hakimov, Sherzod and
21
+ Madureira, Brielen and
22
+ Sadler, Philipp and
23
+ Schlangen, David},
24
+ booktitle = "Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing",
25
+ month = dec,
26
+ year = "2023",
27
+ address = "Singapore",
28
+ publisher = "Association for Computational Linguistics",
29
+ url = "https://aclanthology.org/2023.emnlp-main.689",
30
+ pages = "11174--11219"
31
  }
32
+
33
  ```
app.py CHANGED
@@ -1,29 +1,31 @@
1
  import gradio as gr
2
 
3
  from src.assets.text_content import TITLE, INTRODUCTION_TEXT
4
- from src.utils import get_data, compare_plots, filter_search
 
5
 
6
- ############################ For Leaderboards #############################
7
- DATA_PATH = 'versions'
8
- latest_flag = True #Set flag to iclude latest data in Details and Versions Tab
9
- latest_df, latest_vname, previous_df, previous_vname = get_data(DATA_PATH, latest_flag)
10
 
11
  global prev_df
12
- prev_df = previous_df[0]
13
  def select_prev_df(name):
14
- ind = previous_vname.index(name)
15
- prev_df = previous_df[ind]
16
  return prev_df
17
 
18
- ############################ For Plots ####################################
19
- global plot_df, MODEL_COLS
20
- plot_df = latest_df[0]
21
- MODEL_COLS = list(plot_df['Model'].unique())
 
22
 
23
 
24
- ############# MAIN APPLICATION ######################
25
- demo = gr.Blocks()
26
- with demo:
27
  gr.HTML(TITLE)
28
  gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
29
 
@@ -35,17 +37,17 @@ with demo:
35
  show_label=False,
36
  elem_id="search-bar",
37
  )
38
-
39
  leaderboard_table = gr.components.Dataframe(
40
- value=latest_df[0],
41
  elem_id="leaderboard-table",
42
  interactive=False,
43
  visible=True,
44
  )
45
 
46
- # Add a dummy leaderboard to handle search queries from the latest_df and not update latest_df
47
  dummy_leaderboard_table = gr.components.Dataframe(
48
- value=latest_df[0],
49
  elem_id="leaderboard-table",
50
  interactive=False,
51
  visible=False,
@@ -57,36 +59,88 @@ with demo:
57
  leaderboard_table,
58
  queue=True
59
  )
 
60
  with gr.TabItem("📈 Plot", id=3):
61
  with gr.Row():
62
- model_cols = gr.CheckboxGroup(
63
- MODEL_COLS,
64
- label="Select Models 🤖",
 
 
 
 
 
 
 
 
 
65
  value=[],
66
- elem_id="column-select",
67
  interactive=True,
68
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  with gr.Row():
71
- plot_grdf = gr.DataFrame(
72
  value=plot_df,
73
  visible=False
74
  )
 
75
  with gr.Row():
76
- # Output block for the plot
77
- plot_output = gr.Plot()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
- model_cols.change(
80
  compare_plots,
81
- [plot_grdf, model_cols],
82
  plot_output,
83
  queue=True
84
  )
85
 
86
  with gr.TabItem("🔄 Versions and Details", elem_id="details", id=2):
87
  with gr.Row():
88
- ver_selection = gr.Dropdown(
89
- previous_vname, label="Select Version 🕹️", value=previous_vname[0]
90
  )
91
  with gr.Row():
92
  search_bar_prev = gr.Textbox(
@@ -116,13 +170,14 @@ with demo:
116
  queue=True
117
  )
118
 
119
- ver_selection.change(
120
  select_prev_df,
121
- [ver_selection],
122
  prev_table,
123
  queue=True
124
  )
 
 
 
125
 
126
- demo.load()
127
- demo.queue()
128
- demo.launch()
 
1
  import gradio as gr
2
 
3
  from src.assets.text_content import TITLE, INTRODUCTION_TEXT
4
+ from src.leaderboard_utils import filter_search, get_github_data
5
+ from src.plot_utils import split_models, compare_plots
6
 
7
+ # For Leaderboards
8
+ # Get CSV data
9
+ global primary_leaderboard_df, version_dfs, version_names
10
+ primary_leaderboard_df, version_dfs, version_names = get_github_data()
11
 
12
  global prev_df
13
+ prev_df = version_dfs[0]
14
  def select_prev_df(name):
15
+ ind = version_names.index(name)
16
+ prev_df = version_dfs[ind]
17
  return prev_df
18
 
19
+ # For Plots
20
+ global plot_df, OPEN_MODELS, CLOSED_MODELS, SHOW_ALL, SHOW_NAMES
21
+ plot_df = primary_leaderboard_df[0]
22
+ MODELS = list(plot_df[list(plot_df.columns)[0]].unique())
23
+ OPEN_MODELS, CLOSED_MODELS = split_models(MODELS)
24
 
25
 
26
+ # MAIN APPLICATION s
27
+ main_app = gr.Blocks()
28
+ with main_app:
29
  gr.HTML(TITLE)
30
  gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
31
 
 
37
  show_label=False,
38
  elem_id="search-bar",
39
  )
40
+
41
  leaderboard_table = gr.components.Dataframe(
42
+ value=primary_leaderboard_df[0],
43
  elem_id="leaderboard-table",
44
  interactive=False,
45
  visible=True,
46
  )
47
 
48
+ # Add a dummy leaderboard to handle search queries from the primary_leaderboard_df and not update primary_leaderboard_df
49
  dummy_leaderboard_table = gr.components.Dataframe(
50
+ value=primary_leaderboard_df[0],
51
  elem_id="leaderboard-table",
52
  interactive=False,
53
  visible=False,
 
59
  leaderboard_table,
60
  queue=True
61
  )
62
+
63
  with gr.TabItem("📈 Plot", id=3):
64
  with gr.Row():
65
+ open_models_selection = gr.CheckboxGroup(
66
+ OPEN_MODELS,
67
+ label="Open-weight Models 🌐",
68
+ value=[],
69
+ elem_id="value-select",
70
+ interactive=True,
71
+ )
72
+
73
+ with gr.Row():
74
+ closed_models_selection = gr.CheckboxGroup(
75
+ CLOSED_MODELS,
76
+ label="Closed-weight Models 💼",
77
  value=[],
78
+ elem_id="value-select-2",
79
  interactive=True,
80
  )
81
+
82
+ with gr.Row():
83
+ with gr.Column():
84
+ show_all = gr.CheckboxGroup(
85
+ ["Select All Models"],
86
+ label="Show plot for all models 🤖",
87
+ value=[],
88
+ elem_id="value-select-3",
89
+ interactive=True,
90
+ )
91
+
92
+ with gr.Column():
93
+ show_names = gr.CheckboxGroup(
94
+ ["Show Names"],
95
+ label ="Show names of models on the plot 🏷️",
96
+ value=[],
97
+ elem_id="value-select-4",
98
+ interactive=True,
99
+ )
100
 
101
  with gr.Row():
102
+ dummy_plot_df = gr.DataFrame(
103
  value=plot_df,
104
  visible=False
105
  )
106
+
107
  with gr.Row():
108
+ with gr.Column():
109
+ # Output block for the plot
110
+ plot_output = gr.Plot()
111
+
112
+ open_models_selection.change(
113
+ compare_plots,
114
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names],
115
+ plot_output,
116
+ queue=True
117
+ )
118
+
119
+ closed_models_selection.change(
120
+ compare_plots,
121
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names],
122
+ plot_output,
123
+ queue=True
124
+ )
125
+
126
+ show_all.change(
127
+ compare_plots,
128
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names],
129
+ plot_output,
130
+ queue=True
131
+ )
132
 
133
+ show_names.change(
134
  compare_plots,
135
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names],
136
  plot_output,
137
  queue=True
138
  )
139
 
140
  with gr.TabItem("🔄 Versions and Details", elem_id="details", id=2):
141
  with gr.Row():
142
+ version_select = gr.Dropdown(
143
+ version_names, label="Select Version 🕹️", value=version_names[0]
144
  )
145
  with gr.Row():
146
  search_bar_prev = gr.Textbox(
 
170
  queue=True
171
  )
172
 
173
+ version_select.change(
174
  select_prev_df,
175
+ [version_select],
176
  prev_table,
177
  queue=True
178
  )
179
+ main_app.load()
180
+
181
+ main_app.queue()
182
 
183
+ main_app.launch()
 
 
requirements.txt CHANGED
@@ -42,7 +42,7 @@ orjson==3.8.10
42
  packaging==23.1
43
  pandas==2.0.0
44
  Pillow==9.5.0
45
- plotly==5.14.1
46
  pyarrow==11.0.0
47
  pydantic==1.10.7
48
  pydub==0.25.1
 
42
  packaging==23.1
43
  pandas==2.0.0
44
  Pillow==9.5.0
45
+ plotly==5.18.0
46
  pyarrow==11.0.0
47
  pydantic==1.10.7
48
  pydub==0.25.1
src/assets/text_content.py CHANGED
@@ -1,13 +1,14 @@
1
  TITLE = """<h1 align="center" id="space-title"> 🏆 CLEM Leaderboard</h1>"""
2
 
3
  INTRODUCTION_TEXT = """
 
4
  The CLEM Leaderboard aims to track, rank and evaluate current cLLMs (chat-optimized Large Language Models) with the suggested pronounciation “clems”.
5
 
6
  The benchmarking approach is described in [Clembench: Using Game Play to Evaluate Chat-Optimized Language Models as Conversational Agents](https://arxiv.org/abs/2305.13455).
7
 
8
- Source code benchmarking "clems" is available here: [Clembench](https://github.com/clembench/clembench)
9
 
10
- All generated files and results from the benchmark runs are available here: [clembench-runs](https://github.com/clembench/clembench-runs)
11
  """
12
 
13
  SHORT_NAMES = {
 
1
  TITLE = """<h1 align="center" id="space-title"> 🏆 CLEM Leaderboard</h1>"""
2
 
3
  INTRODUCTION_TEXT = """
4
+ <h6 align="center">
5
  The CLEM Leaderboard aims to track, rank and evaluate current cLLMs (chat-optimized Large Language Models) with the suggested pronounciation “clems”.
6
 
7
  The benchmarking approach is described in [Clembench: Using Game Play to Evaluate Chat-Optimized Language Models as Conversational Agents](https://arxiv.org/abs/2305.13455).
8
 
9
+ Source code for benchmarking "clems" is available here: [Clembench](https://github.com/clembench/clembench)
10
 
11
+ All generated files and results from the benchmark runs are available here: [clembench-runs](https://github.com/clembench/clembench-runs) </h6>
12
  """
13
 
14
  SHORT_NAMES = {
src/leaderboard_utils.py ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pandas as pd
3
+ import requests, json
4
+ from io import StringIO
5
+
6
+ def get_github_data():
7
+ '''
8
+ Get data from csv files on Github
9
+ Args:
10
+ None
11
+ Returns:
12
+ latest_df: singular list containing dataframe of the latest version of the leaderboard with only 4 columns
13
+ all_dfs: list of dataframes for previous versions + latest version including columns for all games
14
+ all_vnames: list of the names for the previous versions + latest version (For Details and Versions Tab Dropdown)
15
+ '''
16
+ uname = "clembench"
17
+ repo = "clembench-runs"
18
+ json_url = f"https://raw.githubusercontent.com/{uname}/{repo}/main/benchmark_runs.json"
19
+ resp = requests.get(json_url)
20
+ if resp.status_code == 200:
21
+ json_data = json.loads(resp.text)
22
+ versions = json_data['versions']
23
+ version_names = []
24
+ csv_url = f"https://raw.githubusercontent.com/{uname}/{repo}/main/"
25
+ for ver in versions:
26
+ version_names.append(ver['version'])
27
+ csv_path = ver['result_file'].split('/')[1:]
28
+ csv_path = '/'.join(csv_path)
29
+
30
+ #Sort by latest version
31
+ float_content = [float(s[1:]) for s in version_names]
32
+ float_content.sort(reverse=True)
33
+ version_names = ['v'+str(s) for s in float_content]
34
+
35
+ DFS = []
36
+ for version in version_names:
37
+ result_url = csv_url+ version + '/' + csv_path
38
+ csv_response = requests.get(result_url)
39
+ if csv_response.status_code == 200:
40
+ df = pd.read_csv(StringIO(csv_response.text))
41
+ df = process_df(df)
42
+ df = df.sort_values(by=list(df.columns)[1], ascending=False) # Sort by clemscore
43
+ DFS.append(df)
44
+ else:
45
+ print(f"Failed to read CSV file for version : {version}. Status Code : {resp.status_code}")
46
+
47
+ # Only keep relavant columns for the main leaderboard
48
+ latest_df_dummy = DFS[0]
49
+ all_columns = list(latest_df_dummy.columns)
50
+ keep_columns = all_columns[0:4]
51
+ latest_df_dummy = latest_df_dummy.drop(columns=[c for c in all_columns if c not in keep_columns])
52
+
53
+ latest_df = [latest_df_dummy]
54
+ all_dfs = []
55
+ all_vnames = []
56
+ for df, name in zip(DFS, version_names):
57
+ all_dfs.append(df)
58
+ all_vnames.append(name)
59
+ return latest_df, all_dfs, all_vnames
60
+
61
+ else:
62
+ print(f"Failed to read JSON file: Status Code : {resp.status_code}")
63
+
64
+ def process_df(df: pd.DataFrame) -> pd.DataFrame:
65
+ '''
66
+ Process dataframe
67
+ - Remove repition in model names
68
+ - Convert datatypes to sort by "float" instead of "str" for sorting
69
+ - Update column names
70
+ Args:
71
+ df: Unprocessed Dataframe (after using update_cols)
72
+ Returns:
73
+ df: Processed Dataframe
74
+ '''
75
+
76
+ # Change column type to float from str
77
+ list_column_names = list(df.columns)
78
+ model_col_name = list_column_names[0]
79
+ for col in list_column_names:
80
+ if col != model_col_name:
81
+ df[col] = df[col].astype(float)
82
+
83
+ # Remove repetition in model names, if any
84
+ models_list = []
85
+ for i in range(len(df)):
86
+ model_name = df.iloc[i][model_col_name]
87
+ splits = model_name.split('--')
88
+ splits = [split.replace('-t0.0', '') for split in splits] # Comment to not remove -t0.0
89
+ if splits[0] == splits[1]:
90
+ models_list.append(splits[0])
91
+ else:
92
+ models_list.append(splits[0] + "--" + splits[1])
93
+ df[model_col_name] = models_list
94
+
95
+ # Update column names
96
+ update = ['Model', 'Clemscore', '% Played', 'Quality Score']
97
+ game_metrics = list_column_names[4:]
98
+
99
+ for col in game_metrics:
100
+ splits = col.split(',')
101
+ update.append(splits[0].capitalize() + "" + splits[1])
102
+
103
+ map_cols = {}
104
+ for i in range(len(update)):
105
+ map_cols[list_column_names[i]] = str(update[i])
106
+
107
+ df = df.rename(columns=map_cols)
108
+ return df
109
+
110
+ def filter_search(df: pd.DataFrame, query: str) -> pd.DataFrame:
111
+ '''
112
+ Filter the dataframe based on the search query
113
+ Args:
114
+ df: Unfiltered dataframe
115
+ query: a string of queries separated by ";"
116
+ Return:
117
+ filtered_df: Dataframe containing searched queries in the 'Model' column
118
+ '''
119
+ queries = query.split(';')
120
+ list_cols = list(df.columns)
121
+ df_len = len(df)
122
+ filtered_models = []
123
+ models_list = list(df[list_cols[0]])
124
+ for q in queries:
125
+ q = q.lower()
126
+ q = q.strip()
127
+ for i in range(df_len):
128
+ model_name = models_list[i]
129
+ if q in model_name.lower():
130
+ filtered_models.append(model_name) # Append model names containing query q
131
+
132
+ filtered_df = df[df[list_cols[0]].isin(filtered_models)]
133
+
134
+ if query == "":
135
+ return df
136
+
137
+ return filtered_df
src/plot_utils.py ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import plotly.express as px
3
+
4
+ from src.assets.text_content import SHORT_NAMES
5
+
6
+ def plotly_plot(df:pd.DataFrame, LIST:list, ALL:list, NAMES:list):
7
+ '''
8
+ Takes in a list of models for a plotly plot
9
+ Args:
10
+ df: A dummy dataframe of latest version
11
+ LIST: List of models to plot
12
+ ALL: Either [] or ["Show All Models"] - toggle view to plot all models
13
+ NAMES: Either [] or ["Show Names"] - toggle view to show model names on plot
14
+ Returns:
15
+ Fig: plotly figure
16
+ '''
17
+
18
+ # Get list of all models and append short names column to df
19
+ list_columns = list(df.columns)
20
+ ALL_LIST = list(df[list_columns[0]].unique())
21
+ short_names = label_map(ALL_LIST)
22
+ list_short_names = list(short_names.values())
23
+ df["Short"] = list_short_names
24
+
25
+ if ALL:
26
+ LIST = ALL_LIST
27
+ # Filter dataframe based on the provided list of models
28
+ df = df[df[list_columns[0]].isin(LIST)]
29
+
30
+
31
+ if NAMES:
32
+ fig = px.scatter(df, x=list_columns[2], y=list_columns[3], color=list_columns[0], symbol=list_columns[0],
33
+ color_discrete_map={"category1": "blue", "category2": "red"},
34
+ hover_name=list_columns[0], template="plotly_white", text="Short")
35
+ fig.update_traces(textposition='top center')
36
+ else:
37
+ fig = px.scatter(df, x=list_columns[2], y=list_columns[3], color=list_columns[0], symbol=list_columns[0],
38
+ color_discrete_map={"category1": "blue", "category2": "red"},
39
+ hover_name=list_columns[0], template="plotly_white")
40
+
41
+ fig.update_layout(
42
+ xaxis_title='% Played',
43
+ yaxis_title='Quality Score',
44
+ title='Overview of benchmark results',
45
+ height=1000,
46
+ width=1500
47
+ )
48
+
49
+ fig.update_xaxes(range=[-5, 105])
50
+ fig.update_yaxes(range=[-5, 105])
51
+
52
+ return fig
53
+
54
+
55
+ # ['Model', 'Clemscore', 'All(Played)', 'All(Quality Score)']
56
+ def compare_plots(df: pd.DataFrame, LIST1: list, LIST2: list, ALL:list, NAMES:list):
57
+ '''
58
+ Quality Score v/s % Played plot by selecting models
59
+ Args:
60
+ df: A dummy dataframe of latest version
61
+ LIST1: The list of open source models to show in the plot, updated from frontend
62
+ LIST2: The list of commercial models to show in the plot, updated from frontend
63
+ ALL: Either [] or ["Show All Models"] - toggle view to plot all models
64
+ NAMES: Either [] or ["Show Names"] - toggle view to show model names on plot
65
+ Returns:
66
+ fig: The plot
67
+ '''
68
+
69
+ # Combine lists for Open source and commercial models
70
+ LIST = LIST1 + LIST2
71
+ fig = plotly_plot(df, LIST, ALL, NAMES)
72
+
73
+ return fig
74
+
75
+ def shorten_model_name(full_name):
76
+ # Split the name into parts
77
+ parts = full_name.split('-')
78
+
79
+ # Process the name parts to keep only the parts with digits (model sizes and versions)
80
+ short_name_parts = [part for part in parts if any(char.isdigit() for char in part)]
81
+
82
+ if len(parts) == 1:
83
+ short_name = ''.join(full_name[0:min(3, len(full_name))])
84
+ else:
85
+ # Join the parts to form the short name
86
+ short_name = '-'.join(short_name_parts)
87
+
88
+ # Remove any leading or trailing hyphens
89
+ short_name = full_name[0] + '-'+ short_name.strip('-')
90
+
91
+ return short_name
92
+
93
+ def label_map(model_list: list) -> dict:
94
+ '''
95
+ Generate a map from long names to short names, to plot them in frontend graph
96
+ Define the short names in src/assets/text_content.py
97
+ Args:
98
+ model_list: A list of long model names
99
+ Returns:
100
+ short_name: A dict from long to short name
101
+ '''
102
+ short_names = {}
103
+ for model_name in model_list:
104
+ if model_name in SHORT_NAMES:
105
+ short_name = SHORT_NAMES[model_name]
106
+ else:
107
+ short_name = shorten_model_name(model_name)
108
+
109
+ # Define the short name and indicate both models are same
110
+ short_names[model_name] = short_name
111
+
112
+ return short_names
113
+
114
+ def split_models(MODEL_LIST: list):
115
+ '''
116
+ Split the models into open source and commercial
117
+ '''
118
+ open_models = []
119
+ comm_models = []
120
+
121
+ for model in MODEL_LIST:
122
+ if model.startswith(('gpt-', 'claude-', 'command')):
123
+ comm_models.append(model)
124
+ else:
125
+ open_models.append(model)
126
+
127
+ open_models.sort(key=lambda o: o.upper())
128
+ comm_models.sort(key=lambda c: c.upper())
129
+ return open_models, comm_models
src/utils.py DELETED
@@ -1,238 +0,0 @@
1
- import os
2
- import pandas as pd
3
- import matplotlib.pyplot as plt
4
- import numpy as np
5
-
6
- from src.assets.text_content import SHORT_NAMES
7
-
8
- def update_cols(df: pd.DataFrame) -> pd.DataFrame:
9
- '''
10
- Change three header rows to a single header row
11
- Args:
12
- df: Raw dataframe containing 3 separate header rows
13
- Remove this function if the dataframe has only one header row
14
-
15
- Returns:
16
- df: Updated dataframe which has only 1 header row instead of 3
17
- '''
18
- default_cols = list(df.columns)
19
-
20
- # First 4 columns are initalised in 'update', Append additional columns for games Model, Clemscore, ALL(PLayed) and ALL(Main Score)
21
- update = ['Model', 'Clemscore', 'Played', 'Quality Score']
22
- game_metrics = default_cols[4:]
23
-
24
- # Change columns Names for each Game
25
- for i in range(len(game_metrics)):
26
- if i%3 == 0:
27
- game = game_metrics[i]
28
- update.append(str(game).capitalize() + "(Played)")
29
- update.append(str(game).capitalize() + "(Quality Score)")
30
- update.append(str(game).capitalize() + "(Quality Score[std])")
31
-
32
- # Create a dict to change names of the columns
33
- map_cols = {}
34
- for i in range(len(default_cols)):
35
- map_cols[default_cols[i]] = str(update[i])
36
-
37
- df = df.rename(columns=map_cols)
38
- df = df.iloc[2:]
39
-
40
- return df
41
-
42
- def process_df(df: pd.DataFrame) -> pd.DataFrame:
43
- '''
44
- Process dataframe - Remove repition in model names, convert datatypes to sort by "float" instead of "str"
45
- Args:
46
- df: Unprocessed Dataframe (after using update_cols)
47
- Returns:
48
- df: Processed Dataframe
49
- '''
50
-
51
- # Change column type to float from str
52
- list_column_names = list(df.columns)
53
- model_col_name = list_column_names[0]
54
- for col in list_column_names:
55
- if col != model_col_name:
56
- df[col] = df[col].astype(float)
57
-
58
- # Remove repetition in model names, if any
59
- models_list = []
60
- for i in range(len(df)):
61
- model_name = df.iloc[i][model_col_name]
62
- splits = model_name.split('--')
63
- splits = [split.replace('-t0.0', '') for split in splits] # Comment to not remove -t0.0
64
- if splits[0] == splits[1]:
65
- models_list.append(splits[0])
66
- else:
67
- models_list.append(splits[0] + "--" + splits[1])
68
- df[model_col_name] = models_list
69
-
70
- return df
71
-
72
- def get_data(path: str, flag: bool):
73
- '''
74
- Get a list of all version names and respective Dataframes
75
- Args:
76
- path: Path to the directory containing CSVs of different versions -> v0.9.csv, v1.0.csv, ....
77
- flag: Set this flag to include the latest version in Details and Versions tab
78
- Returns:
79
- latest_df: singular list containing dataframe of the latest version of the leaderboard with only 4 columns
80
- latest_vname: list of the name of latest version
81
- previous_df: list of dataframes for previous versions (can skip latest version if required)
82
- previous_vname: list of the names for the previous versions (INCLUDED IN Details and Versions Tab)
83
-
84
- '''
85
- # Check if Directory is empty
86
- list_versions = os.listdir(path)
87
- if not list_versions:
88
- print("Directory is empty")
89
-
90
- else:
91
- files = [file for file in list_versions if file.endswith('.csv')]
92
- files.sort(reverse=True)
93
- file_names = [os.path.splitext(file)[0] for file in files]
94
-
95
- DFS = []
96
- for file in files:
97
- df = pd.read_csv(os.path.join(path, file))
98
- df = update_cols(df) # Remove if by default there is only one header row
99
- df = process_df(df) # Process Dataframe
100
- df = df.sort_values(by=list(df.columns)[1], ascending=False) # Sort by clemscore
101
- DFS.append(df)
102
-
103
- # Only keep relavant columns for the main leaderboard
104
- latest_df_dummy = DFS[0]
105
- all_columns = list(latest_df_dummy.columns)
106
- keep_columns = all_columns[0:4]
107
- latest_df_dummy = latest_df_dummy.drop(columns=[c for c in all_columns if c not in keep_columns])
108
-
109
- latest_df = [latest_df_dummy]
110
- latest_vname = [file_names[0]]
111
- previous_df = []
112
- previous_vname = []
113
- for df, name in zip(DFS, file_names):
114
- previous_df.append(df)
115
- previous_vname.append(name)
116
-
117
- if not flag:
118
- previous_df.pop(0)
119
- previous_vname.pop(0)
120
-
121
- return latest_df, latest_vname, previous_df, previous_vname
122
-
123
- return None
124
-
125
-
126
- # ['Model', 'Clemscore', 'All(Played)', 'All(Quality Score)']
127
- def compare_plots(df: pd.DataFrame, LIST: list):
128
- '''
129
- Quality Score v/s % Played plot by selecting models
130
- Args:
131
- LIST: The list of models to show in the plot, updated from frontend
132
- Returns:
133
- fig: The plot
134
- '''
135
- short_names = label_map(LIST)
136
-
137
- list_columns = list(df.columns)
138
- df = df[df[list_columns[0]].isin(LIST)]
139
-
140
- X = df[list_columns[2]]
141
- fig, ax = plt.subplots()
142
- for model in LIST:
143
- short = short_names[model]
144
- # same_flag = short_names[model][1]
145
- model_df = df[df[list_columns[0]] == model]
146
- x = model_df[list_columns[2]]
147
- y = model_df[list_columns[3]]
148
- color = plt.cm.rainbow(x / max(X)) # Use a colormap for different colors
149
- plt.scatter(x, y, color=color)
150
- # if same_flag:
151
- plt.annotate(f'{short}', (x, y), textcoords="offset points", xytext=(0, -15), ha='center', rotation=0)
152
- # else:
153
- # plt.annotate(f'{short}', (x, y), textcoords="offset points", xytext=(20, -3), ha='center', rotation=0)
154
- ax.grid(which='both', color='grey', linewidth=1, linestyle='-', alpha=0.2)
155
- ax.set_xticks(np.arange(0,110,10))
156
- plt.xlim(-10, 110)
157
- plt.ylim(-10, 110)
158
- plt.xlabel('% Played')
159
- plt.ylabel('Quality Score')
160
- plt.title('Overview of benchmark results')
161
- plt.show()
162
-
163
- return fig
164
-
165
- def shorten_model_name(full_name):
166
- # Split the name into parts
167
- parts = full_name.split('-')
168
-
169
- # Process the name parts to keep only the parts with digits (model sizes and versions)
170
- short_name_parts = [part for part in parts if any(char.isdigit() for char in part)]
171
-
172
- if len(parts) == 1:
173
- short_name = ''.join(full_name[0:min(3, len(full_name))])
174
- else:
175
- # Join the parts to form the short name
176
- short_name = '-'.join(short_name_parts)
177
-
178
- # Remove any leading or trailing hyphens
179
- short_name = full_name[0] + '-'+ short_name.strip('-')
180
-
181
- return short_name
182
-
183
- def label_map(model_list: list) -> dict:
184
- '''
185
- Generate a map from long names to short names, to plot them in frontend graph
186
- Define the short names in src/assets/text_content.py
187
- Args:
188
- model_list: A list of long model names
189
- Returns:
190
- short_name: A map from long to list of short name + indication if models are same or different
191
- '''
192
- short_names = {}
193
- for model_name in model_list:
194
- # splits = model_name.split('--')
195
- # if len(splits) != 1:
196
- # splits[0] = SHORT_NAMES[splits[0] + '-']
197
- # splits[1] = SHORT_NAMES[splits[1] + '-']
198
- # # Define the short name and indicate there are two different models
199
- # short_names[model_name] = [splits[0] + '--' + splits[1], 0]
200
- # else:
201
- if model_name in SHORT_NAMES:
202
- short_name = SHORT_NAMES[model_name]
203
- else:
204
- short_name = shorten_model_name(model_name)
205
-
206
- # Define the short name and indicate both models are same
207
- short_names[model_name] = short_name
208
-
209
- return short_names
210
-
211
- def filter_search(df: pd.DataFrame, query: str) -> pd.DataFrame:
212
- '''
213
- Filter the dataframe based on the search query
214
- Args:
215
- df: Unfiltered dataframe
216
- query: a string of queries separated by ";"
217
- Return:
218
- filtered_df: Dataframe containing searched queries in the 'Model' column
219
- '''
220
- queries = query.split(';')
221
- list_cols = list(df.columns)
222
- df_len = len(df)
223
- filtered_models = []
224
- models_list = list(df[list_cols[0]])
225
- for q in queries:
226
- q = q.lower()
227
- for i in range(df_len):
228
- model_name = models_list[i]
229
- if q in model_name.lower():
230
- filtered_models.append(model_name) # Append model names containing query q
231
-
232
- filtered_df = df[df[list_cols[0]].isin(filtered_models)]
233
-
234
- if query == "":
235
- return df
236
-
237
- return filtered_df
238
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
versions/v0.9.csv DELETED
@@ -1,14 +0,0 @@
1
- ,-,all,all,imagegame,imagegame,imagegame,privateshared,privateshared,privateshared,referencegame,referencegame,referencegame,taboo,taboo,taboo,wordle,wordle,wordle,wordle_withclue,wordle_withclue,wordle_withclue,wordle_withcritic,wordle_withcritic,wordle_withcritic
2
- ,clemscore,Average % Played,Average Quality Score,% Played,Quality Score,Quality Score (std),% Played,Quality Score,Quality Score (std),% Played,Quality Score,Quality Score (std),% Played,Quality Score,Quality Score (std),% Played,Quality Score,Quality Score (std),% Played,Quality Score,Quality Score (std),% Played,Quality Score,Quality Score (std)
3
- model,,,,,,,,,,,,,,,,,,,,,,,,
4
- claude-v1.3-t0.0--claude-v1.3-t0.0,37.07,74.76,49.58,0.0,,,100.0,84.87,18.87,100.0,82.5,38.48,76.92,68.75,38.71,100.0,0.0,0.0,100.0,30.56,40.13,46.43,30.77,48.04
5
- falcon-40b-t0.0--falcon-40b-t0.0,0.71,0.95,75.0,0.0,,,0.0,,,0.0,,,0.0,,,0.0,,,3.33,50.0,,3.33,100.0,
6
- gpt-3.5-turbo-t0.0--gpt-3.5-turbo-t0.0,37.02,85.86,43.12,97.5,60.28,25.95,64.0,72.83,13.07,100.0,55.0,50.38,69.49,71.95,44.79,100.0,0.0,0.0,93.33,28.57,46.0,76.67,13.19,30.16
7
- gpt-3.5-turbo-t0.0--gpt-4-t0.0,42.39,86.75,48.87,97.5,64.95,25.45,,,,100.0,57.5,50.06,69.49,62.6,45.15,,,,,,,80.0,10.42,17.42
8
- gpt-4-t0.0--gpt-3.5-turbo-t0.0,55.62,82.78,67.19,65.0,81.0,21.54,,,,100.0,47.5,50.57,66.1,93.59,23.45,,,,,,,100.0,46.67,42.92
9
- gpt-4-t0.0--gpt-4-t0.0,59.49,96.06,61.93,77.5,89.06,22.28,100.0,90.79,8.2,100.0,75.0,43.85,94.92,76.19,37.45,100.0,3.67,8.4,100.0,49.67,42.09,100.0,49.11,38.46
10
- koala-13b-t0.0--koala-13b-t0.0,1.48,14.76,10.0,0.0,,,0.0,,,0.0,,,0.0,,,86.67,0.0,0.0,16.67,20.0,44.72,0.0,,
11
- luminous-supreme-t0.0--luminous-supreme-t0.0,0.0,16.24,0.0,0.0,,,0.0,,,0.0,,,0.0,,,100.0,0.0,0.0,3.33,0.0,,10.34,0.0,0.0
12
- oasst-12b-t0.0--oasst-12b-t0.0,1.74,20.85,8.33,0.0,,,0.0,,,15.0,33.33,51.64,0.0,,,100.0,0.0,0.0,16.67,0.0,0.0,14.29,0.0,0.0
13
- text-davinci-003-t0.0--text-davinci-003-t0.0,15.78,44.5,35.46,57.5,38.7,27.78,16.0,14.1,25.21,82.5,36.36,48.85,28.81,76.47,43.72,66.67,1.25,5.59,36.67,31.36,38.99,23.33,50.0,50.0
14
- vicuna-13b-t0.0--vicuna-13b-t0.0,4.24,13.58,31.25,0.0,,,0.0,,,0.0,,,5.08,100.0,0.0,56.67,0.0,0.0,13.33,25.0,50.0,20.0,0.0,0.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
versions/v1.0.csv DELETED
@@ -1,34 +0,0 @@
1
- ,-,all,all,imagegame,imagegame,imagegame,privateshared,privateshared,privateshared,referencegame,referencegame,referencegame,taboo,taboo,taboo,wordle,wordle,wordle,wordle_withclue,wordle_withclue,wordle_withclue,wordle_withcritic,wordle_withcritic,wordle_withcritic
2
- ,clemscore,Average % Played,Average Quality Score,% Played,Quality Score,Quality Score (std),% Played,Quality Score,Quality Score (std),% Played,Quality Score,Quality Score (std),% Played,Quality Score,Quality Score (std),% Played,Quality Score,Quality Score (std),% Played,Quality Score,Quality Score (std),% Played,Quality Score,Quality Score (std)
3
- model,,,,,,,,,,,,,,,,,,,,,,,,
4
- CodeLlama-34b-Instruct-hf-t0.0--CodeLlama-34b-Instruct-hf-t0.0,10.34,23.96,43.15,7.5,37.67,36.83,0.0,,,15.0,83.33,40.82,74.58,29.55,44.87,53.33,0.0,0.0,13.33,8.33,16.66,4.0,100.0,
5
- Mistral-7B-Instruct-v0.1-t0.0--Mistral-7B-Instruct-v0.1-t0.0,2.72,17.5,15.56,,,,20.0,0.0,0.0,,,,50.85,46.67,49.01,0.0,,,16.67,0.0,0.0,0.0,,
6
- Wizard-Vicuna-13B-Uncensored-HF-t0.0--Wizard-Vicuna-13B-Uncensored-HF-t0.0,2.06,9.49,21.71,0.0,,,0.0,,,7.5,66.67,57.74,22.03,30.77,48.04,3.33,0.0,,30.0,11.11,33.33,3.57,0.0,
7
- WizardLM-13b-v1.2-t0.0--WizardLM-13b-v1.2-t0.0,7.82,40.49,19.31,0.0,,,26.0,21.37,20.34,100.0,35.0,48.3,47.46,51.79,48.08,33.33,0.0,0.0,43.33,7.69,27.74,33.33,0.0,0.0
8
- WizardLM-70b-v1.0-t0.0--WizardLM-70b-v1.0-t0.0,16.7,51.65,32.34,0.0,,,24.0,62.3,19.84,100.0,32.5,47.43,62.71,67.57,47.46,60.0,0.0,0.0,70.0,21.43,40.53,44.83,10.26,28.49
9
- Yi-34B-Chat-t0.0--Yi-34B-Chat-t0.0,16.77,63.76,26.3,100.0,21.25,17.87,0.0,,,100.0,27.5,45.22,79.66,46.81,50.44,86.67,0.0,0.0,50.0,28.89,45.19,30.0,33.33,50.0
10
- claude-2-t0.0--claude-2-t0.0,33.71,82.12,41.05,0.0,,,100.0,75.89,18.57,100.0,45.0,50.38,91.53,73.15,39.71,100.0,0.0,0.0,90.0,21.6,36.56,93.33,30.65,43.22
11
- claude-2.1-t0.0--claude-2.1-t0.0,36.38,83.08,43.79,0.0,,,100.0,73.01,23.8,100.0,55.0,50.38,94.92,69.35,41.41,100.0,0.67,3.65,93.33,29.29,40.95,93.33,35.42,41.74
12
- claude-instant-1.2-t0.0--claude-instant-1.2-t0.0,15.44,59.61,25.91,0.0,,,96.0,34.37,30.79,0.0,,,77.97,60.51,44.77,100.0,0.0,0.0,90.0,18.52,37.08,53.33,16.15,28.94
13
- claude-v1.3-t0.0--claude-v1.3-t0.0,37.64,74.24,50.7,0.0,,,100.0,84.99,18.63,100.0,85.0,36.16,79.66,72.34,37.31,96.67,0.0,0.0,100.0,31.11,39.81,43.33,30.77,48.04
14
- command-t0.0--command-t0.0,3.12,10.01,31.13,0.0,,,0.0,,,2.5,0.0,,47.46,17.86,39.0,0.0,,,16.67,6.67,14.91,3.45,100.0,
15
- falcon-7b-instruct-t0.0--falcon-7b-instruct-t0.0,0.0,14.29,0.0,0.0,,,0.0,,,0.0,,,0.0,,,100.0,0.0,0.0,0.0,,,0.0,,
16
- gpt-3.5-turbo-0613-t0.0--gpt-3.5-turbo-0613-t0.0,32.53,91.96,35.37,97.5,62.49,30.09,91.84,21.17,25.65,100.0,55.0,50.38,64.41,63.16,47.48,100.0,0.0,0.0,100.0,21.38,38.8,90.0,24.38,35.8
17
- gpt-3.5-turbo-1106-t0.0--gpt-3.5-turbo-1106-t0.0,30.45,77.12,39.49,40.0,51.25,34.69,46.94,27.41,33.38,100.0,52.5,50.57,72.88,76.74,39.86,100.0,0.0,0.0,86.67,30.9,44.36,93.33,37.62,45.9
18
- gpt-4-0314-t0.0--gpt-4-0314-t0.0,58.81,93.79,62.7,65.0,88.92,16.24,100.0,91.12,7.48,100.0,77.5,42.29,91.53,79.63,32.48,100.0,2.78,7.37,100.0,50.78,41.69,100.0,48.17,41.42
19
- gpt-4-0613-t0.0--gpt-4-0613-t0.0,60.9,97.22,62.64,97.5,97.28,10.38,100.0,97.34,5.02,100.0,80.0,40.51,83.05,81.97,29.03,100.0,4.25,8.62,100.0,46.11,41.85,100.0,31.5,38.1
20
- gpt-4-1106-preview-t0.0--gpt-4-1106-preview-t0.0,60.33,97.95,61.59,97.5,94.15,14.85,100.0,83.25,12.51,100.0,90.0,30.38,88.14,83.97,29.88,100.0,7.5,13.01,100.0,49.11,42.93,100.0,23.17,37.74
21
- gpt4all-13b-snoozy-t0.0--gpt4all-13b-snoozy-t0.0,0.0,2.92,0.0,0.0,,,0.0,,,0.0,,,0.0,,,0.0,,,13.33,0.0,0.0,7.14,0.0,0.0
22
- koala-13B-HF-t0.0--koala-13B-HF-t0.0,1.25,23.22,5.38,0.0,,,0.0,,,0.0,,,52.54,16.13,37.39,100.0,0.0,0.0,10.0,0.0,0.0,0.0,,
23
- llama-2-13b-chat-hf-t0.0--llama-2-13b-chat-hf-t0.0,1.89,3.43,55.09,0.0,,,24.0,55.09,33.68,0.0,,,0.0,,,0.0,,,0.0,,,0.0,,
24
- llama-2-70b-chat-hf-t0.0--llama-2-70b-chat-hf-t0.0,1.39,3.79,36.74,0.0,,,14.0,13.48,11.98,12.5,60.0,54.77,0.0,,,0.0,,,0.0,,,0.0,,
25
- llama-2-7b-chat-hf-t0.0--llama-2-7b-chat-hf-t0.0,0.24,6.05,4.0,0.0,,,0.0,,,0.0,,,42.37,4.0,20.0,0.0,,,0.0,,,0.0,,
26
- oasst-sft-4-pythia-12b-epoch-3.5-t0.0--oasst-sft-4-pythia-12b-epoch-3.5-t0.0,0.0,14.76,0.0,0.0,,,0.0,,,0.0,,,0.0,,,100.0,0.0,0.0,3.33,0.0,,0.0,,
27
- openchat_3.5-t0.0--openchat_3.5-t0.0,19.72,57.57,34.26,27.5,7.73,13.87,78.0,69.9,29.92,100.0,37.5,49.03,50.85,55.0,49.74,76.67,0.0,0.0,53.33,29.69,43.99,16.67,40.0,54.77
28
- sheep-duck-llama-2-13b-t0.0--sheep-duck-llama-2-13b-t0.0,6.74,34.86,19.34,0.0,,,0.0,,,97.5,33.33,47.76,89.83,0.0,0.0,0.0,,,23.33,19.05,37.8,33.33,25.0,42.49
29
- sheep-duck-llama-2-70b-v1.1-t0.0--sheep-duck-llama-2-70b-v1.1-t0.0,17.12,40.82,41.93,40.0,23.19,28.06,0.0,,,35.0,57.14,51.36,59.32,74.29,44.34,34.78,0.0,0.0,63.33,43.86,43.82,53.33,53.12,49.9
30
- vicuna-13b-v1.5-t0.0--vicuna-13b-v1.5-t0.0,7.21,34.74,20.74,0.0,,,24.0,0.0,0.0,80.0,28.12,45.68,49.15,37.93,49.38,26.67,0.0,0.0,36.67,30.3,45.84,26.67,28.12,45.19
31
- vicuna-33b-v1.3-t0.0--vicuna-33b-v1.3-t0.0,9.15,17.47,52.36,15.0,23.67,24.34,40.0,34.58,26.47,0.0,,,37.29,50.0,51.18,0.0,,,23.33,53.57,46.61,6.67,100.0,0.0
32
- vicuna-7b-v1.5-t0.0--vicuna-7b-v1.5-t0.0,3.46,12.86,26.91,0.0,,,4.0,0.0,0.0,0.0,,,62.71,24.32,43.5,0.0,,,13.33,50.0,57.74,10.0,33.33,57.74
33
- zephyr-7b-alpha-t0.0--zephyr-7b-alpha-t0.0,0.75,7.51,10.0,0.0,,,0.0,,,0.0,,,0.0,,,0.0,,,33.33,20.0,42.16,19.23,0.0,0.0
34
- zephyr-7b-beta-t0.0--zephyr-7b-beta-t0.0,1.23,3.95,31.25,0.0,,,0.0,,,0.0,,,0.0,,,0.0,,,13.33,25.0,50.0,14.29,37.5,47.87