Add the submit function
Browse files
app.py
CHANGED
|
@@ -21,6 +21,8 @@ import plotly.express as px
|
|
| 21 |
import plotly.graph_objects as go
|
| 22 |
import numpy as np
|
| 23 |
|
|
|
|
|
|
|
| 24 |
# Configure logging
|
| 25 |
logging.basicConfig(level=logging.INFO)
|
| 26 |
logger = logging.getLogger(__name__)
|
|
@@ -52,6 +54,63 @@ TASK_METADATA_GENERATIVE = {
|
|
| 52 |
"REL": {"icon": "π", "name": "Relation Extraction", "tooltip": ""},
|
| 53 |
}
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
def highlight_best_per_task(df):
|
| 56 |
"""Add π‘ symbol next to the maximum value in each task column"""
|
| 57 |
|
|
@@ -539,6 +598,79 @@ def create_gradio_interface():
|
|
| 539 |
with gr.TabItem("π About"):
|
| 540 |
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
| 541 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 542 |
# Separatori
|
| 543 |
with gr.TabItem("β", interactive=False):
|
| 544 |
gr.Markdown("", elem_classes="markdown-text")
|
|
|
|
| 21 |
import plotly.graph_objects as go
|
| 22 |
import numpy as np
|
| 23 |
|
| 24 |
+
import requests
|
| 25 |
+
|
| 26 |
# Configure logging
|
| 27 |
logging.basicConfig(level=logging.INFO)
|
| 28 |
logger = logging.getLogger(__name__)
|
|
|
|
| 54 |
"REL": {"icon": "π", "name": "Relation Extraction", "tooltip": ""},
|
| 55 |
}
|
| 56 |
|
| 57 |
+
# Function to send a Slack notification for a new model submission for evaluation
|
| 58 |
+
def send_slack_notification(model_name, user_name, user_affiliation):
|
| 59 |
+
# Insert your Slack webhook URL here
|
| 60 |
+
webhook_url = "https://hooks.slack.com/services/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"
|
| 61 |
+
|
| 62 |
+
# Create the message to be sent to Slack
|
| 63 |
+
message = {
|
| 64 |
+
"text": f"New model submission for EVALITA-LLM leaderboard:\n\n"
|
| 65 |
+
f"**Model Name**: {model_name}\n"
|
| 66 |
+
f"**User**: {user_name}\n"
|
| 67 |
+
f"**Affiliation**: {user_affiliation}\n"
|
| 68 |
+
f"Check out the model on HuggingFace: https://huggingface.co/{model_name}"
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
# Send the message to Slack
|
| 72 |
+
response = requests.post(webhook_url, json=message)
|
| 73 |
+
|
| 74 |
+
# Check if the request was successful and return the appropriate message
|
| 75 |
+
if response.status_code == 200:
|
| 76 |
+
return "β
**Notification sent successfully!**"
|
| 77 |
+
else:
|
| 78 |
+
return f"β **Failed to send notification**: {response.text}"
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
# Funcion to validate the model submission and send the request for processing
|
| 82 |
+
def validate_and_submit_request(model_name, user_email, user_affiliation):
|
| 83 |
+
# Check if model name is provided and not empty
|
| 84 |
+
if not model_name or not model_name.strip():
|
| 85 |
+
return "β **Error:** Model name is required."
|
| 86 |
+
|
| 87 |
+
# Check if user email is provided and not empty
|
| 88 |
+
if not user_email or not user_email.strip():
|
| 89 |
+
return "β **Error:** Email address is required."
|
| 90 |
+
|
| 91 |
+
# Validate email format using regex
|
| 92 |
+
email_regex = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
|
| 93 |
+
if not re.match(email_regex, user_email.strip()):
|
| 94 |
+
return "β **Error:** Invalid email format. Please enter a valid email address."
|
| 95 |
+
|
| 96 |
+
# Check if user affiliation is provided and not empty
|
| 97 |
+
if not user_affiliation or not user_affiliation.strip():
|
| 98 |
+
return "β **Error:** Affiliation is required."
|
| 99 |
+
|
| 100 |
+
# Check if model name follows the correct format (organization/model-name)
|
| 101 |
+
if "/" not in model_name:
|
| 102 |
+
return "β **Error:** Model name must be in format 'organization/model-name' (e.g., 'microsoft/DialoGPT-medium')."
|
| 103 |
+
|
| 104 |
+
# Check if the model name contains only valid characters (letters, numbers, '.', '_', '/', and '-')
|
| 105 |
+
if not re.match(r'^[a-zA-Z0-9._/-]+$', model_name):
|
| 106 |
+
return "β **Error:** Model name contains invalid characters."
|
| 107 |
+
|
| 108 |
+
# If all validations pass, send the Slack notification
|
| 109 |
+
slack_response = send_slack_notification(model_name.strip(), user_email.strip(), user_affiliation.strip())
|
| 110 |
+
|
| 111 |
+
# Return the Slack response (success or failure message)
|
| 112 |
+
return slack_response
|
| 113 |
+
|
| 114 |
def highlight_best_per_task(df):
|
| 115 |
"""Add π‘ symbol next to the maximum value in each task column"""
|
| 116 |
|
|
|
|
| 598 |
with gr.TabItem("π About"):
|
| 599 |
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
| 600 |
|
| 601 |
+
|
| 602 |
+
# π Submit a new model to evaluate
|
| 603 |
+
with gr.TabItem("π Submit"):
|
| 604 |
+
gr.Markdown("# π Model Evaluation Request", elem_classes="markdown-text")
|
| 605 |
+
gr.Markdown("""
|
| 606 |
+
**Fill out the form below to request evaluation of your model on EVALITA-LLM.**
|
| 607 |
+
|
| 608 |
+
Once submitted, our team will automatically receive a notification. We will evaluate the
|
| 609 |
+
submissionβs relevance for both research and commercial purposes, as well as assess its feasibility.
|
| 610 |
+
""", elem_classes="markdown-text")
|
| 611 |
+
|
| 612 |
+
with gr.Row():
|
| 613 |
+
with gr.Column():
|
| 614 |
+
# HuggingFace model name field
|
| 615 |
+
model_name_input = gr.Textbox(
|
| 616 |
+
label="HuggingFace Model Name",
|
| 617 |
+
placeholder="e.g., microsoft/DialoGPT-medium",
|
| 618 |
+
info="Enter the complete model name as it appears on HuggingFace Hub (organization/model-name)",
|
| 619 |
+
elem_id="model-name-input"
|
| 620 |
+
)
|
| 621 |
+
|
| 622 |
+
# User email field
|
| 623 |
+
user_name_input = gr.Textbox(
|
| 624 |
+
label="Your email address",
|
| 625 |
+
placeholder="e.g., mario.rossi@example.com",
|
| 626 |
+
info="Enter your email address for communication",
|
| 627 |
+
elem_id="user-email-input"
|
| 628 |
+
)
|
| 629 |
+
|
| 630 |
+
# Affiliation field
|
| 631 |
+
user_affiliation_input = gr.Textbox(
|
| 632 |
+
label="Affiliation",
|
| 633 |
+
placeholder="e.g., University of Milan, Google Research, Freelancer",
|
| 634 |
+
info="Enter your affiliation (university, company, organization)",
|
| 635 |
+
elem_id="user-affiliation-input"
|
| 636 |
+
)
|
| 637 |
+
|
| 638 |
+
# Submit button
|
| 639 |
+
submit_request_button = gr.Button(
|
| 640 |
+
"π€ Submit Request",
|
| 641 |
+
variant="primary",
|
| 642 |
+
elem_id="submit-request-button"
|
| 643 |
+
)
|
| 644 |
+
|
| 645 |
+
# Result area
|
| 646 |
+
submission_status = gr.Markdown(elem_id="submission-status")
|
| 647 |
+
|
| 648 |
+
# Connect button to function
|
| 649 |
+
submit_request_button.click(
|
| 650 |
+
validate_and_submit_request,
|
| 651 |
+
inputs=[model_name_input, user_name_input, user_affiliation_input],
|
| 652 |
+
outputs=submission_status
|
| 653 |
+
)
|
| 654 |
+
|
| 655 |
+
# Additional information
|
| 656 |
+
with gr.Accordion("βΉοΈ Additional Information", open=False):
|
| 657 |
+
gr.Markdown("""
|
| 658 |
+
**What happens after submission:**
|
| 659 |
+
1. Your request is automatically sent to the EVALITA-LLM team
|
| 660 |
+
2. We verify that the model is accessible on HuggingFace
|
| 661 |
+
3. We contact you to confirm inclusion in the evaluation
|
| 662 |
+
4. The model is added to the evaluation queue
|
| 663 |
+
|
| 664 |
+
**Model requirements:**
|
| 665 |
+
- Model must be publicly accessible on HuggingFace Hub
|
| 666 |
+
- Must be compatible with the EleutherAI/lm-evaluation-harness framework
|
| 667 |
+
- Must have a license that allows evaluation
|
| 668 |
+
|
| 669 |
+
**Evaluation tasks:**
|
| 670 |
+
Your model will be evaluated on all tasks: TE, SA, HS, AT, WIC, FAQ, LS, SU, NER, REL.
|
| 671 |
+
""", elem_classes="markdown-text")
|
| 672 |
+
|
| 673 |
+
|
| 674 |
# Separatori
|
| 675 |
with gr.TabItem("β", interactive=False):
|
| 676 |
gr.Markdown("", elem_classes="markdown-text")
|