Spaces:
Running
Running
File size: 22,422 Bytes
2fc77f5 e46e945 2fc77f5 e46e945 2fc77f5 a90efab 2fc77f5 9fd4b06 a90efab 5b3b90b 2fc77f5 5b3b90b 2fc77f5 5b3b90b 9fd4b06 5b3b90b 2fc77f5 5b3b90b 2fc77f5 a90efab f732437 a90efab f732437 a90efab f732437 a90efab 009db1f f732437 53c242a a90efab 53c242a f732437 53c242a a90efab f732437 53c242a f732437 a90efab 9fd4b06 2fc77f5 5dd7582 2fc77f5 61542b8 2fc77f5 5dd7582 06e8556 2fc77f5 5dd7582 2fc77f5 5dd7582 61542b8 2fc77f5 a100ebc 9fd4b06 53c7136 7ed00c5 f65df62 29701ab b56a213 1eaca05 4493851 e46e945 4493851 e46e945 531005f f65df62 e46e945 4493851 1eaca05 53c7136 b56a213 53c7136 753260a 53c7136 a100ebc 531005f e46e945 531005f e46e945 531005f a100ebc e46e945 a100ebc e46e945 2fc77f5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
from dataclasses import dataclass, make_dataclass
from enum import Enum
import pandas as pd
from src.about import Tasks, TasksMultimodal, TasksMib_Subgraph, TasksMib_Causalgraph
def fields(raw_class):
return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
# These classes are for user facing column names,
# to avoid having to change them all around the code
# when a modif is needed
@dataclass
class ColumnContent:
name: str
type: str
displayed_by_default: bool
hidden: bool = False
never_hidden: bool = False
## Leaderboard columns
auto_eval_column_dict = []
auto_eval_column_dict_multimodal = []
auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
auto_eval_column_dict.append(["hf_repo", ColumnContent, ColumnContent("HF Repo", "str", False)])
auto_eval_column_dict.append(["track", ColumnContent, ColumnContent("Track", "markdown", False)])
#Scores
for task in Tasks:
auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
# Model information
auto_eval_column_dict.append(["text_average", ColumnContent, ColumnContent("Text Average", "number", True)])
auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
auto_eval_column_dict_multimodal.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
auto_eval_column_dict_multimodal.append(["hf_repo", ColumnContent, ColumnContent("HF Repo", "str", False)])
auto_eval_column_dict_multimodal.append(["track", ColumnContent, ColumnContent("Track", "markdown", False)])
for task in TasksMultimodal:
auto_eval_column_dict_multimodal.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
if task.value.col_name in ("ewok", "EWoK"): # make sure this appears in the right order
auto_eval_column_dict_multimodal.append(["text_average", ColumnContent, ColumnContent("Text Average", "number", True)])
auto_eval_column_dict_multimodal.append(["vision_average", ColumnContent, ColumnContent("Vision Average", "number", True)])
auto_eval_column_dict_multimodal.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
auto_eval_column_dict_multimodal.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
AutoEvalColumnMultimodal = make_dataclass("AutoEvalColumnMultimodal", auto_eval_column_dict_multimodal, frozen=True)
##############################################################################################################
# Version 1
# auto_eval_column_dict_mib_subgraph = []
# # Method name column
# auto_eval_column_dict_mib_subgraph.append(["method", ColumnContent, ColumnContent("Method", "markdown", True, never_hidden=True)])
# # For each task and model combination
# for task in TasksMib_Subgraph:
# for model in task.value.models:
# col_name = f"{task.value.benchmark}_{model}" # ioi_gpt2, mcqa_qwen2.5, etc.
# auto_eval_column_dict_mib_subgraph.append([
# col_name,
# ColumnContent,
# ColumnContent(col_name, "number", True)
# ])
# # Average column
# auto_eval_column_dict_mib_subgraph.append(["average", ColumnContent, ColumnContent("Average", "number", True)])
# ##############################################################################################################
# # Version 2
# auto_eval_column_dict_mib_subgraph = []
# # Method name column
# auto_eval_column_dict_mib_subgraph.append(["method", ColumnContent, ColumnContent("Method", "markdown", True, never_hidden=True)])
# # Add task filter column
# task_values = list(set(task.value.benchmark for task in TasksMib_Subgraph))
# auto_eval_column_dict_mib_subgraph.append(
# ["task_filter", ColumnContent, ColumnContent("Task", "str", True, never_hidden=True)]
# )
# # Add model filter column
# model_values = list(set(
# model
# for task in TasksMib_Subgraph
# for model in task.value.models
# ))
# auto_eval_column_dict_mib_subgraph.append(
# ["model_filter", ColumnContent, ColumnContent("Model", "str", True, never_hidden=True)]
# )
# # For each task and model combination
# for task in TasksMib_Subgraph:
# for model in task.value.models:
# col_name = f"{task.value.benchmark}_{model}"
# auto_eval_column_dict_mib_subgraph.append([
# col_name,
# ColumnContent,
# ColumnContent(col_name, "number", True)
# ])
# # Average column
# auto_eval_column_dict_mib_subgraph.append(["average", ColumnContent, ColumnContent("Average", "number", True)])
##############################################################################################################
# Version 3
auto_eval_column_dict_mib_subgraph = []
# Method name column (always present)
auto_eval_column_dict_mib_subgraph.append(
["method", ColumnContent, ColumnContent("Method", "markdown", True, never_hidden=True)]
)
# Add columns for each task-model combination
for task in TasksMib_Subgraph:
for model in task.value.models:
field_name = f"{task.value.benchmark}_{model}"
display_name = f"{task.value.benchmark}({model})"
print(f"Creating column - Field name: {field_name}, Display name: {display_name}")
column_content = ColumnContent(display_name, "number", True)
print(f"Column content name property: {column_content.name}")
auto_eval_column_dict_mib_subgraph.append([
field_name,
ColumnContent,
column_content
])
# Add the Average column
auto_eval_column_dict_mib_subgraph.append(
["average", ColumnContent, ColumnContent("Average", "number", True)]
)
print("\nFinal column configurations:")
for field in auto_eval_column_dict_mib_subgraph:
print(f"Field name: {field[0]}, Display name: {field[2].name}")
# Create the dataclass for MIB columns
AutoEvalColumn_mib_subgraph = make_dataclass("AutoEvalColumn_mib_subgraph", auto_eval_column_dict_mib_subgraph, frozen=True)
# Column selection for display
COLS_MIB_SUBGRAPH = [c.name for c in fields(AutoEvalColumn_mib_subgraph) if not c.hidden]
BENCHMARK_COLS_MIB_SUBGRAPH = []
for task in TasksMib_Subgraph:
for model in task.value.models:
col_name = f"{task.value.col_name}_{model.replace('-', '_')}"
BENCHMARK_COLS_MIB_SUBGRAPH.append(col_name)
# Implement the same for causal graph, auto_eval_column_dict_mib_causalgraph, AutoEvalColumn_mib_causalgraph
AutoEvalColumn_mib_causalgraph = []
COLS_MIB_CAUSALGRAPH = []
BENCHMARK_COLS_MIB_CAUSALGRAPH = []
# # Initialize the MIB causal graph columns
# auto_eval_column_dict_mib_causalgraph = []
# # Method name column
# auto_eval_column_dict_mib_causalgraph.append(["method", ColumnContent, ColumnContent("Method", "markdown", True, never_hidden=True)])
# # For each model-task-intervention combination
# for task in TasksMib_Causalgraph:
# for model in task.value.models:
# for intervention in task.value.interventions:
# col_name = f"{model}_{task.value.benchmark}_{intervention}".lower()
# auto_eval_column_dict_mib_causalgraph.append([
# col_name,
# ColumnContent,
# ColumnContent(col_name, "number", True)
# ])
# auto_eval_column_dict_mib_causalgraph = []
# # Method name column
# auto_eval_column_dict_mib_causalgraph.append(["method", ColumnContent, ColumnContent("Method", "markdown", True, never_hidden=True)])
# # For each model-task-intervention combination
# for task in TasksMib_Causalgraph:
# for model in task.value.models:
# model_name = model.lower() # Convert model name to lowercase
# for layer in task.value.layers:
# for intervention in task.value.interventions:
# for counterfactual in task.value.counterfactuals:
# # Include model name in the column name
# col_name = f"{model_name}_layer{layer}_{intervention}_{counterfactual}"
# field_name = col_name.lower()
# auto_eval_column_dict_mib_causalgraph.append([
# field_name,
# ColumnContent,
# ColumnContent(col_name, "number", True)
# ])
# # In utils.py, modify auto_eval_column_dict_mib_causalgraph:
# auto_eval_column_dict_mib_causalgraph = []
# # Method name column
# auto_eval_column_dict_mib_causalgraph.append(["method", ColumnContent, ColumnContent("Method", "markdown", True, never_hidden=True)])
# # For each model-task-intervention-counterfactual combination
# for task in TasksMib_Causalgraph:
# for model in ["qwen2forcausallm", "gemma2forcausallm", "llamaforcausallm"]: # exact model names
# for layer in task.value.layers:
# for intervention in task.value.interventions:
# for counterfactual in task.value.counterfactuals:
# # Match the exact format from the data
# col_name = f"{model}_layer{layer}_{intervention}_{counterfactual}".lower()
# auto_eval_column_dict_mib_causalgraph.append([
# col_name,
# ColumnContent,
# ColumnContent(col_name, "number", True)
# ])
# auto_eval_column_dict_mib_causalgraph = []
# # Method name column
# auto_eval_column_dict_mib_causalgraph.append(["method", ColumnContent, ColumnContent("Method", "markdown", True, never_hidden=True)])
# # Add eval_name column
# auto_eval_column_dict_mib_causalgraph.append(["eval_name", ColumnContent, ColumnContent("eval_name", "str", True)])
# # For each model-task-intervention-counterfactual combination
# for task in TasksMib_Causalgraph:
# for model in task.value.models: # Use exact model names with correct casing
# model_name = model # Don't convert to lowercase
# for layer in task.value.layers:
# for intervention in task.value.interventions:
# for counterfactual in task.value.counterfactuals:
# # Match exact format from the actual data
# col_name = f"{model_name}_layer{layer}_{intervention}_{counterfactual}"
# # Use the exact column name as both the field name and display name
# auto_eval_column_dict_mib_causalgraph.append([
# col_name,
# ColumnContent,
# ColumnContent(col_name, "number", True)
# ])
# auto_eval_column_dict_mib_causalgraph = []
# # Method name column
# auto_eval_column_dict_mib_causalgraph.append(["method", ColumnContent, ColumnContent("Method", "markdown", True, never_hidden=True)])
# auto_eval_column_dict_mib_causalgraph.append(["eval_name", ColumnContent, ColumnContent("eval_name", "str", True)])
# # For each model-task-intervention-counterfactual combination
# for task in TasksMib_Causalgraph:
# for model in task.value.models:
# for layer in task.value.layers[model]: # Use model-specific layers
# for intervention in task.value.interventions:
# for counterfactual in task.value.counterfactuals:
# col_name = f"{model}_layer{layer}_{intervention}_{counterfactual}"
# auto_eval_column_dict_mib_causalgraph.append([
# col_name,
# ColumnContent,
# ColumnContent(col_name, "number", True)
# ])
# auto_eval_column_dict_mib_causalgraph = []
# # Method name column
# auto_eval_column_dict_mib_causalgraph.append(["method", ColumnContent, ColumnContent("Method", "markdown", True, never_hidden=True)])
# auto_eval_column_dict_mib_causalgraph.append(["eval_name", ColumnContent, ColumnContent("eval_name", "str", True)])
# # For each model-task-intervention-counterfactual combination
# for task in TasksMib_Causalgraph:
# for model in task.value.models: # model will already be lowercase
# for layer in task.value.layers[model]:
# for intervention in task.value.interventions:
# for counterfactual in task.value.counterfactuals:
# # Use exactly the same format as in DataFrame
# col_name = f"{model}_layer{layer}_{intervention}_{counterfactual}"
# auto_eval_column_dict_mib_causalgraph.append([
# col_name,
# ColumnContent,
# ColumnContent(col_name, "number", True)
# ])
auto_eval_column_dict_mib_causalgraph = []
# Only include Method column as required
auto_eval_column_dict_mib_causalgraph.append(["method", ColumnContent, ColumnContent("Method", "markdown", True, never_hidden=True)])
# For each model-task-intervention-counterfactual combination
for task in TasksMib_Causalgraph:
for model in task.value.models: # model will be lowercase
for layer in task.value.layers[model]:
for intervention in task.value.interventions:
for counterfactual in task.value.counterfactuals:
col_name = f"{model}_layer{layer}_{intervention}_{counterfactual}"
auto_eval_column_dict_mib_causalgraph.append([
col_name,
ColumnContent,
ColumnContent(col_name, "number", True)
])
# Create the dataclass
AutoEvalColumn_mib_causalgraph = make_dataclass(
"AutoEvalColumn_mib_causalgraph",
auto_eval_column_dict_mib_causalgraph,
frozen=True
)
# Column selection for display
COLS_MIB_CAUSALGRAPH = [c.name for c in fields(AutoEvalColumn_mib_causalgraph) if not c.hidden]
BENCHMARK_COLS_MIB_CAUSALGRAPH = [f"{model}_{task.value.benchmark}_{intervention}".lower()
for task in TasksMib_Causalgraph
for model in task.value.models
for intervention in task.value.interventions]
## For the queue columns in the submission tab
@dataclass(frozen=True)
class EvalQueueColumn: # Queue column
model = ColumnContent("model", "markdown", True)
track = ColumnContent("track", "str", True)
revision = ColumnContent("revision", "str", True)
private = ColumnContent("private", "bool", True)
status = ColumnContent("status", "str", True)
## All the model information that we might need
@dataclass
class ModelDetails:
name: str
display_name: str = ""
symbol: str = "" # emoji
# Column selection
COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
COLS_MULTIMODAL = [c.name for c in fields(AutoEvalColumnMultimodal) if not c.hidden]
EVAL_COLS = [c.name for c in fields(EvalQueueColumn)]
EVAL_TYPES = [c.type for c in fields(EvalQueueColumn)]
BENCHMARK_COLS = [t.value.col_name for t in Tasks]
BENCHMARK_COLS_MULTIMODAL = [t.value.col_name for t in TasksMultimodal]
TEXT_TASKS = {
"glue": ["cola", "sst2", "mrpc", "qqp", "mnli", "mnli-mm", "qnli", "rte",
"boolq", "multirc", "wsc"],
# Lots of BLiMP tasks – use verifier function below to see if you've included everything.
"blimp": ["adjunct_island","anaphor_gender_agreement","anaphor_number_agreement","animate_subject_passive","animate_subject_trans",
"causative","complex_NP_island","coordinate_structure_constraint_complex_left_branch","coordinate_structure_constraint_object_extraction","determiner_noun_agreement_1",
"determiner_noun_agreement_2","determiner_noun_agreement_irregular_1","determiner_noun_agreement_irregular_2","determiner_noun_agreement_with_adjective_1",
"determiner_noun_agreement_with_adj_2","determiner_noun_agreement_with_adj_irregular_1","determiner_noun_agreement_with_adj_irregular_2","distractor_agreement_relational_noun",
"distractor_agreement_relative_clause","drop_argument","ellipsis_n_bar_1","ellipsis_n_bar_2",
"existential_there_object_raising", "existential_there_quantifiers_1",
"existential_there_quantifiers_2", "existential_there_subject_raising", "expletive_it_object_raising",
"inchoative", "intransitive","irregular_past_participle_adjectives", "irregular_past_participle_verbs",
"irregular_plural_subject_verb_agreement_1", "irregular_plural_subject_verb_agreement_2", "left_branch_island_echo_question", "left_branch_island_simple_question",
"matrix_question_npi_licensor_present", "npi_present_1", "npi_present_2", "only_npi_licensor_present", "only_npi_scope", "passive_1", "passive_2",
"principle_A_case_1", "principle_A_case_2", "principle_A_c_command", "principle_A_domain_1",
"principle_A_domain_2", "principle_A_domain_3", "principle_A_reconstruction", "regular_plural_subject_verb_agreement_1",
"regular_plural_subject_verb_agreement_2", "sentential_negation_npi_licensor_present", "sentential_negation_npi_scope", "sentential_subject_island",
"superlative_quantifiers_1", "superlative_quantifiers_2", "tough_vs_raising_1", "tough_vs_raising_2",
"transitive", "wh_island", "wh_questions_object_gap", "wh_questions_subject_gap",
"wh_questions_subject_gap_long_distance", "wh_vs_that_no_gap", "wh_vs_that_no_gap_long_distance", "wh_vs_that_with_gap",
"wh_vs_that_with_gap_long_distance"
],
"blimp_supplement": ["hypernym", "qa_congruence_easy", "qa_congruence_tricky",
"subject_aux_inversion", "turn_taking"],
"ewok": ["agent-properties", "material-dynamics", "material-properties", "physical-dynamics",
"physical-interactions", "physical-relations", "quantitative-properties",
"social-interactions", "social-properties", "social-relations", "spatial-relations"]
}
VISION_TASKS = {
"vqa": ["vqa"],
"winoground": ["winoground"],
"devbench": ["lex-viz_vocab", "gram-trog", "sem-things"]
}
NUM_EXPECTED_EXAMPLES = {
"glue": {
"cola": 522,
"sst2": 436,
"mrpc": 204,
"qqp": 20215,
"mnli": 4908,
"mnli-mm": 4916,
"qnli": 2732,
"rte": 139,
"boolq": 1635,
"multirc": 2424,
"wsc": 52
},
"blimp": {
"adjunct_island": 928,
"anaphor_gender_agreement": 971,
"anaphor_number_agreement": 931,
"animate_subject_passive": 895,
"animate_subject_trans": 923,
"causative": 818,
"complex_NP_island": 846,
"coordinate_structure_constraint_complex_left_branch": 906,
"coordinate_structure_constraint_object_extraction": 949,
"determiner_noun_agreement_1": 929,
"determiner_noun_agreement_2": 931,
"determiner_noun_agreement_irregular_1": 681,
"determiner_noun_agreement_irregular_2": 820,
"determiner_noun_agreement_with_adjective_1": 933,
"determiner_noun_agreement_with_adj_2": 941,
"determiner_noun_agreement_with_adj_irregular_1": 718,
"determiner_noun_agreement_with_adj_irregular_2": 840,
"distractor_agreement_relational_noun": 788,
"distractor_agreement_relative_clause": 871,
"drop_argument": 920,
"ellipsis_n_bar_1": 802,
"ellipsis_n_bar_2": 828,
"existential_there_object_raising": 812,
"existential_there_quantifiers_1": 930,
"existential_there_quantifiers_2": 911,
"existential_there_subject_raising": 924,
"expletive_it_object_raising": 759,
"inchoative": 855,
"intransitive": 868,
"irregular_past_participle_adjectives": 961,
"irregular_past_participle_verbs": 942,
"irregular_plural_subject_verb_agreement_1": 804,
"irregular_plural_subject_verb_agreement_2": 892,
"left_branch_island_echo_question": 947,
"left_branch_island_simple_question": 951,
"matrix_question_npi_licensor_present": 929,
"npi_present_1": 909,
"npi_present_2": 914,
"only_npi_licensor_present": 882,
"only_npi_scope": 837,
"passive_1": 840,
"passive_2": 903,
"principle_A_case_1": 912,
"principle_A_case_2": 915,
"principle_A_c_command": 946,
"principle_A_domain_1": 914,
"principle_A_domain_2": 915,
"principle_A_domain_3": 941,
"principle_A_reconstruction": 967,
"regular_plural_subject_verb_agreement_1": 890,
"regular_plural_subject_verb_agreement_2": 945,
"sentential_negation_npi_licensor_present": 919,
"sentential_negation_npi_scope": 871,
"sentential_subject_island": 961,
"superlative_quantifiers_1": 979,
"superlative_quantifiers_2": 986,
"tough_vs_raising_1": 948,
"tough_vs_raising_2": 920,
"transitive": 868,
"wh_island": 960,
"wh_questions_object_gap": 859,
"wh_questions_subject_gap": 898,
"wh_questions_subject_gap_long_distance": 857,
"wh_vs_that_no_gap": 861,
"wh_vs_that_no_gap_long_distance": 875,
"wh_vs_that_with_gap": 919,
"wh_vs_that_with_gap_long_distance": 910
},
"blimp_supplement": {
"hypernym": 842,
"qa_congruence_easy": 64,
"qa_congruence_tricky": 165,
"subject_aux_inversion": 3867,
"turn_taking": 280
},
"ewok": {
"agent-properties": 2210,
"material-dynamics": 770,
"material-properties": 170,
"physical-dynamics": 120,
"physical-interactions": 556,
"physical-relations": 818,
"quantitative-properties": 314,
"social-interactions": 294,
"social-properties": 328,
"social-relations": 1548,
"spatial-relations": 490
},
"vqa": {
"vqa": 25230
},
"winoground": {
"winoground": 746
},
"devbench": {
"lex-viz_vocab": 119,
"gram-trog": 76,
"sem-things": 1854
}
} |