File size: 13,031 Bytes
925ac7f
 
b7fabea
54d8c8e
fd62121
 
925ac7f
ee6a180
144f299
 
68e6513
 
ee6a180
144f299
1580227
f16f37c
fd62121
 
f16f37c
144f299
1580227
144f299
54d8c8e
68e6513
fbdc657
 
 
68e6513
fbdc657
 
 
 
 
 
 
 
68e6513
144f299
68e6513
 
144f299
fbdc657
 
144f299
 
 
 
 
 
fbdc657
 
68e6513
 
 
fbdc657
 
68e6513
 
 
f16f37c
68e6513
ee6a180
1580227
 
54d8c8e
1580227
 
 
925ac7f
fbdc657
 
 
fd62121
 
 
 
 
 
 
 
1580227
fd62121
144f299
 
3433b65
54d8c8e
3433b65
fbdc657
 
 
3433b65
 
 
 
fbdc657
 
3433b65
 
 
 
 
144f299
3433b65
 
 
fd62121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7ce5480
3433b65
 
 
 
144f299
3433b65
144f299
3433b65
 
 
 
 
144f299
 
 
3433b65
 
 
 
 
 
 
144f299
3433b65
 
 
 
 
fbdc657
 
3433b65
 
 
 
 
144f299
1580227
 
3433b65
1580227
3433b65
 
 
 
 
 
 
144f299
1580227
 
3433b65
 
 
 
 
 
 
 
144f299
1580227
3433b65
 
 
 
 
 
 
 
144f299
1580227
3433b65
 
925ac7f
54d8c8e
 
 
 
 
 
68e6513
54d8c8e
 
 
fbdc657
54d8c8e
68e6513
 
 
 
 
 
 
 
54d8c8e
68e6513
 
fbdc657
 
fd62121
68e6513
 
 
 
fbdc657
68e6513
fbdc657
 
fd62121
68e6513
 
 
 
 
 
fbdc657
 
fd62121
68e6513
 
 
 
 
 
fbdc657
 
fd62121
fbdc657
 
 
 
 
 
 
 
fd62121
fbdc657
 
 
 
 
 
 
 
fd62121
fbdc657
 
 
 
 
 
 
 
fd62121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbdc657
 
 
 
fd62121
fbdc657
 
 
fd62121
fbdc657
 
 
 
fd62121
fbdc657
 
 
fd62121
fbdc657
 
 
 
 
 
 
 
fd62121
68e6513
 
 
54d8c8e
 
bbae640
 
54d8c8e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3433b65
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
import pandas as pd
import gradio as gr
import os
from gradio_rangeslider import RangeSlider
import calendar
import datetime

from src.filter_utils import filter, filter_cols
from src.process_data import merge_data
import assets.text_content as tc

# Main Leaderboard containing everything
text_leaderboard = pd.read_csv(os.path.join('assets', 'merged_data.csv'))
text_leaderboard = text_leaderboard.sort_values(by=tc.CLEMSCORE, ascending=False)  

# When displaying latency values
text_leaderboard[tc.LATENCY] = text_leaderboard[tc.LATENCY].round(1)
text_leaderboard[tc.CLEMSCORE] = text_leaderboard[tc.CLEMSCORE].round(1)

open_weight_df = text_leaderboard[text_leaderboard[tc.OPEN_WEIGHT] == True]
if not open_weight_df.empty:  # Check if filtered df is non-empty
    max_parameter_size = open_weight_df[tc.PARAMS].max()

# Short leaderboard containing fixed columns
short_leaderboard = filter_cols(text_leaderboard)

## Extract data
langs = []
licenses = []
ip_prices = []
op_prices = []
latencies = []
parameters = []
contexts = []
dates = []

for i in range(len(text_leaderboard)):
    lang_splits = text_leaderboard.iloc[i][tc.LANGS].split(',')
    lang_splits = [s.strip() for s in lang_splits]
    langs += lang_splits
    license_name = text_leaderboard.iloc[i][tc.LICENSE_NAME]

    licenses.append(license_name)
    ip_prices.append(text_leaderboard.iloc[i][tc.INPUT])
    op_prices.append(text_leaderboard.iloc[i][tc.OUTPUT])
    latencies.append(text_leaderboard.iloc[i][tc.LATENCY])
    parameters.append(text_leaderboard.iloc[i][tc.PARAMS])
    contexts.append(text_leaderboard.iloc[i][tc.CONTEXT])
    dates.append(text_leaderboard.iloc[i][tc.RELEASE_DATE])


langs = list(set(langs))
langs.sort()

licenses = list(set(licenses))
licenses.sort()

max_input_price = max(ip_prices)
max_output_price = max(op_prices)
max_latency = text_leaderboard[tc.LATENCY].max().round(3)

