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()