Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,8 @@ import requests
|
|
4 |
import pandas as pd
|
5 |
from io import StringIO
|
6 |
import plotly.graph_objs as go
|
|
|
|
|
7 |
|
8 |
from yall import create_yall
|
9 |
|
@@ -34,7 +36,29 @@ def convert_markdown_table_to_dataframe(md_content):
|
|
34 |
|
35 |
return df
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
|
|
38 |
def create_bar_chart(df, category):
|
39 |
"""Create and display a bar chart for a given category."""
|
40 |
st.write(f"### {category} Scores")
|
@@ -74,25 +98,35 @@ def main():
|
|
74 |
score_columns = ['Average', 'AGIEval', 'GPT4All', 'TruthfulQA', 'Bigbench']
|
75 |
|
76 |
# Display dataframe
|
77 |
-
|
|
|
78 |
for col in score_columns:
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
83 |
with col1:
|
84 |
-
show_phi = st.
|
85 |
with col2:
|
86 |
-
show_mistral = st.
|
|
|
|
|
87 |
|
88 |
# Apply filters based on toggles
|
89 |
-
if
|
90 |
-
df = df[
|
91 |
-
if
|
92 |
-
df = df[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
-
st.dataframe(df, use_container_width=True)
|
95 |
-
|
96 |
# Full-width plot for the first category
|
97 |
create_bar_chart(df, score_columns[0])
|
98 |
|
|
|
4 |
import pandas as pd
|
5 |
from io import StringIO
|
6 |
import plotly.graph_objs as go
|
7 |
+
from huggingface_hub import HfApi
|
8 |
+
from huggingface_hub.utils import RepositoryNotFoundError, RevisionNotFoundError
|
9 |
|
10 |
from yall import create_yall
|
11 |
|
|
|
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
|
46 |
+
|
47 |
+
# Iterate through DataFrame rows
|
48 |
+
for index, row in df.iterrows():
|
49 |
+
model = row['Model'].strip()
|
50 |
+
try:
|
51 |
+
model_info = api.model_info(repo_id=str(model))
|
52 |
+
df.loc[index, 'Likes'] = model_info.likes
|
53 |
+
df.loc[index, 'Tags'] = ', '.join(model_info.tags)
|
54 |
+
|
55 |
+
except (RepositoryNotFoundError, RevisionNotFoundError):
|
56 |
+
df.loc[index, 'Likes'] = -1
|
57 |
+
df.loc[index, 'Tags'] = ''
|
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")
|
|
|
98 |
score_columns = ['Average', 'AGIEval', 'GPT4All', 'TruthfulQA', 'Bigbench']
|
99 |
|
100 |
# Display dataframe
|
101 |
+
full_df = convert_markdown_table_to_dataframe(content)
|
102 |
+
full_df = get_model_info(full_df)
|
103 |
for col in score_columns:
|
104 |
+
full_df[col] = full_df.to_numeric(full_df[col].str.strip(), errors='coerce')
|
105 |
+
df = pd.DataFrame(columns=full_df.columns)
|
106 |
+
|
107 |
+
# Toggles
|
108 |
+
col1, col2, col3 = st.columns(3)
|
109 |
with col1:
|
110 |
+
show_phi = st.toggle("Phi (2.8B)")
|
111 |
with col2:
|
112 |
+
show_mistral = st.toggle("Mistral (7B)")
|
113 |
+
with col3:
|
114 |
+
show_mistral = st.toggle("Mixtral (46.7B)")
|
115 |
|
116 |
# Apply filters based on toggles
|
117 |
+
if show_phi:
|
118 |
+
df = df.append(full_df[full_df['tags'].str.lower().str.contains('phi-msft')], ignore_index=True)
|
119 |
+
if show_mistral:
|
120 |
+
df = df.append(full_df[full_df['tags'].str.lower().str.contains('mistral')], ignore_index=True)
|
121 |
+
if show_mixtral:
|
122 |
+
df = df.append(full_df[full_df['tags'].str.lower().str.contains('mixtral')], ignore_index=True)
|
123 |
+
|
124 |
+
# Sort values
|
125 |
+
df = df.sort_values(by='Average', ascending=False)
|
126 |
+
|
127 |
+
# Display the DataFrame
|
128 |
+
st.dataframe(df[['Model'] + score_columns + ['Likes']], use_container_width=True)
|
129 |
|
|
|
|
|
130 |
# Full-width plot for the first category
|
131 |
create_bar_chart(df, score_columns[0])
|
132 |
|