Spaces:
Sleeping
Sleeping
Shiyu Zhao
commited on
Commit
·
6f3655f
1
Parent(s):
f307635
Update space
Browse files
app.py
CHANGED
@@ -545,14 +545,15 @@ def update_leaderboard_data(submission_data):
|
|
545 |
}
|
546 |
|
547 |
df_to_update = split_to_df[submission_data['Split']]
|
|
|
548 |
|
549 |
# Prepare new row data
|
550 |
new_row = {
|
551 |
-
'Method': submission_data['Method Name'],
|
552 |
-
f'STARK-{
|
553 |
-
f'STARK-{
|
554 |
-
f'STARK-{
|
555 |
-
f'STARK-{
|
556 |
}
|
557 |
|
558 |
# Check if method already exists
|
@@ -562,8 +563,11 @@ def update_leaderboard_data(submission_data):
|
|
562 |
for col in new_row:
|
563 |
df_to_update.loc[method_mask, col] = new_row[col]
|
564 |
else:
|
565 |
-
#
|
566 |
-
|
|
|
|
|
|
|
567 |
|
568 |
# Function to get emails from meta_data
|
569 |
def get_emails_from_metadata(meta_data):
|
@@ -667,9 +671,12 @@ def validate_model_type(method_name, selected_type):
|
|
667 |
|
668 |
def process_submission(
|
669 |
method_name, team_name, dataset, split, contact_email,
|
670 |
-
code_repo, csv_file, model_description, hardware, paper_link, model_type
|
671 |
):
|
672 |
"""Process and validate submission"""
|
|
|
|
|
|
|
673 |
temp_files = []
|
674 |
try:
|
675 |
# Input validation
|
@@ -757,7 +764,7 @@ def process_submission(
|
|
757 |
submission_data = {
|
758 |
**meta_data,
|
759 |
"results": processed_results,
|
760 |
-
"status": "
|
761 |
"submission_date": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
762 |
"csv_path": csv_path_in_repo
|
763 |
}
|
@@ -779,7 +786,7 @@ def process_submission(
|
|
779 |
# 3. Create or update latest.json
|
780 |
latest_info = {
|
781 |
"latest_submission": timestamp,
|
782 |
-
"status": "
|
783 |
"method_name": method_name,
|
784 |
"team_name": team_name
|
785 |
}
|
@@ -854,10 +861,23 @@ def filter_by_model_type(df, selected_types):
|
|
854 |
return df[df['Method'].isin(selected_models)]
|
855 |
|
856 |
def format_dataframe(df, dataset):
|
|
|
|
|
|
|
|
|
857 |
columns = ['Method'] + [col for col in df.columns if dataset in col]
|
858 |
filtered_df = df[columns].copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
859 |
filtered_df.columns = [col.split('_')[-1] if '_' in col else col for col in filtered_df.columns]
|
|
|
|
|
860 |
filtered_df = filtered_df.sort_values('MRR', ascending=False)
|
|
|
861 |
return filtered_df
|
862 |
|
863 |
def update_tables(selected_types):
|
@@ -948,7 +968,7 @@ with gr.Blocks(css=css) as demo:
|
|
948 |
""")
|
949 |
|
950 |
with gr.Row():
|
951 |
-
with gr.Column():
|
952 |
method_name = gr.Textbox(
|
953 |
label="Method Name (max 25 chars)*",
|
954 |
placeholder="e.g., MyRetrievalModel-v1"
|
@@ -977,14 +997,14 @@ with gr.Blocks(css=css) as demo:
|
|
977 |
value="Others",
|
978 |
info="Select the appropriate category for your model"
|
979 |
)
|
980 |
-
|
981 |
-
|
982 |
-
with gr.Column():
|
983 |
model_description = gr.Textbox(
|
984 |
label="Model Description*",
|
985 |
lines=3,
|
986 |
placeholder="Briefly describe how your retriever model works..."
|
987 |
)
|
|
|
|
|
|
|
988 |
code_repo = gr.Textbox(
|
989 |
label="Code Repository*",
|
990 |
placeholder="https://github.com/snap-stanford/stark-leaderboard"
|
@@ -993,6 +1013,11 @@ with gr.Blocks(css=css) as demo:
|
|
993 |
label="Hardware Specifications*",
|
994 |
placeholder="e.g., 4x NVIDIA A100 80GB"
|
995 |
)
|
|
|
|
|
|
|
|
|
|
|
996 |
csv_file = gr.File(
|
997 |
label="Prediction CSV*",
|
998 |
file_types=[".csv"],
|
@@ -1003,9 +1028,9 @@ with gr.Blocks(css=css) as demo:
|
|
1003 |
placeholder="https://arxiv.org/abs/..."
|
1004 |
)
|
1005 |
|
|
|
1006 |
submit_btn = gr.Button("Submit", variant="primary")
|
1007 |
result = gr.Textbox(label="Submission Status", interactive=False)
|
1008 |
-
|
1009 |
|
1010 |
# Set up event handlers
|
1011 |
model_type_filter.change(
|
@@ -1013,13 +1038,18 @@ with gr.Blocks(css=css) as demo:
|
|
1013 |
inputs=[model_type_filter],
|
1014 |
outputs=all_dfs
|
1015 |
)
|
|
|
|
|
|
|
|
|
|
|
1016 |
|
1017 |
# Event handler for submission button
|
1018 |
submit_btn.click(
|
1019 |
fn=process_submission,
|
1020 |
inputs=[
|
1021 |
method_name, team_name, dataset, split, contact_email,
|
1022 |
-
code_repo, csv_file, model_description, hardware, paper_link, model_type
|
1023 |
],
|
1024 |
outputs=result
|
1025 |
).success( # Add a success handler to update tables after successful submission
|
|
|
545 |
}
|
546 |
|
547 |
df_to_update = split_to_df[submission_data['Split']]
|
548 |
+
submitted_dataset = submission_data['Dataset'].upper()
|
549 |
|
550 |
# Prepare new row data
|
551 |
new_row = {
|
552 |
+
'Method': submission_data['Method Name'],
|
553 |
+
f'STARK-{submitted_dataset}_Hit@1': submission_data['results']['hit@1'],
|
554 |
+
f'STARK-{submitted_dataset}_Hit@5': submission_data['results']['hit@5'],
|
555 |
+
f'STARK-{submitted_dataset}_R@20': submission_data['results']['recall@20'],
|
556 |
+
f'STARK-{submitted_dataset}_MRR': submission_data['results']['mrr']
|
557 |
}
|
558 |
|
559 |
# Check if method already exists
|
|
|
563 |
for col in new_row:
|
564 |
df_to_update.loc[method_mask, col] = new_row[col]
|
565 |
else:
|
566 |
+
# For new method, create row with NaN for other datasets
|
567 |
+
all_columns = df_to_update.columns
|
568 |
+
full_row = {col: None for col in all_columns} # Initialize with NaN
|
569 |
+
full_row.update(new_row) # Update with the submitted dataset's values
|
570 |
+
df_to_update.loc[len(df_to_update)] = full_row
|
571 |
|
572 |
# Function to get emails from meta_data
|
573 |
def get_emails_from_metadata(meta_data):
|
|
|
671 |
|
672 |
def process_submission(
|
673 |
method_name, team_name, dataset, split, contact_email,
|
674 |
+
code_repo, csv_file, model_description, hardware, paper_link, model_type, honor_code
|
675 |
):
|
676 |
"""Process and validate submission"""
|
677 |
+
if not honor_code:
|
678 |
+
return "Error: Please accept the honor code to submit"
|
679 |
+
|
680 |
temp_files = []
|
681 |
try:
|
682 |
# Input validation
|
|
|
764 |
submission_data = {
|
765 |
**meta_data,
|
766 |
"results": processed_results,
|
767 |
+
"status": "pending_review", # or "approved"
|
768 |
"submission_date": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
769 |
"csv_path": csv_path_in_repo
|
770 |
}
|
|
|
786 |
# 3. Create or update latest.json
|
787 |
latest_info = {
|
788 |
"latest_submission": timestamp,
|
789 |
+
"status": "pending_review", # or "approved"
|
790 |
"method_name": method_name,
|
791 |
"team_name": team_name
|
792 |
}
|
|
|
861 |
return df[df['Method'].isin(selected_models)]
|
862 |
|
863 |
def format_dataframe(df, dataset):
|
864 |
+
"""
|
865 |
+
Format DataFrame for display, removing rows with no data for the specified dataset.
|
866 |
+
"""
|
867 |
+
# Get relevant columns
|
868 |
columns = ['Method'] + [col for col in df.columns if dataset in col]
|
869 |
filtered_df = df[columns].copy()
|
870 |
+
|
871 |
+
# Remove rows where all metric columns are NaN
|
872 |
+
metric_columns = [col for col in filtered_df.columns if col != 'Method']
|
873 |
+
filtered_df = filtered_df.dropna(subset=metric_columns, how='all')
|
874 |
+
|
875 |
+
# Rename columns to remove dataset prefix
|
876 |
filtered_df.columns = [col.split('_')[-1] if '_' in col else col for col in filtered_df.columns]
|
877 |
+
|
878 |
+
# Sort by MRR
|
879 |
filtered_df = filtered_df.sort_values('MRR', ascending=False)
|
880 |
+
|
881 |
return filtered_df
|
882 |
|
883 |
def update_tables(selected_types):
|
|
|
968 |
""")
|
969 |
|
970 |
with gr.Row():
|
971 |
+
with gr.Column(scale=1):
|
972 |
method_name = gr.Textbox(
|
973 |
label="Method Name (max 25 chars)*",
|
974 |
placeholder="e.g., MyRetrievalModel-v1"
|
|
|
997 |
value="Others",
|
998 |
info="Select the appropriate category for your model"
|
999 |
)
|
|
|
|
|
|
|
1000 |
model_description = gr.Textbox(
|
1001 |
label="Model Description*",
|
1002 |
lines=3,
|
1003 |
placeholder="Briefly describe how your retriever model works..."
|
1004 |
)
|
1005 |
+
|
1006 |
+
|
1007 |
+
with gr.Column(scale=1):
|
1008 |
code_repo = gr.Textbox(
|
1009 |
label="Code Repository*",
|
1010 |
placeholder="https://github.com/snap-stanford/stark-leaderboard"
|
|
|
1013 |
label="Hardware Specifications*",
|
1014 |
placeholder="e.g., 4x NVIDIA A100 80GB"
|
1015 |
)
|
1016 |
+
honor_code = gr.Checkbox(
|
1017 |
+
label="Honor Code",
|
1018 |
+
value=False,
|
1019 |
+
info="By submitting these results, you confirm that they are truthful and reproducible, and you verify the integrity of your submission."
|
1020 |
+
)
|
1021 |
csv_file = gr.File(
|
1022 |
label="Prediction CSV*",
|
1023 |
file_types=[".csv"],
|
|
|
1028 |
placeholder="https://arxiv.org/abs/..."
|
1029 |
)
|
1030 |
|
1031 |
+
|
1032 |
submit_btn = gr.Button("Submit", variant="primary")
|
1033 |
result = gr.Textbox(label="Submission Status", interactive=False)
|
|
|
1034 |
|
1035 |
# Set up event handlers
|
1036 |
model_type_filter.change(
|
|
|
1038 |
inputs=[model_type_filter],
|
1039 |
outputs=all_dfs
|
1040 |
)
|
1041 |
+
honor_code.change(
|
1042 |
+
fn=lambda x: gr.Button.update(interactive=x),
|
1043 |
+
inputs=[honor_code],
|
1044 |
+
outputs=[submit_btn]
|
1045 |
+
)
|
1046 |
|
1047 |
# Event handler for submission button
|
1048 |
submit_btn.click(
|
1049 |
fn=process_submission,
|
1050 |
inputs=[
|
1051 |
method_name, team_name, dataset, split, contact_email,
|
1052 |
+
code_repo, csv_file, model_description, hardware, paper_link, model_type, honor_code
|
1053 |
],
|
1054 |
outputs=result
|
1055 |
).success( # Add a success handler to update tables after successful submission
|