Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,6 @@ from itertools import combinations
|
|
| 7 |
import re
|
| 8 |
from functools import cache
|
| 9 |
from io import StringIO # Corrected import for StringIO
|
| 10 |
-
|
| 11 |
-
|
| 12 |
# Define function to cache model info from Hugging Face API
|
| 13 |
@cache
|
| 14 |
def cached_model_info(api, model):
|
|
@@ -20,12 +18,13 @@ def cached_model_info(api, model):
|
|
| 20 |
# Convert markdown table to DataFrame and extract Hugging Face URLs
|
| 21 |
def convert_markdown_table_to_dataframe(md_content):
|
| 22 |
cleaned_content = re.sub(r'\|\s*$', '', re.sub(r'^\|\s*', '', md_content, flags=re.MULTILINE), flags=re.MULTILINE)
|
| 23 |
-
|
| 24 |
-
df =
|
|
|
|
| 25 |
df.columns = df.columns.str.strip()
|
| 26 |
model_link_pattern = r'\[(.*?)\]\((.*?)\)\s*\[.*?\]\(.*?\)'
|
| 27 |
-
df['URL'] = df
|
| 28 |
-
df['Model'] = df
|
| 29 |
return df
|
| 30 |
|
| 31 |
# Function to get and update model info in the DataFrame
|
|
@@ -95,8 +94,8 @@ def main():
|
|
| 95 |
st.title("Model Leaderboard")
|
| 96 |
st.markdown("Displaying top combinations of models based on scores.")
|
| 97 |
|
| 98 |
-
# Placeholder
|
| 99 |
-
content = """Your markdown table content here"""
|
| 100 |
|
| 101 |
if content:
|
| 102 |
df = convert_markdown_table_to_dataframe(content)
|
|
@@ -105,12 +104,12 @@ def main():
|
|
| 105 |
# Assuming your DataFrame has these score columns already or you've added them
|
| 106 |
score_columns = ['Average', 'AGIEval', 'GPT4All', 'TruthfulQA', 'Bigbench']
|
| 107 |
|
| 108 |
-
#
|
| 109 |
for col in score_columns:
|
| 110 |
df[col] = pd.to_numeric(df[col], errors='coerce')
|
| 111 |
|
| 112 |
display_highest_combined_scores(df, score_columns)
|
| 113 |
-
|
| 114 |
# Create tabs for leaderboard and about section
|
| 115 |
content = create_yall()
|
| 116 |
tab1, tab2 = st.tabs(["🏆 Leaderboard", "📝 About"])
|
|
|
|
| 7 |
import re
|
| 8 |
from functools import cache
|
| 9 |
from io import StringIO # Corrected import for StringIO
|
|
|
|
|
|
|
| 10 |
# Define function to cache model info from Hugging Face API
|
| 11 |
@cache
|
| 12 |
def cached_model_info(api, model):
|
|
|
|
| 18 |
# Convert markdown table to DataFrame and extract Hugging Face URLs
|
| 19 |
def convert_markdown_table_to_dataframe(md_content):
|
| 20 |
cleaned_content = re.sub(r'\|\s*$', '', re.sub(r'^\|\s*', '', md_content, flags=re.MULTILINE), flags=re.MULTILINE)
|
| 21 |
+
# Use StringIO for reading the cleaned_content
|
| 22 |
+
df = pd.read_csv(StringIO(cleaned_content), sep="\|", engine='python', skipinitialspace=True)
|
| 23 |
+
# Skip rows if needed or directly process without dropping
|
| 24 |
df.columns = df.columns.str.strip()
|
| 25 |
model_link_pattern = r'\[(.*?)\]\((.*?)\)\s*\[.*?\]\(.*?\)'
|
| 26 |
+
df['URL'] = df.apply(lambda x: re.search(model_link_pattern, x['Model']).group(2) if re.search(model_link_pattern, x['Model']) else None, axis=1)
|
| 27 |
+
df['Model'] = df.apply(lambda x: re.sub(model_link_pattern, r'\1', x['Model']), axis=1)
|
| 28 |
return df
|
| 29 |
|
| 30 |
# Function to get and update model info in the DataFrame
|
|
|
|
| 94 |
st.title("Model Leaderboard")
|
| 95 |
st.markdown("Displaying top combinations of models based on scores.")
|
| 96 |
|
| 97 |
+
# Placeholder content - ensure you replace this with your actual markdown or method to fetch/create content
|
| 98 |
+
content = """Your markdown table content here"""
|
| 99 |
|
| 100 |
if content:
|
| 101 |
df = convert_markdown_table_to_dataframe(content)
|
|
|
|
| 104 |
# Assuming your DataFrame has these score columns already or you've added them
|
| 105 |
score_columns = ['Average', 'AGIEval', 'GPT4All', 'TruthfulQA', 'Bigbench']
|
| 106 |
|
| 107 |
+
# Ensure the score columns are numeric and handle NaNs or conversion issues
|
| 108 |
for col in score_columns:
|
| 109 |
df[col] = pd.to_numeric(df[col], errors='coerce')
|
| 110 |
|
| 111 |
display_highest_combined_scores(df, score_columns)
|
| 112 |
+
|
| 113 |
# Create tabs for leaderboard and about section
|
| 114 |
content = create_yall()
|
| 115 |
tab1, tab2 = st.tabs(["🏆 Leaderboard", "📝 About"])
|