import pandas as pd
import gradio as gr
from io import StringIO
# Creating a sample dataframe
df = pd.DataFrame({
"Rank" : [1, 2, 3, 4, 5],
"Detector" : [
"""ChatGPT_QA\n(Antoun et al., 2023)\nPaper""",
"""XMLMR_ChatGPT\n(Guo et al., 2023)\nPaper""",
"""LLMDET\n(Liu et al., 2019)\nPaper""",
"""Radar_Vicuna7B\n(Hu et al, 2023)\nPaper""",
"""GPTZero\n(Numo et al.)\nWebApp""",
],
"All Gen. [F1]" : [0.723, 0.563, 0.736, 0.635, 0.464],
"Llama-2 7B Gen. [F1]" : [0.719, 0.636, 0.622, 0.722, 0.777],
"GPT-4 Gen. [F1]" : [0.673, 0.435, 0.362, 0.232, 0.562],
"GPT-3 Gen. [F1]" : [0.374, 0.335, 0.232, 0.632, 0.533],
"Falcon 7B Gen. [F1]" : [0.445, 0.454, 0.646, 0.665, 0.464]
})
def process_csv_text(temp_file):
if isinstance(temp_file, str):
df = pd.read_csv(StringIO(temp_file), parse_dates=["Start date", "End date"])
else:
df = pd.read_csv(temp_file.name, parse_dates=["Start date", "End date"])
print(df)
return df
numeric_cols = df.select_dtypes(include='number').columns
traget_cols = ['All Gen. [F1]', 'Llama-2 7B Gen. [F1]', 'GPT-4 Gen. [F1]']
# Applying style to highlight the maximum value in each row
#styler = df.style.highlight_max(color = 'lightgreen', axis = 0)
styler = df.style.set_properties(**{'text-align': 'center'},subset=['Detector'])\
.highlight_max(color='lightgreen', axis=0, subset=traget_cols)
title = "Test"
desc = "Test gradio"
# Displaying the styled dataframe in Gradio
with gr.Blocks() as demo:
gr.Markdown(
"""
BUST: Benchmark for the evaluation of system detectors of LLM-Generated Text
Welcome to BUST, a comprehensive benchmark for evaluating synthetic text detectors, focusing on their \
effectiveness against outputs from various Large Language Models (LLMs). BUST evaluates detectors using a wide \
range of metrics including linguistic features, readability, and writer attitudes, aiming to identify spurious \
signals that may influence detection. The benchmark not only ranks detectors but also analyzes their performance \
correlations with specific metrics and provides insights into biases and robustness against different LLM outputs. \
BUST is designed as a dynamic resource, continuously updated to stay relevant in the rapidly evolving field of \
LLM-generated content detection.
""")
gr.DataFrame(styler, line_breaks=True, datatype="markdown")
# Download testset
gr.Markdown(
"""
Download test dataset
...
""")
# Upload table
gr.Markdown(
"""
Upload predictions
Upload your predictions. Please make sure that the file is in the right format (.csv) and contains the "id" and "prediction" columns.
""")
upload_button = gr.UploadButton(label="Upload Predictions", file_types = ['.csv'], file_count = "single")
table = gr.Dataframe(headers=["Detector", "All Gen. [F1]", "Llama-2 7B Gen. [F1]", "GPT-4 Gen. [F1]","GPT-3 Gen. [F1]", "Falcon 7B Gen. [F1]"], type="pandas", col_count=6)
upload_button.upload(fn=process_csv_text, inputs=upload_button, outputs=table, api_name="upload_csv")
demo.launch()