Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,14 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
import sys
|
| 3 |
import time
|
| 4 |
import random
|
| 5 |
import yaml
|
| 6 |
import subprocess
|
|
|
|
| 7 |
|
| 8 |
import runpod
|
|
|
|
| 9 |
import gradio as gr
|
| 10 |
import pandas as pd
|
| 11 |
from jinja2 import Template
|
|
@@ -303,6 +306,39 @@ def create_pod(model_name: str, username: str, n=10, wait_seconds=10):
|
|
| 303 |
print("All attempts failed. Giving up.")
|
| 304 |
raise
|
| 305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
def merge_loop():
|
| 307 |
# Start HF API
|
| 308 |
api = HfApi(token=HF_TOKEN)
|
|
@@ -366,11 +402,14 @@ title = """
|
|
| 366 |
<p><em>AutoMerger selects two 7B models on top of the Open LLM Leaderboard, combine them with a merge technique, and evaluate the resulting model.</em></p>
|
| 367 |
</div>
|
| 368 |
"""
|
|
|
|
| 369 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
|
| 370 |
gr.Markdown(title)
|
| 371 |
logs = gr.Textbox(label="Logs")
|
| 372 |
demo.load(read_logs, None, logs, every=1)
|
| 373 |
-
|
|
|
|
|
|
|
| 374 |
|
| 375 |
print("Start AutoMerger...")
|
| 376 |
|
|
|
|
| 1 |
import os
|
| 2 |
+
import re
|
| 3 |
import sys
|
| 4 |
import time
|
| 5 |
import random
|
| 6 |
import yaml
|
| 7 |
import subprocess
|
| 8 |
+
from io import StringIO
|
| 9 |
|
| 10 |
import runpod
|
| 11 |
+
import requests
|
| 12 |
import gradio as gr
|
| 13 |
import pandas as pd
|
| 14 |
from jinja2 import Template
|
|
|
|
| 306 |
print("All attempts failed. Giving up.")
|
| 307 |
raise
|
| 308 |
|
| 309 |
+
|
| 310 |
+
def download_leaderboard():
|
| 311 |
+
url = "https://gist.githubusercontent.com/automerger/84af749b1c0ef7336858df408f46f388/raw"
|
| 312 |
+
file_path = "leaderboard.txt"
|
| 313 |
+
response = requests.get(url)
|
| 314 |
+
return response.content.decode('utf-8')
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
def convert_markdown_table_to_dataframe(md_content):
|
| 318 |
+
"""
|
| 319 |
+
Converts markdown table to Pandas DataFrame.
|
| 320 |
+
"""
|
| 321 |
+
# Remove leading and trailing | characters
|
| 322 |
+
cleaned_content = re.sub(r'\|\s*$', '', re.sub(r'^\|\s*', '', md_content, flags=re.MULTILINE), flags=re.MULTILINE)
|
| 323 |
+
|
| 324 |
+
# Create DataFrame from cleaned content
|
| 325 |
+
df = pd.read_csv(StringIO(cleaned_content), sep="\|", engine='python')
|
| 326 |
+
|
| 327 |
+
# Remove the first row after the header
|
| 328 |
+
df = df.drop(0, axis=0)
|
| 329 |
+
|
| 330 |
+
# Strip whitespace from column names
|
| 331 |
+
df.columns = df.columns.str.strip()
|
| 332 |
+
|
| 333 |
+
return df
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
def get_dataframe():
|
| 337 |
+
content = download_leaderboard()
|
| 338 |
+
df = convert_markdown_table_to_dataframe(content)
|
| 339 |
+
return df
|
| 340 |
+
|
| 341 |
+
|
| 342 |
def merge_loop():
|
| 343 |
# Start HF API
|
| 344 |
api = HfApi(token=HF_TOKEN)
|
|
|
|
| 402 |
<p><em>AutoMerger selects two 7B models on top of the Open LLM Leaderboard, combine them with a merge technique, and evaluate the resulting model.</em></p>
|
| 403 |
</div>
|
| 404 |
"""
|
| 405 |
+
footer = '<div align="center"><p><em>Special thanks to <a href="https://huggingface.co/Weyaxi">Weyaxi</a> for the <a href="https://github.com/Weyaxi/scrape-open-llm-leaderboard">Open LLM Leaderboard Scraper</a> and <a href="https://github.com/cg123">Charles Goddard</a> for <a href="https://github.com/arcee-ai/mergekit">mergekit</a>.</em></p></div>'
|
| 406 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
|
| 407 |
gr.Markdown(title)
|
| 408 |
logs = gr.Textbox(label="Logs")
|
| 409 |
demo.load(read_logs, None, logs, every=1)
|
| 410 |
+
leaderboard = gr.Dataframe(value=get_dataframe, datatype=["markdown", "number", "number", "number", "number", "number"], every=3600)
|
| 411 |
+
gr.Markdown(footer)
|
| 412 |
+
demo.queue().launch(server_name="0.0.0.0", show_error=True, prevent_thread_lock=True)
|
| 413 |
|
| 414 |
print("Start AutoMerger...")
|
| 415 |
|