CultriX commited on
Commit
8b0b0da
ยท
verified ยท
1 Parent(s): 0e76f26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -31
app.py CHANGED
@@ -6,6 +6,8 @@ from huggingface_hub.utils import RepositoryNotFoundError, RevisionNotFoundError
6
  from itertools import combinations
7
  import re
8
  from functools import cache
 
 
9
 
10
  # Define function to cache model info from Hugging Face API
11
  @cache
@@ -18,7 +20,7 @@ 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
- df = pd.read_csv(pd.compat.StringIO(cleaned_content), sep="\|", engine='python')
22
  df = df.drop(0).reset_index(drop=True)
23
  df.columns = df.columns.str.strip()
24
  model_link_pattern = r'\[(.*?)\]\((.*?)\)\s*\[.*?\]\(.*?\)'
@@ -39,21 +41,6 @@ def get_and_update_model_info(df):
39
  df.loc[index, 'Tags'] = ''
40
  return df
41
 
42
-
43
-
44
- # Function to get model info from Hugging Face API using caching
45
- @cache
46
- def cached_model_info(api, model):
47
- try:
48
- return api.model_info(repo_id=str(model))
49
- except (RepositoryNotFoundError, RevisionNotFoundError):
50
- return None
51
-
52
- # Define the score columns
53
- score_columns = ['Average', 'AGIEval', 'GPT4All', 'TruthfulQA', 'Bigbench']
54
-
55
-
56
-
57
  # Calculate the highest combined score for a given column
58
  def calculate_highest_combined_score(data, column):
59
  scores = data[column].dropna().tolist()
@@ -79,18 +66,6 @@ def display_highest_combined_scores(data, score_columns):
79
  st.write(f"Score: {score}, Models: {', '.join(combination)}")
80
 
81
 
82
- # Function to calculate the highest combined score for a given column
83
- def calculate_highest_combined_score(data, column):
84
- scores = data[column].tolist()
85
- models = data['Model'].tolist()
86
- top_combinations = {2: [], 3: [], 4: [], 5: [], 6: []}
87
- for r in range(2, 7):
88
- for combination in combinations(zip(scores, models), r):
89
- combined_score = sum(score for score, _ in combination)
90
- top_combinations[r].append((combined_score, tuple(model for _, model in combination)))
91
- top_combinations[r] = sorted(top_combinations[r], key=lambda x: x[0], reverse=True)[:3]
92
- return column, top_combinations
93
-
94
  # Function to create bar chart for a given category
95
  def create_bar_chart(df, category):
96
  """Create and display a bar chart for a given category."""
@@ -121,9 +96,8 @@ def main():
121
  st.markdown("Displaying top combinations of models based on scores.")
122
 
123
  # Placeholder for content fetching or upload
124
- # For demonstration, let's assume 'content' is a markdown string from somewhere
125
- content = """Your markdown table content here"""
126
-
127
  if content:
128
  df = convert_markdown_table_to_dataframe(content)
129
  df = get_and_update_model_info(df)
@@ -136,6 +110,7 @@ def main():
136
  df[col] = pd.to_numeric(df[col], errors='coerce')
137
 
138
  display_highest_combined_scores(df, score_columns)
 
139
  # Create tabs for leaderboard and about section
140
  content = create_yall()
141
  tab1, tab2 = st.tabs(["๐Ÿ† Leaderboard", "๐Ÿ“ About"])
 
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
 
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
+ df = pd.read_csv(StringIO(cleaned_content), sep="\|", engine='python') # Corrected use of StringIO
24
  df = df.drop(0).reset_index(drop=True)
25
  df.columns = df.columns.str.strip()
26
  model_link_pattern = r'\[(.*?)\]\((.*?)\)\s*\[.*?\]\(.*?\)'
 
41
  df.loc[index, 'Tags'] = ''
42
  return df
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  # Calculate the highest combined score for a given column
45
  def calculate_highest_combined_score(data, column):
46
  scores = data[column].dropna().tolist()
 
66
  st.write(f"Score: {score}, Models: {', '.join(combination)}")
67
 
68
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  # Function to create bar chart for a given category
70
  def create_bar_chart(df, category):
71
  """Create and display a bar chart for a given category."""
 
96
  st.markdown("Displaying top combinations of models based on scores.")
97
 
98
  # Placeholder for content fetching or upload
99
+ content = """Your markdown table content here""" # Placeholder content
100
+
 
101
  if content:
102
  df = convert_markdown_table_to_dataframe(content)
103
  df = get_and_update_model_info(df)
 
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"])