Hannah commited on
Commit
f0ad9ed
·
1 Parent(s): ff17adc

not initial

Browse files
Files changed (4) hide show
  1. app.py +175 -0
  2. hf.svg +10 -0
  3. requirements.txt +8 -0
  4. style.css +44 -0
app.py ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import numpy as np
3
+ import gradio as gr
4
+ from urllib.parse import quote
5
+
6
+ def style_dataframe(df):
7
+ if len(df) == 0:
8
+ return df
9
+
10
+ highlight_cols = ["Average", "IFEval", "BBHI", "MATH", "GPQA", "MUJB", "MMLU-PRO"]
11
+ styled = df.style
12
+
13
+ def highlight_green(val):
14
+ try:
15
+ val_float = float(str(val).replace('%', '').replace(' kg', ''))
16
+ return f'background: linear-gradient(90deg, rgba(46, 125, 50, 0.5) {val_float}%, rgba(46, 125, 50, 0.1) {val_float}%); color: white;'
17
+ except:
18
+ return 'background-color: #121212; color: white;'
19
+
20
+ for col in highlight_cols:
21
+ styled = styled.applymap(highlight_green, subset=[col])
22
+
23
+ styled = styled.set_properties(
24
+ subset=["Model"],
25
+ **{'color': '#4da6ff'}
26
+ )
27
+
28
+ return styled
29
+
30
+ def create_leaderboard_data():
31
+ models = [
32
+ {"model_name": "meta-llama/llama-3-70b-instruct", "type": "open"},
33
+ {"model_name": "mistralai/Mistral-7B-Instruct-v0.3", "type": "open"},
34
+ {"model_name": "google/gemma-7b-it", "type": "open"},
35
+ {"model_name": "Qwen/Qwen2-7B-Instruct", "type": "open"},
36
+ {"model_name": "anthropic/claude-3-opus", "type": "closed"},
37
+ {"model_name": "OpenAI/gpt-4o", "type": "closed"},
38
+ {"model_name": "01-ai/Yi-1.5-34B-Chat", "type": "open"},
39
+ {"model_name": "google/gemma-2b", "type": "open"},
40
+ {"model_name": "microsoft/phi-3-mini-4k-instruct", "type": "open"},
41
+ {"model_name": "microsoft/phi-3-mini-128k-instruct", "type": "open"},
42
+ {"model_name": "stabilityai/stable-beluga-7b", "type": "open"},
43
+ {"model_name": "togethercomputer/RedPajama-INCITE-7B-Instruct", "type": "open"},
44
+ {"model_name": "databricks/dbrx-instruct", "type": "closed"},
45
+ {"model_name": "mosaicml/mpt-7b-instruct", "type": "open"},
46
+ {"model_name": "01-ai/Yi-1.5-9B-Chat", "type": "open"}
47
+ ]
48
+
49
+ np.random.seed(42)
50
+
51
+ rows = []
52
+ for i, model in enumerate(models, 1):
53
+ model_name = model["model_name"]
54
+ model_type = model["type"]
55
+
56
+ emoji = "🟢" if model_type.lower() == "open" else "🔴"
57
+ type_with_emoji = f"{emoji} {model_type.upper()}"
58
+
59
+ if "/" in model_name:
60
+ org, name = model_name.split("/", 1)
61
+ model_link = f"[{model_name}](https://huggingface.co/{quote(model_name)})"
62
+ else:
63
+ model_link = f"[{model_name}](https://huggingface.co/models?search={quote(model_name)})"
64
+
65
+ average = round(np.random.uniform(40, 90), 2)
66
+ ifeval = round(np.random.uniform(30, 90), 2)
67
+ bbhi = round(np.random.uniform(40, 85), 2)
68
+ math = round(np.random.uniform(20, 80), 2)
69
+ gpqa = round(np.random.uniform(10, 70), 2)
70
+ mujb = round(np.random.uniform(10, 70), 2)
71
+ mmlu = round(np.random.uniform(40, 85), 2)
72
+ co2_cost = round(np.random.uniform(1, 100), 2)
73
+
74
+ rows.append([
75
+ i,
76
+ type_with_emoji,
77
+ model_link,
78
+ f"{average}",
79
+ f"{ifeval}",
80
+ f"{bbhi}",
81
+ f"{math}",
82
+ f"{gpqa}",
83
+ f"{mujb}",
84
+ f"{mmlu}",
85
+ f"{co2_cost} kg"
86
+ ])
87
+
88
+ rows.sort(key=lambda x: float(x[3]), reverse=True)
89
+
90
+ for i, row in enumerate(rows, 1):
91
+ row[0] = i
92
+
93
+ df = pd.DataFrame(rows, columns=["Rank", "Type", "Model", "Average", "IFEval", "BBHI", "MATH", "GPQA", "MUJB", "MMLU-PRO", "CO_Cost"])
94
+ return style_dataframe(df)
95
+
96
+ def get_filter_data():
97
+ return {
98
+ "For Edge Devices": 5,
99
+ "For Consumers": 4,
100
+ "Mid-range": 4,
101
+ "For the GPU-rich": 3,
102
+ "Only Official Providers": 8
103
+ }
104
+
105
+ css = """
106
+ .html-container {
107
+ text-align: center;
108
+ display: flex;
109
+ justify-content: center;
110
+ width: 100%;
111
+ }
112
+
113
+ .dataframe-container {
114
+ margin-top: 0.5rem;
115
+ margin-bottom: 0.5rem;
116
+ }
117
+
118
+ .leaderboard-title {
119
+ font-size: 1.5rem;
120
+ font-weight: bold;
121
+ margin-bottom: 0.25rem;
122
+ color: #f0f0f0;
123
+ }
124
+
125
+ .leaderboard-subtitle {
126
+ font-size: 0.9rem;
127
+ margin-bottom: 1rem;
128
+ color: #a0a0a0;
129
+ }
130
+
131
+ .filters-container {
132
+ margin-bottom: 0.5rem;
133
+ }
134
+ """
135
+
136
+ filter_data = get_filter_data()
137
+ filter_choices = [f"{key} · {value}" for key, value in filter_data.items()]
138
+
139
+ with gr.Blocks(css=css) as demo:
140
+ gr.HTML("""
141
+ <div style="display: flex; align-items: center; justify-content: center; margin-bottom: 10px;">
142
+ <div class="leaderboard-title">Open LLM Leaderboard</div>
143
+ </div>
144
+ <div class="leaderboard-subtitle">Comparing Large Language Models in an open and reproducible way</div>
145
+ """)
146
+
147
+ with gr.Row():
148
+ filters = gr.CheckboxGroup(
149
+ label="Quick Filters",
150
+ choices=filter_choices,
151
+ )
152
+
153
+ with gr.Row():
154
+ status_text = gr.HTML("<div style='text-align: right; color: #888; font-size: 0.8rem;'>Last updated: June 25, 2024 at 10:30 AM</div>")
155
+
156
+ leaderboard_df = create_leaderboard_data()
157
+ leaderboard_table = gr.Dataframe(
158
+ value=leaderboard_df,
159
+ headers=["Rank", "Type", "Model", "Average", "IFEval", "BBHI", "MATH", "GPQA", "MUJB", "MMLU-PRO", "CO_Cost"],
160
+ datatype=["number", "str", "markdown", "str", "str", "str", "str", "str", "str", "str", "str"],
161
+ elem_id="leaderboard-table",
162
+ interactive=False,
163
+ max_height=600,
164
+ show_search="search",
165
+ show_copy_button=True,
166
+ show_fullscreen_button=True,
167
+ pinned_columns=2,
168
+ column_widths=["5%", "7%", "35%", "7%", "7%", "7%", "7%", "7%", "7%", "7%", "6%"]
169
+ )
170
+
171
+ refresh_btn = gr.Button("Refresh Data")
172
+ refresh_btn.click(fn=lambda: create_leaderboard_data(), outputs=leaderboard_table)
173
+
174
+ if __name__ == "__main__":
175
+ demo.launch()
hf.svg ADDED
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ gradio>=3.50.0
2
+ numpy>=1.20.0
3
+ pandas>=1.3.0
4
+ pillow>=8.0,<12.0
5
+ pydub
6
+ pyyaml>=5.0,<7.0
7
+ python-multipart>=0.0.18
8
+ typing_extensions~=4.0
style.css ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .html-container {
2
+ text-align: center;
3
+ display: flex;
4
+ justify-content: center;
5
+ width: 100%;
6
+ }
7
+
8
+ .dataframe-container {
9
+ margin-top: 0.5rem;
10
+ margin-bottom: 0.5rem;
11
+ }
12
+
13
+ .leaderboard-title {
14
+ font-size: 1.5rem;
15
+ font-weight: bold;
16
+ margin-bottom: 0.25rem;
17
+ color: #f0f0f0;
18
+ }
19
+
20
+ .leaderboard-subtitle {
21
+ font-size: 0.9rem;
22
+ margin-bottom: 1rem;
23
+ color: #a0a0a0;
24
+ }
25
+
26
+ .filters-container fieldset {
27
+ display: flex;
28
+ flex-direction: row;
29
+ justify-content: center;
30
+ align-items: center;
31
+ gap: 0.5rem;
32
+ }
33
+
34
+ .refresh-btn {
35
+ margin-top: 0.5rem;
36
+ }
37
+
38
+ .status-container {
39
+ display: flex;
40
+ justify-content: flex-end;
41
+ font-size: 0.75rem;
42
+ color: #a0a0a0;
43
+ }
44
+