CultriX commited on
Commit
434f3cf
1 Parent(s): 952614e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -26
app.py CHANGED
@@ -149,33 +149,43 @@ def create_bar_chart(df, category):
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
- csv_data = df.to_csv(index=False)
178
- return configurations, matches, csv_data
 
 
 
 
 
 
 
 
 
 
 
179
 
180
  # Main function to run the Streamlit app
181
  def main():
 
149
  st.plotly_chart(fig, use_container_width=True, height=len(df) * 35)
150
 
151
  def fetch_merge_configs(df):
152
+ # Sort the data by the second column (assuming the column name is 'Average')
153
+ df_sorted = df.sort_values(by='Average', ascending=False)
154
+
155
+ # Open the file in append mode
156
+ with open('configurations.txt', 'a') as file:
157
+ # Get model cards for the top 20 entries
158
+ for index, row in df_sorted.head(20).iterrows():
159
+ model_name = row['Model'].rstrip()
 
160
  card = ModelCard.load(model_name)
161
+ file.write(f'Model Name: {model_name}\n')
162
+ file.write(f'Scores: {row["Average"]}\n') # Assuming 'Average' is the benchmark score
163
+ file.write(f'AGIEval: {row["AGIEval"]}\n')
164
+ file.write(f'GPT4All: {row["GPT4All"]}\n')
165
+ file.write(f'TruthfulQA: {row["TruthfulQA"]}\n')
166
+ file.write(f'Bigbench: {row["Bigbench"]}\n')
167
+ file.write(f'Model Card: {card}\n')
168
+
169
+ # Open the second file in read mode
170
+ with open('configurations.txt', 'r') as file:
171
+ # Read the content
172
+ content = file.read()
173
+
174
+ # Find all text between 'yaml' and '```'
175
+ matches = re.findall(r'yaml(.*?)```', content, re.DOTALL)
176
+
177
+ # Open the file 'configurations2.txt' in write mode
178
+ with open('configurations2.txt', 'w') as file:
179
+ # Write the matches to the file
180
+ for row, match in zip(df_sorted[['Model', 'Average', 'AGIEval', 'GPT4All', 'TruthfulQA', 'Bigbench']].head(20).values, matches):
181
+ file.write(f'Model Name: {row[0]}\n')
182
+ file.write(f'Scores: {row[1]}\n')
183
+ file.write(f'AGIEval: {row[2]}\n')
184
+ file.write(f'GPT4All: {row[3]}\n')
185
+ file.write(f'TruthfulQA: {row[4]}\n')
186
+ file.write(f'Bigbench: {row[5]}\n')
187
+ file.write('yaml' + match + '```\n')
188
+
189
 
190
  # Main function to run the Streamlit app
191
  def main():