Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -117,24 +117,24 @@ def init_leaderboard_mib(dataframe, track):
|
|
| 117 |
)
|
| 118 |
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
# Process results into summary format
|
| 126 |
summary_data = []
|
| 127 |
method_name = json_data['method_name']
|
| 128 |
|
| 129 |
-
# Extract
|
| 130 |
for model_result in json_data['results']:
|
| 131 |
model_id = model_result['model_id']
|
|
|
|
| 132 |
|
| 133 |
-
# Get scores for the specified task
|
| 134 |
-
task_data = model_result['task_scores'].get(task_type, [])
|
| 135 |
-
if not task_data:
|
| 136 |
-
continue
|
| 137 |
-
|
| 138 |
# Calculate best layer performance
|
| 139 |
best_scores = calculate_best_layer_scores(task_data)
|
| 140 |
|
|
@@ -148,14 +148,14 @@ def init_leaderboard_mib_causal(json_data, task_type):
|
|
| 148 |
summary_data.append(summary_row)
|
| 149 |
|
| 150 |
# Convert to DataFrame
|
| 151 |
-
|
| 152 |
|
| 153 |
# Round numeric columns to 3 decimal places
|
| 154 |
numeric_cols = ['Best Output Token Score', 'Best Output Location Score']
|
| 155 |
-
|
| 156 |
|
| 157 |
return Leaderboard(
|
| 158 |
-
value=
|
| 159 |
datatype=['text', 'text', 'number', 'number', 'number'],
|
| 160 |
select_columns=SelectColumns(
|
| 161 |
default_selection=['Method', 'Model', 'Best Output Token Score', 'Best Output Location Score', 'Best Layer'],
|
|
|
|
| 117 |
)
|
| 118 |
|
| 119 |
|
| 120 |
+
Ah, I see the issue - the function is receiving a DataFrame but the code expects JSON data. Let me fix the function to work with the DataFrame input:
|
| 121 |
+
pythonCopydef init_leaderboard_mib_causal(dataframe, track):
|
| 122 |
+
"""Creates a leaderboard summary for causal intervention results"""
|
| 123 |
+
if dataframe is None or dataframe.empty:
|
| 124 |
+
raise ValueError("Leaderboard DataFrame is empty or None.")
|
| 125 |
+
|
| 126 |
+
# Read and process JSON data
|
| 127 |
+
json_data = json.loads(dataframe.to_json(orient='records'))[0]
|
| 128 |
+
|
| 129 |
# Process results into summary format
|
| 130 |
summary_data = []
|
| 131 |
method_name = json_data['method_name']
|
| 132 |
|
| 133 |
+
# Extract scores for MCQA task
|
| 134 |
for model_result in json_data['results']:
|
| 135 |
model_id = model_result['model_id']
|
| 136 |
+
task_data = model_result['task_scores']['MCQA']
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
# Calculate best layer performance
|
| 139 |
best_scores = calculate_best_layer_scores(task_data)
|
| 140 |
|
|
|
|
| 148 |
summary_data.append(summary_row)
|
| 149 |
|
| 150 |
# Convert to DataFrame
|
| 151 |
+
results_df = pd.DataFrame(summary_data)
|
| 152 |
|
| 153 |
# Round numeric columns to 3 decimal places
|
| 154 |
numeric_cols = ['Best Output Token Score', 'Best Output Location Score']
|
| 155 |
+
results_df[numeric_cols] = results_df[numeric_cols].round(3)
|
| 156 |
|
| 157 |
return Leaderboard(
|
| 158 |
+
value=results_df,
|
| 159 |
datatype=['text', 'text', 'number', 'number', 'number'],
|
| 160 |
select_columns=SelectColumns(
|
| 161 |
default_selection=['Method', 'Model', 'Best Output Token Score', 'Best Output Location Score', 'Best Layer'],
|