Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ from huggingface_hub.utils import RepositoryNotFoundError, RevisionNotFoundError
|
|
10 |
from yall import create_yall
|
11 |
|
12 |
|
|
|
13 |
def convert_markdown_table_to_dataframe(md_content):
|
14 |
"""
|
15 |
Converts markdown table to Pandas DataFrame, handling special characters and links,
|
@@ -36,10 +37,10 @@ def convert_markdown_table_to_dataframe(md_content):
|
|
36 |
|
37 |
return df
|
38 |
|
39 |
-
@st.cache_data
|
40 |
def get_model_info(df):
|
41 |
api = HfApi()
|
42 |
-
|
43 |
# Initialize new columns for likes and tags
|
44 |
df['Likes'] = None
|
45 |
df['Tags'] = None
|
@@ -58,7 +59,8 @@ def get_model_info(df):
|
|
58 |
|
59 |
return df
|
60 |
|
61 |
-
|
|
|
62 |
def create_bar_chart(df, category):
|
63 |
"""Create and display a bar chart for a given category."""
|
64 |
st.write(f"### {category} Scores")
|
@@ -66,12 +68,12 @@ def create_bar_chart(df, category):
|
|
66 |
# Sort the DataFrame based on the category score
|
67 |
sorted_df = df[['Model', category]].sort_values(by=category, ascending=True)
|
68 |
|
69 |
-
# Create the bar chart with color gradient
|
70 |
fig = go.Figure(go.Bar(
|
71 |
x=sorted_df[category],
|
72 |
y=sorted_df['Model'],
|
73 |
orientation='h',
|
74 |
-
marker=dict(color=sorted_df[category], colorscale='Spectral')
|
75 |
))
|
76 |
|
77 |
# Update layout for better readability
|
@@ -79,9 +81,13 @@ def create_bar_chart(df, category):
|
|
79 |
margin=dict(l=20, r=20, t=20, b=20)
|
80 |
)
|
81 |
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
-
|
85 |
def main():
|
86 |
st.set_page_config(page_title="YALL - Yet Another LLM Leaderboard", layout="wide")
|
87 |
|
@@ -96,7 +102,7 @@ def main():
|
|
96 |
if content:
|
97 |
try:
|
98 |
score_columns = ['Average', 'AGIEval', 'GPT4All', 'TruthfulQA', 'Bigbench']
|
99 |
-
|
100 |
# Display dataframe
|
101 |
full_df = convert_markdown_table_to_dataframe(content)
|
102 |
for col in score_columns:
|
@@ -105,18 +111,15 @@ def main():
|
|
105 |
full_df = get_model_info(full_df)
|
106 |
full_df['Tags'] = full_df['Tags'].fillna('')
|
107 |
df = pd.DataFrame(columns=full_df.columns)
|
108 |
-
|
109 |
-
# Toggles
|
110 |
-
col1, col2, col3 = st.columns(3)
|
111 |
-
with col1:
|
112 |
-
show_phi = st.checkbox("Phi (2.8B)", value=True)
|
113 |
-
with col2:
|
114 |
-
show_mistral = st.checkbox("Mistral (7B)", value=True)
|
115 |
-
with col3:
|
116 |
-
show_other = st.checkbox("Other", value=True)
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
dfs_to_concat = []
|
119 |
-
|
120 |
if show_phi:
|
121 |
dfs_to_concat.append(full_df[full_df['Tags'].str.lower().str.contains('phi,|phi-msft,')])
|
122 |
if show_mistral:
|
@@ -124,15 +127,19 @@ def main():
|
|
124 |
if show_other:
|
125 |
other_df = full_df[~full_df['Tags'].str.lower().str.contains('phi,|phi-msft,|mistral,')]
|
126 |
dfs_to_concat.append(other_df)
|
127 |
-
|
128 |
# Concatenate the DataFrames
|
129 |
if dfs_to_concat:
|
130 |
df = pd.concat(dfs_to_concat, ignore_index=True)
|
131 |
-
|
132 |
-
#
|
133 |
-
|
134 |
-
|
135 |
-
#
|
|
|
|
|
|
|
|
|
136 |
st.dataframe(
|
137 |
df[['Model'] + score_columns + ['Likes', 'URL']],
|
138 |
use_container_width=True,
|
@@ -145,26 +152,41 @@ def main():
|
|
145 |
"URL": st.column_config.LinkColumn("URL"),
|
146 |
},
|
147 |
hide_index=True,
|
148 |
-
height=len(df)*37,
|
149 |
)
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
# Full-width plot for the first category
|
152 |
create_bar_chart(df, score_columns[0])
|
153 |
-
|
154 |
# Next two plots in two columns
|
155 |
col1, col2 = st.columns(2)
|
156 |
with col1:
|
157 |
create_bar_chart(df, score_columns[1])
|
158 |
with col2:
|
159 |
create_bar_chart(df, score_columns[2])
|
160 |
-
|
161 |
# Last two plots in two columns
|
162 |
col3, col4 = st.columns(2)
|
163 |
with col3:
|
164 |
create_bar_chart(df, score_columns[3])
|
165 |
with col4:
|
166 |
create_bar_chart(df, score_columns[4])
|
167 |
-
|
|
|
168 |
except Exception as e:
|
169 |
st.error("An error occurred while processing the markdown table.")
|
170 |
st.error(str(e))
|
@@ -177,7 +199,7 @@ def main():
|
|
177 |
### Nous benchmark suite
|
178 |
|
179 |
Popularized by [Teknium](https://huggingface.co/teknium) and [NousResearch](https://huggingface.co/NousResearch), this benchmark suite aggregates four benchmarks:
|
180 |
-
|
181 |
* [**AGIEval**](https://arxiv.org/abs/2304.06364) (0-shot): `agieval_aqua_rat,agieval_logiqa_en,agieval_lsat_ar,agieval_lsat_lr,agieval_lsat_rc,agieval_sat_en,agieval_sat_en_without_passage,agieval_sat_math`
|
182 |
* **GPT4ALL** (0-shot): `hellaswag,openbookqa,winogrande,arc_easy,arc_challenge,boolq,piqa`
|
183 |
* [**TruthfulQA**](https://arxiv.org/abs/2109.07958) (0-shot): `truthfulqa_mc`
|
|
|
10 |
from yall import create_yall
|
11 |
|
12 |
|
13 |
+
|
14 |
def convert_markdown_table_to_dataframe(md_content):
|
15 |
"""
|
16 |
Converts markdown table to Pandas DataFrame, handling special characters and links,
|
|
|
37 |
|
38 |
return df
|
39 |
|
40 |
+
@st.cache_data
|
41 |
def get_model_info(df):
|
42 |
api = HfApi()
|
43 |
+
|
44 |
# Initialize new columns for likes and tags
|
45 |
df['Likes'] = None
|
46 |
df['Tags'] = None
|
|
|
59 |
|
60 |
return df
|
61 |
|
62 |
+
|
63 |
+
|
64 |
def create_bar_chart(df, category):
|
65 |
"""Create and display a bar chart for a given category."""
|
66 |
st.write(f"### {category} Scores")
|
|
|
68 |
# Sort the DataFrame based on the category score
|
69 |
sorted_df = df[['Model', category]].sort_values(by=category, ascending=True)
|
70 |
|
71 |
+
# Create the bar chart with a color gradient (using 'Viridis' color scale as an example)
|
72 |
fig = go.Figure(go.Bar(
|
73 |
x=sorted_df[category],
|
74 |
y=sorted_df['Model'],
|
75 |
orientation='h',
|
76 |
+
marker=dict(color=sorted_df[category], colorscale='Spectral') # You can change 'Viridis' to another color scale
|
77 |
))
|
78 |
|
79 |
# Update layout for better readability
|
|
|
81 |
margin=dict(l=20, r=20, t=20, b=20)
|
82 |
)
|
83 |
|
84 |
+
# Adjust the height of the chart based on the number of rows in the DataFrame
|
85 |
+
st.plotly_chart(fig, use_container_width=True, height=len(df) * 35)
|
86 |
+
|
87 |
+
# Example usage:
|
88 |
+
# create_bar_chart(your_dataframe, 'Your_Category')
|
89 |
+
|
90 |
|
|
|
91 |
def main():
|
92 |
st.set_page_config(page_title="YALL - Yet Another LLM Leaderboard", layout="wide")
|
93 |
|
|
|
102 |
if content:
|
103 |
try:
|
104 |
score_columns = ['Average', 'AGIEval', 'GPT4All', 'TruthfulQA', 'Bigbench']
|
105 |
+
|
106 |
# Display dataframe
|
107 |
full_df = convert_markdown_table_to_dataframe(content)
|
108 |
for col in score_columns:
|
|
|
111 |
full_df = get_model_info(full_df)
|
112 |
full_df['Tags'] = full_df['Tags'].fillna('')
|
113 |
df = pd.DataFrame(columns=full_df.columns)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
+
# Toggles for filtering by tags
|
116 |
+
show_phi = st.checkbox("Phi (2.8B)", value=True)
|
117 |
+
show_mistral = st.checkbox("Mistral (7B)", value=True)
|
118 |
+
show_other = st.checkbox("Other", value=True)
|
119 |
+
|
120 |
+
# Create a DataFrame based on selected filters
|
121 |
dfs_to_concat = []
|
122 |
+
|
123 |
if show_phi:
|
124 |
dfs_to_concat.append(full_df[full_df['Tags'].str.lower().str.contains('phi,|phi-msft,')])
|
125 |
if show_mistral:
|
|
|
127 |
if show_other:
|
128 |
other_df = full_df[~full_df['Tags'].str.lower().str.contains('phi,|phi-msft,|mistral,')]
|
129 |
dfs_to_concat.append(other_df)
|
130 |
+
|
131 |
# Concatenate the DataFrames
|
132 |
if dfs_to_concat:
|
133 |
df = pd.concat(dfs_to_concat, ignore_index=True)
|
134 |
+
|
135 |
+
# Add a search bar
|
136 |
+
search_query = st.text_input("Search models", "")
|
137 |
+
|
138 |
+
# Filter the DataFrame based on the search query
|
139 |
+
if search_query:
|
140 |
+
df = df[df['Model'].str.contains(search_query, case=False)]
|
141 |
+
|
142 |
+
# Display the filtered DataFrame or the entire leaderboard
|
143 |
st.dataframe(
|
144 |
df[['Model'] + score_columns + ['Likes', 'URL']],
|
145 |
use_container_width=True,
|
|
|
152 |
"URL": st.column_config.LinkColumn("URL"),
|
153 |
},
|
154 |
hide_index=True,
|
155 |
+
height=len(df) * 37,
|
156 |
)
|
157 |
|
158 |
+
# Add a button to export data to CSV
|
159 |
+
if st.button("Export to CSV"):
|
160 |
+
# Export the DataFrame to CSV
|
161 |
+
csv_data = df.to_csv(index=False)
|
162 |
+
|
163 |
+
# Create a link to download the CSV file
|
164 |
+
st.download_button(
|
165 |
+
label="Download CSV",
|
166 |
+
data=csv_data,
|
167 |
+
file_name="leaderboard.csv",
|
168 |
+
key="download-csv",
|
169 |
+
help="Click to download the CSV file",
|
170 |
+
)
|
171 |
+
|
172 |
# Full-width plot for the first category
|
173 |
create_bar_chart(df, score_columns[0])
|
174 |
+
|
175 |
# Next two plots in two columns
|
176 |
col1, col2 = st.columns(2)
|
177 |
with col1:
|
178 |
create_bar_chart(df, score_columns[1])
|
179 |
with col2:
|
180 |
create_bar_chart(df, score_columns[2])
|
181 |
+
|
182 |
# Last two plots in two columns
|
183 |
col3, col4 = st.columns(2)
|
184 |
with col3:
|
185 |
create_bar_chart(df, score_columns[3])
|
186 |
with col4:
|
187 |
create_bar_chart(df, score_columns[4])
|
188 |
+
|
189 |
+
|
190 |
except Exception as e:
|
191 |
st.error("An error occurred while processing the markdown table.")
|
192 |
st.error(str(e))
|
|
|
199 |
### Nous benchmark suite
|
200 |
|
201 |
Popularized by [Teknium](https://huggingface.co/teknium) and [NousResearch](https://huggingface.co/NousResearch), this benchmark suite aggregates four benchmarks:
|
202 |
+
|
203 |
* [**AGIEval**](https://arxiv.org/abs/2304.06364) (0-shot): `agieval_aqua_rat,agieval_logiqa_en,agieval_lsat_ar,agieval_lsat_lr,agieval_lsat_rc,agieval_sat_en,agieval_sat_en_without_passage,agieval_sat_math`
|
204 |
* **GPT4ALL** (0-shot): `hellaswag,openbookqa,winogrande,arc_easy,arc_challenge,boolq,piqa`
|
205 |
* [**TruthfulQA**](https://arxiv.org/abs/2109.07958) (0-shot): `truthfulqa_mc`
|