File size: 1,762 Bytes
2a9bd05 2186efb 2a9bd05 cee44e8 b6d8e58 2186efb cee44e8 2a9bd05 609c960 cee44e8 72631c1 2a9bd05 a7bc56b ea3d0ab a7bc56b 2186efb 2a9bd05 a7bc56b 2186efb 2a9bd05 d7209cb |
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 |
import gradio as gr
import pandas as pd
LEADERBOARD_FILE = "results.csv"
def load_leaderboard():
return pd.read_csv(LEADERBOARD_FILE)
def display_data(data_type="Overall"):
df = load_leaderboard()
for col in ["Safe Completion Rate", "Harmful Completion Rate", "Refusal Rate", "Normalized Safety Score", "Bias Completion Rate", "Cybercrime Completion Rate", "Harassment Completion Rate","Misinformation Completion Rate", "Illegal Activity Completion Rate"]:
df[col] = df[col].apply(lambda x: f"{x:.1f}")
if data_type == "Overall":
new_df = df[["Model", "Safe Completion Rate", "Harmful Completion Rate", "Refusal Rate", "Normalized Safety Score", "License"]].copy()
else:
category_col = f"{data_type} Completion Rate"
new_df = df[["Model", category_col, "Safe Completion Rate", "License"]].copy()
sort_col = "Model"
return new_df.sort_values(by=sort_col)
with gr.Blocks() as demo:
gr.Markdown("# SafeArena Leaderboard")
gr.Markdown("""
# SafeArena Leaderboard
| [**🤗Dataset**](https://huggingface.co/datasets/McGill-NLP/safearena) | [**📄Paper**](https://arxiv.org/abs/2503.04957) | [**🌐Website**](https://safearena.github.io) | [**💾Code**](https://github.com/McGill-NLP/safearena) |
| :--: | :--: | :--: | :--: |
""")
data_type_dropdown = gr.Dropdown(
label="Data Type",
choices=["Overall", "Bias", "Cybercrime", "Harassment", "Misinformation", "Illegal Activity"],
value="Overall"
)
table = gr.Dataframe(value=display_data("Overall"), interactive=False)
data_type_dropdown.change(
fn=display_data,
inputs=data_type_dropdown,
outputs=table
)
demo.launch(share=True) |