Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Zack Zhiyuan Li
commited on
Commit
Β·
116bc60
1
Parent(s):
75f5d7b
support leaderboard updates
Browse files- README.md +2 -1
- app.py +95 -62
- requirements.txt +5 -3
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
title: Open LLLM Leaderboard for domains
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
|
@@ -9,6 +9,7 @@ app_file: app.py
|
|
| 9 |
pinned: false
|
| 10 |
short_description: Ranking for Open-sourced LLMs in different domains
|
| 11 |
license: mit
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
# specialized-llm-leaderboard
|
|
|
|
| 1 |
---
|
| 2 |
title: Open LLLM Leaderboard for domains
|
| 3 |
+
emoji: π
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
|
|
|
| 9 |
pinned: false
|
| 10 |
short_description: Ranking for Open-sourced LLMs in different domains
|
| 11 |
license: mit
|
| 12 |
+
hf_oauth: true
|
| 13 |
---
|
| 14 |
|
| 15 |
# specialized-llm-leaderboard
|
app.py
CHANGED
|
@@ -1,48 +1,89 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
| 4 |
import requests
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
def submit_vote(category, vote):
|
| 29 |
-
if not category or not vote:
|
| 30 |
-
return "All fields are required!"
|
| 31 |
-
# code
|
| 32 |
-
return f"Vote '{vote}' submitted successfully!"
|
| 33 |
|
| 34 |
def submit_model(category, model_id):
|
| 35 |
if not category or not model_id:
|
| 36 |
return "All fields are required!"
|
| 37 |
|
| 38 |
-
url = "https://sdk.nexa4ai.com/task" # Will have a new endpoint
|
| 39 |
-
|
| 40 |
data = {
|
| 41 |
-
"
|
| 42 |
-
"
|
| 43 |
}
|
| 44 |
|
| 45 |
-
response = requests.post(
|
| 46 |
|
| 47 |
if response.status_code == 200:
|
| 48 |
return "Your request has been submitted successfully. We will notify you by email once processing is complete."
|
|
@@ -50,58 +91,50 @@ def submit_model(category, model_id):
|
|
| 50 |
return f"Failed to submit request: {response.text}"
|
| 51 |
|
| 52 |
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
with gr.Tabs():
|
| 55 |
with gr.TabItem("Table"):
|
| 56 |
category = gr.Dropdown(
|
| 57 |
-
choices=[
|
| 58 |
-
"Overall", "Biology", "Physics", "Business", "Chemistry",
|
| 59 |
-
"Economics", "Philosophy", "History", "Culture", "Computer Science",
|
| 60 |
-
"Math", "Health", "Law", "Engineering", "Other"
|
| 61 |
-
],
|
| 62 |
label="Select Category",
|
| 63 |
-
value="
|
| 64 |
)
|
| 65 |
|
| 66 |
-
initial_data = update_table("
|
| 67 |
table = gr.Dataframe(
|
| 68 |
-
headers=["
|
| 69 |
-
datatype=["
|
| 70 |
value=initial_data,
|
| 71 |
-
col_count=(
|
| 72 |
)
|
| 73 |
category.change(update_table, inputs=category, outputs=table)
|
| 74 |
|
| 75 |
with gr.TabItem("Vote"):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
category = gr.Dropdown(
|
| 77 |
-
choices=[
|
| 78 |
-
"Biology", "Physics", "Business", "Chemistry",
|
| 79 |
-
"Economics", "Philosophy", "History", "Culture", "Computer Science",
|
| 80 |
-
"Math", "Health", "Law", "Engineering", "Other"
|
| 81 |
-
],
|
| 82 |
label="Select Category"
|
| 83 |
)
|
| 84 |
-
|
|
|
|
| 85 |
submit_button = gr.Button("Submit Vote")
|
| 86 |
-
submit_result = gr.
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
with gr.TabItem("Submit Model"):
|
| 90 |
-
category = gr.Dropdown(
|
| 91 |
-
|
| 92 |
-
"Biology", "Physics", "Business", "Chemistry",
|
| 93 |
-
"Economics", "Philosophy", "History", "Culture", "Computer Science",
|
| 94 |
-
"Math", "Health", "Law", "Engineering", "Other"
|
| 95 |
-
],
|
| 96 |
-
label="Select Category"
|
| 97 |
-
)
|
| 98 |
-
model_id = HuggingfaceHubSearch(
|
| 99 |
-
label="Hub Model ID",
|
| 100 |
-
placeholder="Search for model id on Huggingface",
|
| 101 |
-
search_type="model",
|
| 102 |
-
)
|
| 103 |
submit_model_button = gr.Button("Submit Model")
|
| 104 |
-
submit_model_result = gr.
|
| 105 |
submit_model_button.click(fn=submit_model, inputs=[category, model_id], outputs=submit_model_result)
|
| 106 |
|
| 107 |
-
app.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
import pandas as pd
|
| 4 |
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
| 5 |
import requests
|
| 6 |
|
| 7 |
+
leaderboard_url = os.getenv("LEADERBOARD_URL", "https://leaderboard.nexa4ai.com")
|
| 8 |
+
|
| 9 |
+
get_ranking_url = f"{leaderboard_url}/model/get-ranking-by-category"
|
| 10 |
+
get_models_url = f"{leaderboard_url}/model/get-models-by-category"
|
| 11 |
+
vote_url = f"{leaderboard_url}/model/vote"
|
| 12 |
+
submit_models_url = f"{leaderboard_url}/model/submit-models"
|
| 13 |
+
|
| 14 |
+
def update_table(category):
|
| 15 |
+
url_with_params = f"{get_ranking_url}?category={category}"
|
| 16 |
+
|
| 17 |
+
response = requests.get(url_with_params)
|
| 18 |
+
|
| 19 |
+
if response.status_code == 200:
|
| 20 |
+
ranking_data = response.json()["ranking"]
|
| 21 |
+
api_model_data = {
|
| 22 |
+
"Model": [item["model_id"] for item in ranking_data],
|
| 23 |
+
"Votes": [item["votes"] for item in ranking_data],
|
| 24 |
+
"Categories": [category] * len(ranking_data)
|
| 25 |
}
|
| 26 |
+
api_df = pd.DataFrame(api_model_data)
|
| 27 |
+
else:
|
| 28 |
+
print(f"Failed to submit request: {response.text}")
|
| 29 |
+
api_df = pd.DataFrame()
|
| 30 |
+
return api_df
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def get_user(profile: gr.OAuthProfile | None) -> str:
|
| 34 |
+
if profile is None:
|
| 35 |
+
return ""
|
| 36 |
+
return profile.username
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def get_vote_models(category):
|
| 40 |
+
if not category:
|
| 41 |
+
return []
|
| 42 |
+
|
| 43 |
+
url_with_params = f"{get_models_url}?category={category}"
|
| 44 |
+
|
| 45 |
+
response = requests.get(url_with_params)
|
| 46 |
+
|
| 47 |
+
if response.status_code == 200:
|
| 48 |
+
models_data = response.json()
|
| 49 |
+
return gr.CheckboxGroup(choices=models_data, label="Choose your options", interactive=True)
|
| 50 |
+
else:
|
| 51 |
+
print(f"Failed to get models: {response.text}")
|
| 52 |
+
return []
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def submit_vote(username, category, models):
|
| 56 |
+
if not category or not models:
|
| 57 |
+
return "All fields are required!"
|
| 58 |
+
if not username:
|
| 59 |
+
return "You need to log in to submit a vote."
|
| 60 |
+
if username.startswith("Hello "):
|
| 61 |
+
username = username[6:]
|
| 62 |
+
|
| 63 |
+
data = {
|
| 64 |
+
"category": category,
|
| 65 |
+
"username": username,
|
| 66 |
+
"model_ids": models
|
| 67 |
}
|
| 68 |
|
| 69 |
+
response = requests.post(vote_url, json=data)
|
| 70 |
+
|
| 71 |
+
if response.status_code == 200:
|
| 72 |
+
return f"Vote '{models}' submitted successfully!"
|
| 73 |
+
else:
|
| 74 |
+
return f"Failed to vote: {response.text}"
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
def submit_model(category, model_id):
|
| 78 |
if not category or not model_id:
|
| 79 |
return "All fields are required!"
|
| 80 |
|
|
|
|
|
|
|
| 81 |
data = {
|
| 82 |
+
"model_id": model_id,
|
| 83 |
+
"categories": [category]
|
| 84 |
}
|
| 85 |
|
| 86 |
+
response = requests.post(submit_models_url, json=data)
|
| 87 |
|
| 88 |
if response.status_code == 200:
|
| 89 |
return "Your request has been submitted successfully. We will notify you by email once processing is complete."
|
|
|
|
| 91 |
return f"Failed to submit request: {response.text}"
|
| 92 |
|
| 93 |
|
| 94 |
+
theme = gr.themes.Soft()
|
| 95 |
+
|
| 96 |
+
with gr.Blocks(theme=theme) as app:
|
| 97 |
with gr.Tabs():
|
| 98 |
with gr.TabItem("Table"):
|
| 99 |
category = gr.Dropdown(
|
| 100 |
+
choices=["all", "Biology", "Physics", "Business", "Chemistry", "Economics", "Philosophy", "History", "Culture", "Computer Science", "Math", "Health", "Law", "Engineering", "Other"],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
label="Select Category",
|
| 102 |
+
value="all"
|
| 103 |
)
|
| 104 |
|
| 105 |
+
initial_data = update_table("all")
|
| 106 |
table = gr.Dataframe(
|
| 107 |
+
headers=["Model", "Votes", "Categories"],
|
| 108 |
+
datatype=["str", "number", "str"],
|
| 109 |
value=initial_data,
|
| 110 |
+
col_count=(3, "fixed"),
|
| 111 |
)
|
| 112 |
category.change(update_table, inputs=category, outputs=table)
|
| 113 |
|
| 114 |
with gr.TabItem("Vote"):
|
| 115 |
+
username_text = gr.State(value="")
|
| 116 |
+
login_button = gr.LoginButton()
|
| 117 |
+
app.load(get_user, inputs=None, outputs=username_text)
|
| 118 |
+
|
| 119 |
category = gr.Dropdown(
|
| 120 |
+
choices=["Biology", "Physics", "Business", "Chemistry", "Economics", "Philosophy", "History", "Culture", "Computer Science", "Math", "Health", "Law", "Engineering", "Other"],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
label="Select Category"
|
| 122 |
)
|
| 123 |
+
|
| 124 |
+
cbg = gr.CheckboxGroup(choices=[], label="Choose your options",interactive=True)
|
| 125 |
submit_button = gr.Button("Submit Vote")
|
| 126 |
+
submit_result = gr.Markdown()
|
| 127 |
+
|
| 128 |
+
category.change(get_vote_models, inputs=category, outputs=cbg)
|
| 129 |
+
|
| 130 |
+
submit_button.click(fn=submit_vote, inputs=[username_text, category, cbg], outputs=submit_result)
|
| 131 |
+
|
| 132 |
|
| 133 |
with gr.TabItem("Submit Model"):
|
| 134 |
+
category = gr.Dropdown(choices=["Biology", "Physics", "Business", "Chemistry", "Economics", "Philosophy", "History", "Culture", "Computer Science", "Math", "Health", "Law", "Engineering", "Other"], label="Select Category")
|
| 135 |
+
model_id = HuggingfaceHubSearch(label="Hub Model ID", placeholder="Search for model id on Huggingface", search_type="model")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
submit_model_button = gr.Button("Submit Model")
|
| 137 |
+
submit_model_result = gr.Markdown()
|
| 138 |
submit_model_button.click(fn=submit_model, inputs=[category, model_id], outputs=submit_model_result)
|
| 139 |
|
| 140 |
+
app.launch(share=True)
|
requirements.txt
CHANGED
|
@@ -1,3 +1,5 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
gradio_huggingfacehub_search
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
motor
|
| 3 |
+
gradio_huggingfacehub_search
|
| 4 |
+
pandas
|
| 5 |
+
requests
|