CultriX commited on
Commit
76d602e
1 Parent(s): 1a726f2

Create get-hf-merge-configs.py

Browse files
Files changed (1) hide show
  1. get-hf-merge-configs.py +43 -0
get-hf-merge-configs.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ from huggingface_hub import ModelCard
3
+ import pandas as pd
4
+
5
+ # Load the CSV data
6
+ df = pd.read_csv('/tmp/models.csv')
7
+
8
+ # Sort the data by the second column (assuming the column name is 'Average')
9
+ df_sorted = df.sort_values(by='Average', ascending=False)
10
+
11
+ # Open the file in append mode
12
+ with open('configurations.txt', 'a') as file:
13
+ # Get model cards for the top 20 entries
14
+ for index, row in df_sorted.head(20).iterrows():
15
+ model_name = row['Model'].rstrip()
16
+ card = ModelCard.load(model_name)
17
+ file.write(f'Model Name: {model_name}\n')
18
+ file.write(f'Scores: {row["Average"]}\n') # Assuming 'Average' is the benchmark score
19
+ file.write(f'AGIEval: {row["AGIEval"]}\n')
20
+ file.write(f'GPT4All: {row["GPT4All"]}\n')
21
+ file.write(f'TruthfulQA: {row["TruthfulQA"]}\n')
22
+ file.write(f'Bigbench: {row["Bigbench"]}\n')
23
+ file.write(f'Model Card: {card}\n')
24
+
25
+ # Open the second file in read mode
26
+ with open('configurations.txt', 'r') as file:
27
+ # Read the content
28
+ content = file.read()
29
+
30
+ # Find all text between 'yaml' and '```'
31
+ matches = re.findall(r'yaml(.*?)```', content, re.DOTALL)
32
+
33
+ # Open the file 'configurations2.txt' in write mode
34
+ with open('configurations2.txt', 'w') as file:
35
+ # Write the matches to the file
36
+ for row, match in zip(df_sorted[['Model', 'Average', 'AGIEval', 'GPT4All', 'TruthfulQA', 'Bigbench']].head(20).values, matches):
37
+ file.write(f'Model Name: {row[0]}\n')
38
+ file.write(f'Scores: {row[1]}\n')
39
+ file.write(f'AGIEval: {row[2]}\n')
40
+ file.write(f'GPT4All: {row[3]}\n')
41
+ file.write(f'TruthfulQA: {row[4]}\n')
42
+ file.write(f'Bigbench: {row[5]}\n')
43
+ file.write('yaml' + match + '```\n')