Commit
Β·
144f299
1
Parent(s):
3f2d847
Final Changes
Browse files- app.py +28 -34
- assets/__pycache__/text_content.cpython-313.pyc +0 -0
- assets/text_content.py +29 -43
- requirements.txt +1 -2
- src/__pycache__/filter_utils.cpython-313.pyc +0 -0
- src/__pycache__/process_data.cpython-313.pyc +0 -0
- src/filter_utils.py +36 -45
- src/process_data.py +36 -29
app.py
CHANGED
@@ -4,14 +4,16 @@ import os
|
|
4 |
from gradio_rangeslider import RangeSlider
|
5 |
|
6 |
from src.filter_utils import filter, filter_cols
|
|
|
|
|
7 |
|
8 |
# Main Leaderboard containing everything
|
9 |
text_leaderboard = pd.read_csv(os.path.join('assets', 'merged_data.csv'))
|
10 |
-
text_leaderboard = text_leaderboard.sort_values(by=
|
11 |
|
12 |
-
open_weight_df = text_leaderboard[text_leaderboard[
|
13 |
if not open_weight_df.empty: # Check if filtered df is non-empty
|
14 |
-
max_parameter_size = open_weight_df[
|
15 |
|
16 |
# Short leaderboard containing fixed columns
|
17 |
short_leaderboard = filter_cols(text_leaderboard)
|
@@ -27,18 +29,18 @@ contexts = []
|
|
27 |
dates = []
|
28 |
|
29 |
for i in range(len(text_leaderboard)):
|
30 |
-
lang_splits = text_leaderboard.iloc[i][
|
31 |
lang_splits = [s.strip() for s in lang_splits]
|
32 |
langs += lang_splits
|
33 |
-
license_name = text_leaderboard.iloc[i][
|
34 |
|
35 |
licenses.append(license_name)
|
36 |
-
ip_prices.append(text_leaderboard.iloc[i][
|
37 |
-
op_prices.append(text_leaderboard.iloc[i][
|
38 |
-
latencies.append(text_leaderboard.iloc[i][
|
39 |
-
parameters.append(text_leaderboard.iloc[i][
|
40 |
-
contexts.append(text_leaderboard.iloc[i][
|
41 |
-
dates.append(text_leaderboard.iloc[i][
|
42 |
|
43 |
|
44 |
langs = list(set(langs))
|
@@ -54,7 +56,6 @@ max_latency = max(latencies)
|
|
54 |
min_parameters = 0 if pd.isna(min(parameters)) else min(parameters)
|
55 |
max_parameter = max_parameter_size
|
56 |
parameter_step = 1
|
57 |
-
print(f"MIN {min_parameters}, MAX {max_parameter}")
|
58 |
|
59 |
min_context = min(contexts)
|
60 |
max_context = max(contexts)
|
@@ -63,21 +64,14 @@ context_step = 8
|
|
63 |
min_date = min(dates)
|
64 |
max_date = max(dates)
|
65 |
|
66 |
-
TITLE =
|
67 |
-
|
68 |
-
#double-slider-1 {height: 100px}
|
69 |
-
#double-slider-2 {height: 100px}
|
70 |
-
#double-slider-3 {height: 100px}
|
71 |
-
#double-slider-4 {height: 100px}
|
72 |
-
"""
|
73 |
|
74 |
-
llm_calc_app = gr.Blocks(
|
75 |
with llm_calc_app:
|
76 |
|
77 |
gr.HTML(TITLE)
|
78 |
|
79 |
-
##################################################
|
80 |
-
|
81 |
with gr.Row():
|
82 |
|
83 |
#####################################
|
@@ -91,14 +85,14 @@ with llm_calc_app:
|
|
91 |
choices=langs,
|
92 |
value=[],
|
93 |
multiselect=True,
|
94 |
-
label="
|
95 |
)
|
96 |
|
97 |
with gr.Row():
|
98 |
start_date = gr.DateTime(
|
99 |
value=min_date,
|
100 |
type="string",
|
101 |
-
label="Release Date
|
102 |
)
|
103 |
|
104 |
end_date = gr.DateTime(
|
@@ -110,17 +104,17 @@ with llm_calc_app:
|
|
110 |
# Multiodality Select
|
111 |
with gr.Row():
|
112 |
multimodal_checkbox = gr.CheckboxGroup(
|
113 |
-
choices=[
|
114 |
value=[],
|
115 |
-
label="
|
116 |
)
|
117 |
|
118 |
# Open/Commercial Selection
|
119 |
with gr.Row():
|
120 |
open_weight_checkbox = gr.CheckboxGroup(
|
121 |
-
choices=[
|
122 |
-
value=[
|
123 |
-
label="
|
124 |
)
|
125 |
|
126 |
# License selection
|
@@ -128,7 +122,7 @@ with llm_calc_app:
|
|
128 |
license_checkbox = gr.CheckboxGroup(
|
129 |
choices=licenses,
|
130 |
value=licenses,
|
131 |
-
label="License
|
132 |
)
|
133 |
|
134 |
#############################################################
|
@@ -141,7 +135,7 @@ with llm_calc_app:
|
|
141 |
parameter_slider = RangeSlider(
|
142 |
minimum=0,
|
143 |
maximum=max_parameter,
|
144 |
-
label=f"
|
145 |
elem_id="double-slider-1",
|
146 |
step=parameter_step
|
147 |
)
|
@@ -153,7 +147,7 @@ with llm_calc_app:
|
|
153 |
context_slider = RangeSlider(
|
154 |
minimum=0,
|
155 |
maximum=max_context,
|
156 |
-
label="
|
157 |
elem_id="double-slider-2",
|
158 |
step=context_step
|
159 |
)
|
@@ -164,7 +158,7 @@ with llm_calc_app:
|
|
164 |
minimum=0,
|
165 |
maximum=max_input_price,
|
166 |
value=(0, max_input_price),
|
167 |
-
label="
|
168 |
elem_id="double-slider-3"
|
169 |
)
|
170 |
|
@@ -174,7 +168,7 @@ with llm_calc_app:
|
|
174 |
minimum=0,
|
175 |
maximum=max_output_price,
|
176 |
value=(0, max_output_price),
|
177 |
-
label="
|
178 |
elem_id="double-slider-4"
|
179 |
)
|
180 |
|
|
|
4 |
from gradio_rangeslider import RangeSlider
|
5 |
|
6 |
from src.filter_utils import filter, filter_cols
|
7 |
+
from src.process_data import merge_data
|
8 |
+
import assets.text_content as tc
|
9 |
|
10 |
# Main Leaderboard containing everything
|
11 |
text_leaderboard = pd.read_csv(os.path.join('assets', 'merged_data.csv'))
|
12 |
+
text_leaderboard = text_leaderboard.sort_values(by=tc.CLEMSCORE, ascending=False)
|
13 |
|
14 |
+
open_weight_df = text_leaderboard[text_leaderboard[tc.OPEN_WEIGHT] == True]
|
15 |
if not open_weight_df.empty: # Check if filtered df is non-empty
|
16 |
+
max_parameter_size = open_weight_df[tc.PARAMS].max()
|
17 |
|
18 |
# Short leaderboard containing fixed columns
|
19 |
short_leaderboard = filter_cols(text_leaderboard)
|
|
|
29 |
dates = []
|
30 |
|
31 |
for i in range(len(text_leaderboard)):
|
32 |
+
lang_splits = text_leaderboard.iloc[i][tc.LANGS].split(',')
|
33 |
lang_splits = [s.strip() for s in lang_splits]
|
34 |
langs += lang_splits
|
35 |
+
license_name = text_leaderboard.iloc[i][tc.LICENSE_NAME]
|
36 |
|
37 |
licenses.append(license_name)
|
38 |
+
ip_prices.append(text_leaderboard.iloc[i][tc.INPUT])
|
39 |
+
op_prices.append(text_leaderboard.iloc[i][tc.OUTPUT])
|
40 |
+
latencies.append(text_leaderboard.iloc[i][tc.LATENCY])
|
41 |
+
parameters.append(text_leaderboard.iloc[i][tc.PARAMS])
|
42 |
+
contexts.append(text_leaderboard.iloc[i][tc.CONTEXT])
|
43 |
+
dates.append(text_leaderboard.iloc[i][tc.RELEASE_DATE])
|
44 |
|
45 |
|
46 |
langs = list(set(langs))
|
|
|
56 |
min_parameters = 0 if pd.isna(min(parameters)) else min(parameters)
|
57 |
max_parameter = max_parameter_size
|
58 |
parameter_step = 1
|
|
|
59 |
|
60 |
min_context = min(contexts)
|
61 |
max_context = max(contexts)
|
|
|
64 |
min_date = min(dates)
|
65 |
max_date = max(dates)
|
66 |
|
67 |
+
TITLE = tc.TITLE
|
68 |
+
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
+
llm_calc_app = gr.Blocks()
|
71 |
with llm_calc_app:
|
72 |
|
73 |
gr.HTML(TITLE)
|
74 |
|
|
|
|
|
75 |
with gr.Row():
|
76 |
|
77 |
#####################################
|
|
|
85 |
choices=langs,
|
86 |
value=[],
|
87 |
multiselect=True,
|
88 |
+
label="Languages π£οΈ"
|
89 |
)
|
90 |
|
91 |
with gr.Row():
|
92 |
start_date = gr.DateTime(
|
93 |
value=min_date,
|
94 |
type="string",
|
95 |
+
label="Release Date π
| Start Date"
|
96 |
)
|
97 |
|
98 |
end_date = gr.DateTime(
|
|
|
104 |
# Multiodality Select
|
105 |
with gr.Row():
|
106 |
multimodal_checkbox = gr.CheckboxGroup(
|
107 |
+
choices=[tc.SINGLE_IMG, tc.MULT_IMG, tc.AUDIO, tc.VIDEO],
|
108 |
value=[],
|
109 |
+
label="Additional Modalities π·π§π¬",
|
110 |
)
|
111 |
|
112 |
# Open/Commercial Selection
|
113 |
with gr.Row():
|
114 |
open_weight_checkbox = gr.CheckboxGroup(
|
115 |
+
choices=[tc.OPEN, tc.COMM],
|
116 |
+
value=[tc.OPEN, tc.COMM],
|
117 |
+
label="Model Type π πΌ",
|
118 |
)
|
119 |
|
120 |
# License selection
|
|
|
122 |
license_checkbox = gr.CheckboxGroup(
|
123 |
choices=licenses,
|
124 |
value=licenses,
|
125 |
+
label="License π‘οΈ",
|
126 |
)
|
127 |
|
128 |
#############################################################
|
|
|
135 |
parameter_slider = RangeSlider(
|
136 |
minimum=0,
|
137 |
maximum=max_parameter,
|
138 |
+
label=f"Parameters π {int(min_parameters)}B - {int(max_parameter)}B+",
|
139 |
elem_id="double-slider-1",
|
140 |
step=parameter_step
|
141 |
)
|
|
|
147 |
context_slider = RangeSlider(
|
148 |
minimum=0,
|
149 |
maximum=max_context,
|
150 |
+
label="Context (k) π",
|
151 |
elem_id="double-slider-2",
|
152 |
step=context_step
|
153 |
)
|
|
|
158 |
minimum=0,
|
159 |
maximum=max_input_price,
|
160 |
value=(0, max_input_price),
|
161 |
+
label="π²/1M input tokens",
|
162 |
elem_id="double-slider-3"
|
163 |
)
|
164 |
|
|
|
168 |
minimum=0,
|
169 |
maximum=max_output_price,
|
170 |
value=(0, max_output_price),
|
171 |
+
label="π²/1M output tokens",
|
172 |
elem_id="double-slider-4"
|
173 |
)
|
174 |
|
assets/__pycache__/text_content.cpython-313.pyc
CHANGED
Binary files a/assets/__pycache__/text_content.cpython-313.pyc and b/assets/__pycache__/text_content.cpython-313.pyc differ
|
|
assets/text_content.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import os
|
2 |
|
|
|
3 |
CLEMBENCH_RUNS_REPO = "https://raw.githubusercontent.com/clembench/clembench-runs/main/"
|
4 |
REGISTRY_URL = "https://raw.githubusercontent.com/clp-research/clembench/refs/heads/refactor_model_registry/backends/model_registry.json"
|
5 |
BENCHMARK_FILE = "benchmark_runs.json"
|
@@ -8,46 +9,31 @@ LATENCY_FOLDER = os.path.join("Addenda", "Latency")
|
|
8 |
RESULT_FILE = "results.csv"
|
9 |
LATENCY_SUFFIX = "_latency.csv"
|
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 |
-
'ja': 'Japanese',
|
40 |
-
'no': 'Norwegian',
|
41 |
-
'uk': 'Ukrainian',
|
42 |
-
'fr': 'French',
|
43 |
-
'et': 'Estonian',
|
44 |
-
'ru': 'Russian',
|
45 |
-
'th': 'Thai',
|
46 |
-
'bg': 'Bulgarian',
|
47 |
-
'tr': 'Turkish',
|
48 |
-
'ms': 'Malay',
|
49 |
-
'he': 'Hebrew',
|
50 |
-
'tl': 'Tagalog',
|
51 |
-
'sr': 'Serbian',
|
52 |
-
'en': 'English'
|
53 |
-
}
|
|
|
1 |
import os
|
2 |
|
3 |
+
# Data Sources
|
4 |
CLEMBENCH_RUNS_REPO = "https://raw.githubusercontent.com/clembench/clembench-runs/main/"
|
5 |
REGISTRY_URL = "https://raw.githubusercontent.com/clp-research/clembench/refs/heads/refactor_model_registry/backends/model_registry.json"
|
6 |
BENCHMARK_FILE = "benchmark_runs.json"
|
|
|
9 |
RESULT_FILE = "results.csv"
|
10 |
LATENCY_SUFFIX = "_latency.csv"
|
11 |
|
12 |
+
# Setup Column Names
|
13 |
+
DEFAULT_MODEL_NAME = "Unnamed: 0"
|
14 |
+
DEFAULT_CLEMSCORE = "-, clemscore"
|
15 |
+
|
16 |
+
MODEL_NAME = "Model Name"
|
17 |
+
CLEMSCORE = "Clemscore"
|
18 |
+
LATENCY = "Latency (s)"
|
19 |
+
PARAMS = "Parameters (B)"
|
20 |
+
RELEASE_DATE = 'Release Date'
|
21 |
+
OPEN_WEIGHT = 'Open Weight'
|
22 |
+
LANGS = "Languages"
|
23 |
+
CONTEXT = "Context Size (k)"
|
24 |
+
LICENSE_NAME = "License Name"
|
25 |
+
LICENSE_URL = "License URL"
|
26 |
+
SINGLE_IMG = "Single Image"
|
27 |
+
MULT_IMG = "Multiple Images"
|
28 |
+
AUDIO = "Audio"
|
29 |
+
VIDEO = "Video"
|
30 |
+
INPUT = "Input $/1M tokens"
|
31 |
+
OUTPUT = "Output $/1M tokens"
|
32 |
+
LICENSE = "License"
|
33 |
+
TEMP_DATE = "Temp Date"
|
34 |
+
|
35 |
+
# UI - HF Sapce
|
36 |
+
OPEN = "Open-Weight"
|
37 |
+
COMM = "Commercial"
|
38 |
+
|
39 |
+
TITLE = """<h1 align="center" id="space-title"> LLM Calculator βοΈβ‘ ππ°</h1>"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
-
beautifulsoup4==4.12.3
|
2 |
pandas==2.2.3
|
3 |
gradio_rangeslider==0.0.7
|
4 |
gradio==4.44.1
|
5 |
-
|
|
|
|
|
1 |
pandas==2.2.3
|
2 |
gradio_rangeslider==0.0.7
|
3 |
gradio==4.44.1
|
4 |
+
pycountry==24.6.1
|
src/__pycache__/filter_utils.cpython-313.pyc
CHANGED
Binary files a/src/__pycache__/filter_utils.cpython-313.pyc and b/src/__pycache__/filter_utils.cpython-313.pyc differ
|
|
src/__pycache__/process_data.cpython-313.pyc
ADDED
Binary file (9.95 kB). View file
|
|
src/filter_utils.py
CHANGED
@@ -1,19 +1,20 @@
|
|
1 |
# Utility functions for filtering the dataframe
|
2 |
|
3 |
import pandas as pd
|
|
|
4 |
|
5 |
def filter_cols(df):
|
6 |
|
7 |
df = df[[
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
]]
|
18 |
|
19 |
return df
|
@@ -24,73 +25,65 @@ def filter(df, language_list, parameters, input_price, output_price, multimodal,
|
|
24 |
|
25 |
|
26 |
if not df.empty: # Check if df is non-empty
|
27 |
-
df = df[df[
|
28 |
|
29 |
if not df.empty:
|
30 |
# Split dataframe by Open Weight
|
31 |
-
open_weight_true = df[df[
|
32 |
-
open_weight_false = df[df[
|
33 |
|
34 |
# Get max parameter size for open weight models
|
35 |
-
max_parameter_size = open_weight_true[
|
36 |
|
37 |
# Filter only the open weight models based on parameters
|
38 |
if not open_weight_true.empty:
|
39 |
if parameters[1] >= max_parameter_size:
|
40 |
filtered_open = open_weight_true[
|
41 |
-
(open_weight_true[
|
42 |
]
|
43 |
else:
|
44 |
filtered_open = open_weight_true[
|
45 |
-
(open_weight_true[
|
46 |
-
(open_weight_true[
|
47 |
]
|
48 |
|
49 |
# Combine filtered open weight models with unfiltered commercial models
|
50 |
df = pd.concat([filtered_open, open_weight_false])
|
51 |
|
52 |
if not df.empty: # Check if df is non-empty
|
53 |
-
df = df[(df[
|
54 |
|
55 |
if not df.empty: # Check if df is non-empty
|
56 |
-
df = df[(df[
|
57 |
-
|
58 |
-
|
59 |
-
print("Price")
|
60 |
-
print(df)
|
61 |
|
62 |
if not df.empty: # Check if df is non-empty
|
63 |
-
if
|
64 |
-
df = df[df[
|
65 |
-
if
|
66 |
-
df = df[df[
|
67 |
-
if
|
68 |
-
df = df[df[
|
69 |
-
if
|
70 |
-
df = df[df[
|
71 |
|
72 |
# if not df.empty: # Check if df is non-empty
|
73 |
# df = df[(df['Context Size (k)'] >= (context[0])) & (df['Context Size (k)'] <= (context[1]))]
|
74 |
|
75 |
-
|
76 |
-
print("Modality")
|
77 |
-
print(df)
|
78 |
-
|
79 |
if not df.empty: # Check if df is non-empty
|
80 |
-
if
|
81 |
-
df = df[df[
|
82 |
-
elif
|
83 |
-
df = df[df[
|
84 |
-
elif
|
85 |
# Return empty DataFrame with same columns
|
86 |
df = pd.DataFrame(columns=df.columns)
|
87 |
|
88 |
if not df.empty: # Check if df is non-empty
|
89 |
-
df = df[df[
|
90 |
|
91 |
# Convert 'Release Date' to int temporarily
|
92 |
if not df.empty: # Check if df is non-empty
|
93 |
-
df[
|
94 |
|
95 |
# Convert start and end to int (seconds since epoch)
|
96 |
start = int(pd.to_datetime(start).timestamp())
|
@@ -98,12 +91,10 @@ def filter(df, language_list, parameters, input_price, output_price, multimodal,
|
|
98 |
|
99 |
# Filter based on the converted 'Release Date'
|
100 |
if not df.empty: # Check if df is non-empty
|
101 |
-
df = df[(df[
|
102 |
|
103 |
df = filter_cols(df)
|
104 |
-
df = df.sort_values(by=
|
105 |
-
|
106 |
-
print(df)
|
107 |
|
108 |
return df # Return the filtered dataframe
|
109 |
|
|
|
1 |
# Utility functions for filtering the dataframe
|
2 |
|
3 |
import pandas as pd
|
4 |
+
import assets.text_content as tc
|
5 |
|
6 |
def filter_cols(df):
|
7 |
|
8 |
df = df[[
|
9 |
+
tc.MODEL_NAME,
|
10 |
+
tc.CLEMSCORE,
|
11 |
+
tc.INPUT,
|
12 |
+
tc.OUTPUT,
|
13 |
+
tc.LATENCY,
|
14 |
+
tc.CONTEXT,
|
15 |
+
tc.PARAMS,
|
16 |
+
tc.RELEASE_DATE,
|
17 |
+
tc.LICENSE
|
18 |
]]
|
19 |
|
20 |
return df
|
|
|
25 |
|
26 |
|
27 |
if not df.empty: # Check if df is non-empty
|
28 |
+
df = df[df[tc.LANGS].apply(lambda x: all(lang in x for lang in language_list))]
|
29 |
|
30 |
if not df.empty:
|
31 |
# Split dataframe by Open Weight
|
32 |
+
open_weight_true = df[df[tc.OPEN_WEIGHT] == True]
|
33 |
+
open_weight_false = df[df[tc.OPEN_WEIGHT] == False]
|
34 |
|
35 |
# Get max parameter size for open weight models
|
36 |
+
max_parameter_size = open_weight_true[tc.PARAMS].max() if not open_weight_true.empty else 0
|
37 |
|
38 |
# Filter only the open weight models based on parameters
|
39 |
if not open_weight_true.empty:
|
40 |
if parameters[1] >= max_parameter_size:
|
41 |
filtered_open = open_weight_true[
|
42 |
+
(open_weight_true[tc.PARAMS] >= parameters[0])
|
43 |
]
|
44 |
else:
|
45 |
filtered_open = open_weight_true[
|
46 |
+
(open_weight_true[tc.PARAMS] >= parameters[0]) &
|
47 |
+
(open_weight_true[tc.PARAMS] <= parameters[1])
|
48 |
]
|
49 |
|
50 |
# Combine filtered open weight models with unfiltered commercial models
|
51 |
df = pd.concat([filtered_open, open_weight_false])
|
52 |
|
53 |
if not df.empty: # Check if df is non-empty
|
54 |
+
df = df[(df[tc.INPUT] >= input_price[0]) & (df[tc.INPUT] <= input_price[1])]
|
55 |
|
56 |
if not df.empty: # Check if df is non-empty
|
57 |
+
df = df[(df[tc.OUTPUT] >= output_price[0]) & (df[tc.OUTPUT] <= output_price[1])]
|
|
|
|
|
|
|
|
|
58 |
|
59 |
if not df.empty: # Check if df is non-empty
|
60 |
+
if tc.SINGLE_IMG in multimodal:
|
61 |
+
df = df[df[tc.SINGLE_IMG] == True]
|
62 |
+
if tc.MULT_IMG in multimodal:
|
63 |
+
df = df[df[tc.MULT_IMG] == True]
|
64 |
+
if tc.AUDIO in multimodal:
|
65 |
+
df = df[df[tc.AUDIO] == True]
|
66 |
+
if tc.VIDEO in multimodal:
|
67 |
+
df = df[df[tc.VIDEO] == True]
|
68 |
|
69 |
# if not df.empty: # Check if df is non-empty
|
70 |
# df = df[(df['Context Size (k)'] >= (context[0])) & (df['Context Size (k)'] <= (context[1]))]
|
71 |
|
|
|
|
|
|
|
|
|
72 |
if not df.empty: # Check if df is non-empty
|
73 |
+
if tc.OPEN in open_weight and tc.COMM not in open_weight:
|
74 |
+
df = df[df[tc.OPEN_WEIGHT] == True]
|
75 |
+
elif tc.COMM in open_weight and tc.OPEN not in open_weight:
|
76 |
+
df = df[df[tc.OPEN_WEIGHT] == False]
|
77 |
+
elif tc.OPEN not in open_weight and tc.COMM not in open_weight:
|
78 |
# Return empty DataFrame with same columns
|
79 |
df = pd.DataFrame(columns=df.columns)
|
80 |
|
81 |
if not df.empty: # Check if df is non-empty
|
82 |
+
df = df[df[tc.LICENSE_NAME].apply(lambda x: any(lic in x for lic in license))]
|
83 |
|
84 |
# Convert 'Release Date' to int temporarily
|
85 |
if not df.empty: # Check if df is non-empty
|
86 |
+
df[tc.TEMP_DATE] = pd.to_datetime(df[tc.TEMP_DATE]).astype(int) // 10**9 # Convert to seconds since epoch
|
87 |
|
88 |
# Convert start and end to int (seconds since epoch)
|
89 |
start = int(pd.to_datetime(start).timestamp())
|
|
|
91 |
|
92 |
# Filter based on the converted 'Release Date'
|
93 |
if not df.empty: # Check if df is non-empty
|
94 |
+
df = df[(df[tc.TEMP_DATE] >= start) & (df[tc.TEMP_DATE] <= end)]
|
95 |
|
96 |
df = filter_cols(df)
|
97 |
+
df = df.sort_values(by=tc.CLEMSCORE, ascending=False)
|
|
|
|
|
98 |
|
99 |
return df # Return the filtered dataframe
|
100 |
|
src/process_data.py
CHANGED
@@ -2,9 +2,11 @@ import pandas as pd
|
|
2 |
import json
|
3 |
import os
|
4 |
import pycountry
|
|
|
5 |
|
6 |
from src.collect_data import fetch_version_metadata, fetch_registry_data
|
7 |
-
|
|
|
8 |
PRICING_PATH = os.path.join('assets', 'pricing.json')
|
9 |
|
10 |
# Convert parameters to float, handling both B and T suffixes
|
@@ -64,6 +66,11 @@ def get_multimodality_field(model_data, field):
|
|
64 |
except:
|
65 |
return False
|
66 |
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
def merge_data():
|
69 |
|
@@ -73,10 +80,10 @@ def merge_data():
|
|
73 |
pricing_data = json.load(f)
|
74 |
|
75 |
# Ensure the unnamed column is renamed to 'model'
|
76 |
-
mm_result_df.rename(columns={
|
77 |
-
text_result_df.rename(columns={
|
78 |
-
mm_result_df['model'] = mm_result_df['model'].
|
79 |
-
text_result_df['model'] = text_result_df['model'].
|
80 |
|
81 |
# Merge datasets to compute average values
|
82 |
avg_latency_df = pd.concat([mm_latency_df, text_latency_df], axis=0).groupby('model')['latency'].mean().reset_index()
|
@@ -116,20 +123,20 @@ def merge_data():
|
|
116 |
|
117 |
# Update column renaming
|
118 |
merged_df = merged_df.rename(columns={
|
119 |
-
'model':
|
120 |
-
'latency':
|
121 |
-
'clemscore':
|
122 |
-
'parameters':
|
123 |
-
'release_date':
|
124 |
-
'open_weight':
|
125 |
-
'languages':
|
126 |
-
'context_size':
|
127 |
-
'license_name':
|
128 |
-
'license_url':
|
129 |
-
'single_image':
|
130 |
-
'multiple_images':
|
131 |
-
'audio':
|
132 |
-
'video':
|
133 |
})
|
134 |
|
135 |
# Convert pricing_data list to DataFrame
|
@@ -149,27 +156,27 @@ def merge_data():
|
|
149 |
# Drop duplicate model column and rename price columns
|
150 |
merged_df = merged_df.drop('model_id', axis=1)
|
151 |
merged_df = merged_df.rename(columns={
|
152 |
-
'input':
|
153 |
-
'output':
|
154 |
})
|
155 |
|
156 |
# Fill NaN values with 0.0 for pricing columns
|
157 |
-
merged_df[
|
158 |
-
merged_df[
|
159 |
|
160 |
# Convert parameters and set to None for commercial models
|
161 |
-
merged_df[
|
162 |
-
lambda row: None if not row[
|
163 |
axis=1
|
164 |
)
|
165 |
|
166 |
-
merged_df[
|
167 |
-
merged_df[
|
168 |
|
169 |
-
merged_df[
|
170 |
|
171 |
# Sort by Clemscore in descending order
|
172 |
-
merged_df = merged_df.sort_values(by=
|
173 |
|
174 |
# Drop model_name column
|
175 |
merged_df.drop(columns=['model_name'], inplace=True)
|
|
|
2 |
import json
|
3 |
import os
|
4 |
import pycountry
|
5 |
+
import re
|
6 |
|
7 |
from src.collect_data import fetch_version_metadata, fetch_registry_data
|
8 |
+
import assets.text_content as tc
|
9 |
+
|
10 |
PRICING_PATH = os.path.join('assets', 'pricing.json')
|
11 |
|
12 |
# Convert parameters to float, handling both B and T suffixes
|
|
|
66 |
except:
|
67 |
return False
|
68 |
|
69 |
+
def clean_model_name(model_name: str) -> str:
|
70 |
+
"""Clean model name by removing temperature suffix pattern."""
|
71 |
+
# Match pattern like -t0.0--, -t0.7--, -t1.0--, etc.
|
72 |
+
pattern = r'-t[0-1]\.[0-9]--'
|
73 |
+
return re.split(pattern, model_name)[0]
|
74 |
|
75 |
def merge_data():
|
76 |
|
|
|
80 |
pricing_data = json.load(f)
|
81 |
|
82 |
# Ensure the unnamed column is renamed to 'model'
|
83 |
+
mm_result_df.rename(columns={tc.DEFAULT_MODEL_NAME: 'model', tc.DEFAULT_CLEMSCORE: 'clemscore'}, inplace=True)
|
84 |
+
text_result_df.rename(columns={tc.DEFAULT_MODEL_NAME: 'model', tc.DEFAULT_CLEMSCORE: 'clemscore'}, inplace=True)
|
85 |
+
mm_result_df['model'] = mm_result_df['model'].apply(clean_model_name)
|
86 |
+
text_result_df['model'] = text_result_df['model'].apply(clean_model_name)
|
87 |
|
88 |
# Merge datasets to compute average values
|
89 |
avg_latency_df = pd.concat([mm_latency_df, text_latency_df], axis=0).groupby('model')['latency'].mean().reset_index()
|
|
|
123 |
|
124 |
# Update column renaming
|
125 |
merged_df = merged_df.rename(columns={
|
126 |
+
'model': tc.MODEL_NAME,
|
127 |
+
'latency': tc.LATENCY,
|
128 |
+
'clemscore': tc.CLEMSCORE,
|
129 |
+
'parameters': tc.PARAMS,
|
130 |
+
'release_date': tc.RELEASE_DATE,
|
131 |
+
'open_weight': tc.OPEN_WEIGHT,
|
132 |
+
'languages': tc.LANGS,
|
133 |
+
'context_size': tc.CONTEXT,
|
134 |
+
'license_name': tc.LICENSE_NAME,
|
135 |
+
'license_url': tc.LICENSE_URL,
|
136 |
+
'single_image': tc.SINGLE_IMG,
|
137 |
+
'multiple_images': tc.MULT_IMG,
|
138 |
+
'audio': tc.AUDIO,
|
139 |
+
'video': tc.VIDEO
|
140 |
})
|
141 |
|
142 |
# Convert pricing_data list to DataFrame
|
|
|
156 |
# Drop duplicate model column and rename price columns
|
157 |
merged_df = merged_df.drop('model_id', axis=1)
|
158 |
merged_df = merged_df.rename(columns={
|
159 |
+
'input': tc.INPUT,
|
160 |
+
'output': tc.OUTPUT
|
161 |
})
|
162 |
|
163 |
# Fill NaN values with 0.0 for pricing columns
|
164 |
+
merged_df[tc.INPUT] = merged_df[tc.INPUT].fillna(0.0)
|
165 |
+
merged_df[tc.OUTPUT] = merged_df[tc.OUTPUT].fillna(0.0)
|
166 |
|
167 |
# Convert parameters and set to None for commercial models
|
168 |
+
merged_df[tc.PARAMS] = merged_df.apply(
|
169 |
+
lambda row: None if not row[tc.OPEN_WEIGHT] else convert_parameters(row[tc.PARAMS]),
|
170 |
axis=1
|
171 |
)
|
172 |
|
173 |
+
merged_df[tc.LICENSE] = merged_df.apply(lambda row: f'<a href="{row[tc.LICENSE_URL]}" style="color: blue;">{row[tc.LICENSE_NAME]}</a>', axis=1)
|
174 |
+
merged_df[tc.TEMP_DATE] = merged_df[tc.RELEASE_DATE]
|
175 |
|
176 |
+
merged_df[tc.LANGS] = merged_df[tc.LANGS].apply(map_languages)
|
177 |
|
178 |
# Sort by Clemscore in descending order
|
179 |
+
merged_df = merged_df.sort_values(by=tc.CLEMSCORE, ascending=False)
|
180 |
|
181 |
# Drop model_name column
|
182 |
merged_df.drop(columns=['model_name'], inplace=True)
|