Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -232,74 +232,19 @@ def main():
|
|
232 |
selected_models = st.multiselect('Select models to compare', df['Model'].unique())
|
233 |
comparison_df = df[df['Model'].isin(selected_models)]
|
234 |
st.dataframe(comparison_df)
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
data=csv_data,
|
249 |
-
file_name="leaderboard.csv",
|
250 |
-
key="download-csv",
|
251 |
-
help="Click to download the CSV file",
|
252 |
-
)
|
253 |
-
|
254 |
-
# Add the new button in the second column
|
255 |
-
with button_row[1]:
|
256 |
-
if st.button("Fetch Top Mergeki-Configs"):
|
257 |
-
# Export the DataFrame to CSV and save it to /tmp/models.csv
|
258 |
-
df.to_csv('/tmp/models.csv', index=False)# Add a button to export data to CSV
|
259 |
-
# Load the CSV data
|
260 |
-
df = pd.read_csv('/tmp/models.csv')
|
261 |
-
|
262 |
-
# Sort the data by the second column (assuming the column name is 'Average')
|
263 |
-
df_sorted = df.sort_values(by='Average', ascending=False)
|
264 |
-
|
265 |
-
# Open the file in append mode
|
266 |
-
with open('configurations.txt', 'a') as file:
|
267 |
-
# Get model cards for the top 20 entries
|
268 |
-
for index, row in df_sorted.head(20).iterrows():
|
269 |
-
model_name = row['Model'].rstrip()
|
270 |
-
card = ModelCard.load(model_name)
|
271 |
-
file.write(f'Model Name: {model_name}\n')
|
272 |
-
file.write(f'Scores: {row["Average"]}\n') # Assuming 'Average' is the benchmark score
|
273 |
-
file.write(f'AGIEval: {row["AGIEval"]}\n')
|
274 |
-
file.write(f'GPT4All: {row["GPT4All"]}\n')
|
275 |
-
file.write(f'TruthfulQA: {row["TruthfulQA"]}\n')
|
276 |
-
file.write(f'Bigbench: {row["Bigbench"]}\n')
|
277 |
-
file.write(f'Model Card: {card}\n')
|
278 |
-
|
279 |
-
# Open the second file in read mode
|
280 |
-
with open('configurations.txt', 'r') as file:
|
281 |
-
# Read the content
|
282 |
-
content = file.read()
|
283 |
-
|
284 |
-
# Find all text between 'yaml' and '```'
|
285 |
-
matches = re.findall(r'yaml(.*?)```', content, re.DOTALL)
|
286 |
-
|
287 |
-
# Open the file 'configurations2.txt' in write mode
|
288 |
-
with open('configurations2.txt', 'w') as file:
|
289 |
-
# Write the matches to the file
|
290 |
-
for row, match in zip(df_sorted[['Model', 'Average', 'AGIEval', 'GPT4All', 'TruthfulQA', 'Bigbench']].head(20).values, matches):
|
291 |
-
file.write(f'Model Name: {row[0]}\n')
|
292 |
-
file.write(f'Scores: {row[1]}\n')
|
293 |
-
file.write(f'AGIEval: {row[2]}\n')
|
294 |
-
file.write(f'GPT4All: {row[3]}\n')
|
295 |
-
file.write(f'TruthfulQA: {row[4]}\n')
|
296 |
-
file.write(f'Bigbench: {row[5]}\n')
|
297 |
-
file.write('yaml' + match + '```\n')
|
298 |
-
# Provide a link to download the generated file
|
299 |
-
st.markdown('[Download configurations](file:configurations2.txt)')
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
|
304 |
# Full-width plot for the first category
|
305 |
create_bar_chart(df, score_columns[0])
|
@@ -348,4 +293,3 @@ def main():
|
|
348 |
# Run the main function if this script is run directly
|
349 |
if __name__ == "__main__":
|
350 |
main()
|
351 |
-
|
|
|
232 |
selected_models = st.multiselect('Select models to compare', df['Model'].unique())
|
233 |
comparison_df = df[df['Model'].isin(selected_models)]
|
234 |
st.dataframe(comparison_df)
|
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 = df.to_csv(index=False)
|
239 |
+
|
240 |
+
# Create a link to download the CSV file
|
241 |
+
st.download_button(
|
242 |
+
label="Download CSV",
|
243 |
+
data=csv_data,
|
244 |
+
file_name="leaderboard.csv",
|
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])
|
|
|
293 |
# Run the main function if this script is run directly
|
294 |
if __name__ == "__main__":
|
295 |
main()
|
|