CultriX commited on
Commit
a989e5c
·
verified ·
1 Parent(s): f733a1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -1
app.py CHANGED
@@ -8,6 +8,9 @@ from functools import cache
8
  from io import StringIO
9
  from yall import create_yall
10
  import plotly.graph_objs as go
 
 
 
11
 
12
  def calculate_pages(df, items_per_page):
13
  return -(-len(df) // items_per_page) # Equivalent to math.ceil(len(df) / items_per_page)
@@ -145,6 +148,35 @@ def create_bar_chart(df, category):
145
  # Adjust the height of the chart based on the number of rows in the DataFrame
146
  st.plotly_chart(fig, use_container_width=True, height=len(df) * 35)
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  # Main function to run the Streamlit app
149
  def main():
150
  # Set page configuration and title
@@ -235,7 +267,7 @@ def main():
235
  # Add a button to export data to CSV
236
  if st.button("Export to CSV"):
237
  # Export the DataFrame to CSV
238
- csv_data = full_df.to_csv(index=False)
239
 
240
  # Create a link to download the CSV file
241
  st.download_button(
@@ -245,7 +277,23 @@ def main():
245
  key="download-csv",
246
  help="Click to download the CSV file",
247
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
 
249
  # Full-width plot for the first category
250
  create_bar_chart(df, score_columns[0])
251
 
 
8
  from io import StringIO
9
  from yall import create_yall
10
  import plotly.graph_objs as go
11
+ from huggingface_hub import ModelCard
12
+
13
+
14
 
15
  def calculate_pages(df, items_per_page):
16
  return -(-len(df) // items_per_page) # Equivalent to math.ceil(len(df) / items_per_page)
 
148
  # Adjust the height of the chart based on the number of rows in the DataFrame
149
  st.plotly_chart(fig, use_container_width=True, height=len(df) * 35)
150
 
151
+ def fetch_merge_configs(df):
152
+ # Sort the DataFrame
153
+ df_sorted = df.sort_values(by='Average', ascending=False).head(20)
154
+ configurations = []
155
+ matches = []
156
+
157
+ # Get model cards for the top 20 entries
158
+ for index, row in df_sorted.iterrows():
159
+ model_name = row['Model'].rstrip()
160
+ try:
161
+ card = ModelCard.load(model_name)
162
+ configurations.append({
163
+ "Model Name": model_name,
164
+ "Scores": row["Average"],
165
+ "AGIEval": row["AGIEval"],
166
+ "GPT4All": row["GPT4All"],
167
+ "TruthfulQA": row["TruthfulQA"],
168
+ "Bigbench": row["Bigbench"],
169
+ "Model Card": str(card)
170
+ })
171
+ match = re.findall(r'yaml(.*?)```', str(card), re.DOTALL)
172
+ if match:
173
+ matches.append(match[0])
174
+ except Exception as e:
175
+ print(f"Failed to load model card for {model_name}. Error: {e}")
176
+
177
+ # Assuming you will display the configurations in some way in your app
178
+ return configurations, matchescsv_data = df.to_csv(index=False)
179
+
180
  # Main function to run the Streamlit app
181
  def main():
182
  # Set page configuration and title
 
267
  # Add a button to export data to CSV
268
  if st.button("Export to CSV"):
269
  # Export the DataFrame to CSV
270
+ csv_data = df.to_csv(index=False)
271
 
272
  # Create a link to download the CSV file
273
  st.download_button(
 
277
  key="download-csv",
278
  help="Click to download the CSV file",
279
  )
280
+ if st.button("Fetch Merge-Configs"):
281
+ # Call the function with the current DataFrame
282
+ configurations, matches = fetch_merge_configs(full_df) # Assuming full_df is your DataFrame
283
+
284
+ # You can then display the configurations or matches as needed, or write them to a file
285
+ # For example, displaying the configurations:
286
+ for config in configurations:
287
+ st.text(f"Model Name: {config['Model Name']}\nScores: {config['Scores']}\nAGIEval: {config['AGIEval']}\nGPT4All: {config['GPT4All']}\nTruthfulQA: {config['TruthfulQA']}\nBigbench: {config['Bigbench']}\nModel Card: {config['Model Card']}\n\n")
288
+ st.download_button(
289
+ label="Download Configurations",
290
+ data=configurations,
291
+ file_name="configurations.csv",
292
+ key="download-csv",
293
+ help="Click to download the CSV file",
294
+ )
295
 
296
+
297
  # Full-width plot for the first category
298
  create_bar_chart(df, score_columns[0])
299