Update app.py
Browse files
app.py
CHANGED
|
@@ -1,204 +1,124 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
| 3 |
import pandas as pd
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
from
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
)
|
| 27 |
-
from
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
)
|
| 90 |
|
|
|
|
| 91 |
|
| 92 |
-
demo
|
| 93 |
-
with demo:
|
| 94 |
-
gr.HTML(TITLE)
|
| 95 |
-
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
| 96 |
-
|
| 97 |
-
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
| 98 |
-
with gr.TabItem("🏅 LLM Benchmark", elem_id="llm-benchmark-tab-table", id=0):
|
| 99 |
-
leaderboard = init_leaderboard(LEADERBOARD_DF)
|
| 100 |
-
|
| 101 |
-
with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
|
| 102 |
-
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
| 103 |
-
|
| 104 |
-
with gr.TabItem("🚀 Submit here! ", elem_id="llm-benchmark-tab-table", id=3):
|
| 105 |
-
with gr.Column():
|
| 106 |
-
with gr.Row():
|
| 107 |
-
gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
|
| 108 |
-
|
| 109 |
-
with gr.Column():
|
| 110 |
-
with gr.Accordion(
|
| 111 |
-
f"✅ Finished Evaluations ({len(finished_eval_queue_df)})",
|
| 112 |
-
open=False,
|
| 113 |
-
):
|
| 114 |
-
with gr.Row():
|
| 115 |
-
finished_eval_table = gr.components.Dataframe(
|
| 116 |
-
value=finished_eval_queue_df,
|
| 117 |
-
headers=EVAL_COLS,
|
| 118 |
-
datatype=EVAL_TYPES,
|
| 119 |
-
row_count=5,
|
| 120 |
-
)
|
| 121 |
-
with gr.Accordion(
|
| 122 |
-
f"🔄 Running Evaluation Queue ({len(running_eval_queue_df)})",
|
| 123 |
-
open=False,
|
| 124 |
-
):
|
| 125 |
-
with gr.Row():
|
| 126 |
-
running_eval_table = gr.components.Dataframe(
|
| 127 |
-
value=running_eval_queue_df,
|
| 128 |
-
headers=EVAL_COLS,
|
| 129 |
-
datatype=EVAL_TYPES,
|
| 130 |
-
row_count=5,
|
| 131 |
-
)
|
| 132 |
-
|
| 133 |
-
with gr.Accordion(
|
| 134 |
-
f"⏳ Pending Evaluation Queue ({len(pending_eval_queue_df)})",
|
| 135 |
-
open=False,
|
| 136 |
-
):
|
| 137 |
-
with gr.Row():
|
| 138 |
-
pending_eval_table = gr.components.Dataframe(
|
| 139 |
-
value=pending_eval_queue_df,
|
| 140 |
-
headers=EVAL_COLS,
|
| 141 |
-
datatype=EVAL_TYPES,
|
| 142 |
-
row_count=5,
|
| 143 |
-
)
|
| 144 |
-
with gr.Row():
|
| 145 |
-
gr.Markdown("# ✉️✨ Submit your model here!", elem_classes="markdown-text")
|
| 146 |
-
|
| 147 |
-
with gr.Row():
|
| 148 |
-
with gr.Column():
|
| 149 |
-
model_name_textbox = gr.Textbox(label="Model name")
|
| 150 |
-
revision_name_textbox = gr.Textbox(label="Revision commit", placeholder="main")
|
| 151 |
-
model_type = gr.Dropdown(
|
| 152 |
-
choices=[t.to_str(" : ") for t in ModelType if t != ModelType.Unknown],
|
| 153 |
-
label="Model type",
|
| 154 |
-
multiselect=False,
|
| 155 |
-
value=None,
|
| 156 |
-
interactive=True,
|
| 157 |
-
)
|
| 158 |
-
|
| 159 |
-
with gr.Column():
|
| 160 |
-
precision = gr.Dropdown(
|
| 161 |
-
choices=[i.value.name for i in Precision if i != Precision.Unknown],
|
| 162 |
-
label="Precision",
|
| 163 |
-
multiselect=False,
|
| 164 |
-
value="float16",
|
| 165 |
-
interactive=True,
|
| 166 |
-
)
|
| 167 |
-
weight_type = gr.Dropdown(
|
| 168 |
-
choices=[i.value.name for i in WeightType],
|
| 169 |
-
label="Weights type",
|
| 170 |
-
multiselect=False,
|
| 171 |
-
value="Original",
|
| 172 |
-
interactive=True,
|
| 173 |
-
)
|
| 174 |
-
base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
|
| 175 |
-
|
| 176 |
-
submit_button = gr.Button("Submit Eval")
|
| 177 |
-
submission_result = gr.Markdown()
|
| 178 |
-
submit_button.click(
|
| 179 |
-
add_new_eval,
|
| 180 |
-
[
|
| 181 |
-
model_name_textbox,
|
| 182 |
-
base_model_name_textbox,
|
| 183 |
-
revision_name_textbox,
|
| 184 |
-
precision,
|
| 185 |
-
weight_type,
|
| 186 |
-
model_type,
|
| 187 |
-
],
|
| 188 |
-
submission_result,
|
| 189 |
-
)
|
| 190 |
-
|
| 191 |
-
with gr.Row():
|
| 192 |
-
with gr.Accordion("📙 Citation", open=False):
|
| 193 |
-
citation_button = gr.Textbox(
|
| 194 |
-
value=CITATION_BUTTON_TEXT,
|
| 195 |
-
label=CITATION_BUTTON_LABEL,
|
| 196 |
-
lines=20,
|
| 197 |
-
elem_id="citation-button",
|
| 198 |
-
show_copy_button=True,
|
| 199 |
-
)
|
| 200 |
-
|
| 201 |
-
scheduler = BackgroundScheduler()
|
| 202 |
-
scheduler.add_job(restart_space, "interval", seconds=1800)
|
| 203 |
-
scheduler.start()
|
| 204 |
-
demo.queue(default_concurrency_limit=40).launch()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
+
import os
|
| 4 |
+
import shutil
|
| 5 |
+
|
| 6 |
+
# Description and Introduction texts
|
| 7 |
+
DESCRIPTION = """
|
| 8 |
+
Independent performance benchmark of LLMs with various Inference Engines. Definitions are below the table.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
INTRODUCTION = """
|
| 12 |
+
**Introduction**
|
| 13 |
+
In our ongoing quest to help developers find the right libraries and LLMs for their use cases.
|
| 14 |
+
|
| 15 |
+
We tested them across six different inference engines (vLLM, TGI, TensorRT-LLM, Tritonvllm, Deepspeed-mii, ctranslate) on A100 GPUs hosted on Azure, ensuring a neutral playing field separate from our Inferless platform.
|
| 16 |
+
The goal?
|
| 17 |
+
To help developers, researchers, and AI enthusiasts pinpoint the best LLMs for their needs, whether for development or production.
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
HOW_WE_TESTED = """
|
| 21 |
+
**How we tested?**
|
| 22 |
+
Here's how we ensured consistent, reliable benchmarks:
|
| 23 |
+
* **Platform:** All tests ran on A100 GPUs from Azure, providing a level playing field.
|
| 24 |
+
* **Setup:** Docker containers for each library ensured a consistent environment.
|
| 25 |
+
* **Configuration:** Standard settings (temperature 0.5, top_p 1) kept the focus on performance, not external variables.
|
| 26 |
+
* **Prompts & Token Ranges:** We used six distinct prompts with input lengths from 20 to 2,000 tokens and tested generation lengths of 100, 200, and 500 tokens to evaluate each library's flexibility.
|
| 27 |
+
* **Models & Libraries Tested:** We evaluated Phi-3-medium-128k-instruct, Meta-Llama-3.1-8B-Instruct, Mistral-7B-Instruct-v0.3, Qwen2-7B-Instruct, and Gemma-2-9b-it using Text Generation Inference (TGI), vLLM, DeepSpeed Mii, CTranslate2, Triton with vLLM Backend, and TensorRT-LLM.
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
# Replace 'path/to/your/csv/folder' with the actual path to your folder containing CSV files
|
| 31 |
+
csv_folder_path = 'result_csv/'
|
| 32 |
+
|
| 33 |
+
# Function to read all CSV files from a folder and rearrange columns
|
| 34 |
+
def read_and_process_csv_files(folder_path):
|
| 35 |
+
all_data = []
|
| 36 |
+
for filename in os.listdir(folder_path):
|
| 37 |
+
if filename.endswith('.csv'):
|
| 38 |
+
file_path = os.path.join(folder_path, filename)
|
| 39 |
+
df = pd.read_csv(file_path)
|
| 40 |
+
all_data.append(df)
|
| 41 |
+
|
| 42 |
+
combined_df = pd.concat(all_data, ignore_index=True)
|
| 43 |
+
|
| 44 |
+
# Rearrange columns
|
| 45 |
+
columns_order = [
|
| 46 |
+
"Model_Name", "Library", "TTFT", "Tokens-per-Second", "Token_Count",
|
| 47 |
+
"Input_Tokens", "Output_Tokens", "Input", "Output"
|
| 48 |
+
]
|
| 49 |
+
|
| 50 |
+
# Ensure all required columns exist, if not, create them with NaN values
|
| 51 |
+
for col in columns_order:
|
| 52 |
+
if col not in combined_df.columns:
|
| 53 |
+
combined_df[col] = pd.NA
|
| 54 |
+
|
| 55 |
+
# Select and order the columns
|
| 56 |
+
return combined_df[columns_order]
|
| 57 |
+
|
| 58 |
+
df = read_and_process_csv_files(csv_folder_path)
|
| 59 |
+
|
| 60 |
+
def get_leaderboard_df():
|
| 61 |
+
return df
|
| 62 |
+
|
| 63 |
+
def add_new_entry(file):
|
| 64 |
+
global df
|
| 65 |
+
if file is None:
|
| 66 |
+
return df, "No file uploaded."
|
| 67 |
+
|
| 68 |
+
# Read the uploaded CSV file
|
| 69 |
+
new_df = pd.read_csv(file.name)
|
| 70 |
+
|
| 71 |
+
# Rearrange columns to match the existing DataFrame
|
| 72 |
+
columns_order = [
|
| 73 |
+
"Model_Name", "Library", "TTFT", "Tokens-per-Second", "Token_Count",
|
| 74 |
+
"Input_Tokens", "Output_Tokens", "Input", "Output"
|
| 75 |
+
]
|
| 76 |
+
for col in columns_order:
|
| 77 |
+
if col not in new_df.columns:
|
| 78 |
+
new_df[col] = pd.NA
|
| 79 |
+
new_df = new_df[columns_order]
|
| 80 |
+
|
| 81 |
+
# Append the new data to the existing DataFrame
|
| 82 |
+
df = pd.concat([df, new_df], ignore_index=True)
|
| 83 |
+
|
| 84 |
+
# Save the uploaded file to the CSV folder
|
| 85 |
+
filename = os.path.basename(file.name)
|
| 86 |
+
destination = os.path.join(csv_folder_path, filename)
|
| 87 |
+
shutil.copy(file.name, destination)
|
| 88 |
+
|
| 89 |
+
return df, f"File '{filename}' uploaded and data added successfully!"
|
| 90 |
+
|
| 91 |
+
with gr.Blocks() as demo:
|
| 92 |
+
gr.Markdown("# LLM Inference Leaderboard")
|
| 93 |
+
|
| 94 |
+
# About section at the top
|
| 95 |
+
with gr.Column():
|
| 96 |
+
gr.Markdown("---")
|
| 97 |
+
gr.Markdown(DESCRIPTION)
|
| 98 |
+
gr.Markdown(INTRODUCTION)
|
| 99 |
+
gr.Markdown("---")
|
| 100 |
+
|
| 101 |
+
# Tabs for Leaderboard and Add New Entry
|
| 102 |
+
with gr.Tabs():
|
| 103 |
+
with gr.TabItem("Leaderboard"):
|
| 104 |
+
leaderboard = gr.DataFrame(df)
|
| 105 |
+
|
| 106 |
+
with gr.TabItem("Add New Entry"):
|
| 107 |
+
file_upload = gr.File(label="Upload CSV File")
|
| 108 |
+
submit_button = gr.Button("Add Entry")
|
| 109 |
+
result = gr.Markdown()
|
| 110 |
+
|
| 111 |
+
# How we tested section at the bottom
|
| 112 |
+
with gr.Column():
|
| 113 |
+
gr.Markdown("---")
|
| 114 |
+
gr.Markdown(HOW_WE_TESTED)
|
| 115 |
+
|
| 116 |
+
submit_button.click(
|
| 117 |
+
add_new_entry,
|
| 118 |
+
inputs=[file_upload],
|
| 119 |
+
outputs=[leaderboard, result]
|
| 120 |
)
|
| 121 |
|
| 122 |
+
demo.load(get_leaderboard_df, outputs=[leaderboard])
|
| 123 |
|
| 124 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|