min_parameters = 0 if pd.isna(min(parameters)) else min(parameters)
max_parameter = max_parameter_size
parameter_step = 1

min_context = min(contexts)
max_context = max(contexts)
context_step = 8

min_date = min(dates)
max_date = max(dates)

# Date settings
today = datetime.date.today()
end_year = today.year
start_year = tc.START_YEAR

YEARS = list(range(int(start_year), int(end_year)+1))
YEARS = [str(y) for y in YEARS] 
MONTHS = list(calendar.month_name[1:])

TITLE = tc.TITLE

llm_calc_app = gr.Blocks()
with llm_calc_app:

    gr.HTML(TITLE)

    with gr.Row():

        #####################################
        # First Column
        ####################################
        ## Language Select
        with gr.Column():

            with gr.Row():
                lang_dropdown = gr.Dropdown(
                    choices=langs,
                    value=[],
                    multiselect=True,
                    label="Languages πŸ—£οΈ"
                )

            with gr.Row():
                with gr.Column():
                    start_year = gr.Dropdown(
                        choices=YEARS,
                        value=[YEARS[0]],
                        allow_custom_value=True
                    )
                    start_month = gr.Dropdown(
                        choices=MONTHS,
                        value=[MONTHS[0]],
                        allow_custom_value=True
                    )

                with gr.Column():
                    end_year = gr.Dropdown(
                        choices=YEARS,
                        value=[YEARS[-1]],
                        allow_custom_value=True
                    )
                    end_month = gr.Dropdown(
                        choices=MONTHS,
                        value=[MONTHS[-1]],
                        allow_custom_value=True
                    )


            # Multiodality Select
            with gr.Row():
                multimodal_checkbox = gr.CheckboxGroup(
                    choices=[tc.SINGLE_IMG, tc.MULT_IMG, tc.AUDIO, tc.VIDEO],
                    value=[],
                    label="Additional Modalities πŸ“·πŸŽ§πŸŽ¬",
                )

            # Open/Commercial Selection
            with gr.Row():
                open_weight_checkbox = gr.CheckboxGroup(
                    choices=[tc.OPEN, tc.COMM],
                    value=[tc.OPEN, tc.COMM],
                    label="Model Type πŸ”“ πŸ’Ό",
                )    

            # License selection
            with gr.Row():
                license_checkbox = gr.CheckboxGroup(
                    choices=licenses,
                    value=licenses,
                    label="License πŸ›‘οΈ",
                )    
        
        #############################################################
        # Second Column
        #############################################################
        with gr.Column():

            ####### LOG SLIDER 1 ###########
            with gr.Row():
                parameter_slider = RangeSlider(
                    minimum=0, 
                    maximum=max_parameter, 
                    label=f"Parameters πŸ” {int(min_parameters)}B - {int(max_parameter)}B+",
                    elem_id="double-slider-1",
                    step=parameter_step
                )

                
            ########### LOG SLIDER 2 ################

            with gr.Row():
                context_slider = RangeSlider(
                    minimum=0, 
                    maximum=max_context, 
                    label="Context (k) πŸ“",
                    elem_id="double-slider-2",
                    step=context_step
                )

            ############# PRICE SLIDER 1 ###############
            with gr.Row():
                input_pricing_slider = RangeSlider(
                    minimum=0, 
                    maximum=max_input_price, 
                    value=(0, max_input_price), 
                    label="πŸ’²/1M input tokens",
                    elem_id="double-slider-3"
                )
            
            ############### PRICE SLIDER 2 ###############
            with gr.Row():
                output_pricing_slider = RangeSlider(
                    minimum=0, 
                    maximum=max_output_price, 
                    value=(0, max_output_price), 
                    label="πŸ’²/1M output tokens",
                    elem_id="double-slider-4"
                )
       

    with gr.Row():
        """
        Main Leaderboard Row
        """

        leaderboard_table = gr.Dataframe(
                                value=short_leaderboard,
                                elem_id="text-leaderboard-table",
                                interactive=False,
                                visible=True,
                                datatype=['html', 'number', 'number', 'date', 'number', 'number', 'number', 'number', 'html']
                            )

        
        dummy_leaderboard_table = gr.Dataframe(
                                value=text_leaderboard,
                                elem_id="dummy-leaderboard-table",
                                interactive=False,
                                visible=False
                            )
        
        lang_dropdown.change(
            filter,
            [dummy_leaderboard_table, lang_dropdown, parameter_slider,
             input_pricing_slider, output_pricing_slider, multimodal_checkbox,
             context_slider, open_weight_checkbox, start_year, start_month, end_year, end_month, license_checkbox],
            [leaderboard_table],   
            queue=True
        )

        parameter_slider.change(
            filter,
            [dummy_leaderboard_table, lang_dropdown, parameter_slider,
             input_pricing_slider, output_pricing_slider, multimodal_checkbox,
             context_slider, open_weight_checkbox, start_year, start_month, end_year, end_month, license_checkbox],
            [leaderboard_table],
            queue=True
        )

        input_pricing_slider.change(
            filter,
            [dummy_leaderboard_table, lang_dropdown, parameter_slider,
             input_pricing_slider, output_pricing_slider, multimodal_checkbox,
             context_slider, open_weight_checkbox, start_year, start_month, end_year, end_month, license_checkbox],
            [leaderboard_table],
            queue=True
        )

        output_pricing_slider.change(
            filter,
            [dummy_leaderboard_table, lang_dropdown, parameter_slider,
             input_pricing_slider, output_pricing_slider, multimodal_checkbox,
             context_slider, open_weight_checkbox, start_year, start_month, end_year, end_month, license_checkbox],
            [leaderboard_table],
            queue=True
        )

        multimodal_checkbox.change(
            filter,
            [dummy_leaderboard_table, lang_dropdown, parameter_slider,
             input_pricing_slider, output_pricing_slider, multimodal_checkbox,
             context_slider, open_weight_checkbox, start_year, start_month, end_year, end_month, license_checkbox],
            [leaderboard_table],
            queue=True
        )

        open_weight_checkbox.change(
            filter,
            [dummy_leaderboard_table, lang_dropdown, parameter_slider,
             input_pricing_slider, output_pricing_slider, multimodal_checkbox,
             context_slider, open_weight_checkbox, start_year, start_month, end_year, end_month, license_checkbox],
            [leaderboard_table],
            queue=True
        )

        context_slider.change(
            filter,
            [dummy_leaderboard_table, lang_dropdown, parameter_slider,
             input_pricing_slider, output_pricing_slider, multimodal_checkbox,
             context_slider, open_weight_checkbox, start_year, start_month, end_year, end_month, license_checkbox],
            [leaderboard_table],
            queue=True
        )

        start_year.change(
            filter,
            [dummy_leaderboard_table, lang_dropdown, parameter_slider,
             input_pricing_slider, output_pricing_slider, multimodal_checkbox,
             context_slider, open_weight_checkbox, start_year, start_month, end_year, end_month, license_checkbox],
            [leaderboard_table],
            queue=True
        )

        start_month.change(
            filter,
            [dummy_leaderboard_table, lang_dropdown, parameter_slider,
             input_pricing_slider, output_pricing_slider, multimodal_checkbox,
             context_slider, open_weight_checkbox, start_year, start_month, end_year, end_month, license_checkbox],
            [leaderboard_table],
            queue=True
        )

        end_year.change(
            filter,
            [dummy_leaderboard_table, lang_dropdown, parameter_slider,
             input_pricing_slider, output_pricing_slider, multimodal_checkbox,
             context_slider, open_weight_checkbox, start_year, start_month, end_year, end_month, license_checkbox],
            [leaderboard_table],
            queue=True
        )

        end_month.change(
            filter,
            [dummy_leaderboard_table, lang_dropdown, parameter_slider,
             input_pricing_slider, output_pricing_slider, multimodal_checkbox,
             context_slider, open_weight_checkbox, start_year, start_month, end_year, end_month, license_checkbox],
            [leaderboard_table],
            queue=True
        )

        license_checkbox.change(
            filter,
            [dummy_leaderboard_table, lang_dropdown, parameter_slider,
             input_pricing_slider, output_pricing_slider, multimodal_checkbox,
             context_slider, open_weight_checkbox, start_year, start_month, end_year, end_month, license_checkbox],
            [leaderboard_table],
            queue=True
        )

    llm_calc_app.load()
llm_calc_app.queue()
llm_calc_app.launch()



"""
model_name, input_price, output_price,
multimodality_image,multimodality_multiple_image,multimodality_audio,multimodality_video,
source,licence_name,licence_url,languages,release_date,
parameters_estimated,parameters_actual,

open_weight,context, 

additional_prices_context_caching,
additional_prices_context_storage,
additional_prices_image_input,additional_prices_image_output,additional_prices_video_input,additional_prices_video_output,additional_prices_audio_input,additional_prices_audio_output,clemscore_v1.6.5_multimodal,clemscore_v1.6.5_ascii,clemscore_v1.6,latency_v1.6,latency_v1.6.5_multimodal,latency_v1.6.5_ascii,

average_clemscore,average_latency,parameters

Final list

model_name, input_price, output_price,
multimodality_image,multimodality_multiple_image,multimodality_audio,multimodality_video,
source,licence_name,licence_url,languages,release_date, open_weight,context, average_clemscore,average_latency,parameters


Filter
multimodality_image,multimodality_multiple_image,multimodality_audio,multimodality_video,
licence_name+licence_url, languages, release_date, open_weight

RR
model_name, input_price, output_price,
source, release_date

"""