Spaces:
Runtime error
Runtime error
File size: 3,089 Bytes
ad25c15 ded31ce adabf5e 8c8e152 ded31ce ad25c15 ded31ce ad25c15 ded31ce ad25c15 ded31ce adabf5e ded31ce ad25c15 ded31ce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
import gradio as gr
import pandas as pd
import numpy as np
# ๋ฐ์ดํฐ ์ ์ (ํ๋์ฝ๋ฉ)
data = {
"Company/Model": [
"Anthropic/Claude 3 Opus",
"OpenAI/GPT-4",
"Google/Gemini Ultra",
"Cohere/Command R+",
"Naver/HyperCLOVA X",
"Kakao/KoGPT"
],
"URL": [
"https://www.anthropic.com/claude",
"https://openai.com/gpt-4",
"https://deepmind.google/technologies/gemini/",
"https://cohere.com/models/command-r-plus",
"https://clova.ai/hyperclova",
"https://kogpt.ai/"
],
"Korean Bar Exam (๋ณํธ์ฌ)": [85, 82, 80, 75, 79, 77],
"Senior Civil Service Examination (๊ตญ๊ฐ์ง 5๊ธ)": [88, 84, 83, 76, 81, 78]
}
# DataFrame ์์ฑ
df = pd.DataFrame(data)
# Average ์ ์ ๊ณ์ฐ
exam_columns = ["Korean Bar Exam (๋ณํธ์ฌ)", "Senior Civil Service Examination (๊ตญ๊ฐ์ง 5๊ธ)"]
df["Average"] = df[exam_columns].mean(axis=1).round(1)
# ์ด ์์ ์ฌ๋ฐฐ์น (Company/Model, URL, Average, ๊ทธ ๋ค์ ๊ฐ ์ํ)
cols = ["Company/Model", "URL", "Average"] + exam_columns
df = df[cols]
# HTML๋ก ๋ ๋๋งํ๊ธฐ ์ํ ํจ์ (URL์ ํด๋ฆญ ๊ฐ๋ฅํ ๋งํฌ๋ก ๋ณํ)
def format_df_as_html(df):
# DataFrame ๋ณต์ฌ๋ณธ ์์ฑ
display_df = df.copy()
# URL ์ด์ ํด๋ฆญ ๊ฐ๋ฅํ ๋งํฌ๋ก ๋ณํ
for i, url in enumerate(display_df["URL"]):
model_name = display_df.iloc[i]["Company/Model"]
display_df.at[i, "Company/Model"] = f'<a href="{url}" target="_blank">{model_name}</a>'
# URL ์ด ์ ๊ฑฐ (์ด๋ฏธ Company/Model์ ๋งํฌ๋ก ํตํฉ)
display_df = display_df.drop("URL", axis=1)
# ํ ์คํ์ผ ์ถ๊ฐ
styled_html = """
<style>
table {
width: 100%;
border-collapse: collapse;
font-family: Arial, sans-serif;
}
th {
background-color: #4CAF50;
color: white;
font-weight: bold;
text-align: left;
padding: 12px;
}
td {
padding: 10px;
border-bottom: 1px solid #ddd;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #ddd;
}
.header {
text-align: center;
font-size: 24px;
font-weight: bold;
margin-bottom: 20px;
color: #333;
}
</style>
<div class="header">Korean Exam Leaderboard</div>
"""
# DataFrame์ HTML๋ก ๋ณํํ๊ณ ์คํ์ผ ์ ์ฉ
html_table = display_df.to_html(index=False, escape=False)
return styled_html + html_table
# Gradio ์ธํฐํ์ด์ค
def show_leaderboard():
html_content = format_df_as_html(df)
return html_content
# ์ธํฐํ์ด์ค ์์ฑ
demo = gr.Interface(
fn=show_leaderboard,
inputs=None,
outputs=gr.HTML(),
title="Korean Exam Leaderboard",
description="์ฑ๋ฅ ๋น๊ต: ํ๊ตญ ๋ฒํ ๋ฐ ํ์ ๊ณ ์ ์ํ์์์ AI ๋ชจ๋ธ ์ ์"
)
# ์ฑ ์คํ
if __name__ == "__main__":
demo.launch() |