Spaces:
Sleeping
Sleeping
Create modules/ui_components.py
Browse files- modules/ui_components.py +99 -0
modules/ui_components.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# CSS styling for the application
|
4 |
+
CSS = """
|
5 |
+
#preview_header {
|
6 |
+
margin-bottom: 10px;
|
7 |
+
margin-top: 5px;
|
8 |
+
}
|
9 |
+
#preview_table {
|
10 |
+
background-color: #f8f9fa;
|
11 |
+
border-radius: 8px;
|
12 |
+
padding: 10px;
|
13 |
+
}
|
14 |
+
h1 {
|
15 |
+
text-align: center;
|
16 |
+
}
|
17 |
+
.section-divider {
|
18 |
+
border-top: 1px solid #ddd;
|
19 |
+
margin: 12px 0;
|
20 |
+
}
|
21 |
+
.config-box {
|
22 |
+
border: 1px solid #ddd;
|
23 |
+
border-radius: 8px;
|
24 |
+
padding: 15px;
|
25 |
+
margin: 10px;
|
26 |
+
background-color: #f9f9f9;
|
27 |
+
}
|
28 |
+
.center-divider {
|
29 |
+
display: flex;
|
30 |
+
justify-content: center;
|
31 |
+
height: 100%;
|
32 |
+
}
|
33 |
+
.error-message {
|
34 |
+
color: #d32f2f;
|
35 |
+
background-color: #ffebee;
|
36 |
+
padding: 10px;
|
37 |
+
border-radius: 4px;
|
38 |
+
margin: 10px 0;
|
39 |
+
}
|
40 |
+
"""
|
41 |
+
|
42 |
+
def create_header():
|
43 |
+
"""
|
44 |
+
Creates the main application header.
|
45 |
+
|
46 |
+
Returns:
|
47 |
+
list: List of header components.
|
48 |
+
"""
|
49 |
+
title = gr.Markdown("# Head-to-Head Model Evaluation Comparator")
|
50 |
+
description = gr.Markdown("""
|
51 |
+
This demo evaluates two models (or one model with two different configs), head-to-head, on a benchmark dataset.
|
52 |
+
|
53 |
+
Available Datasets: [MMLU-Pro](https://huggingface.co/datasets/TIGER-Lab/MMLU-Pro)
|
54 |
+
""")
|
55 |
+
|
56 |
+
return [title, description]
|
57 |
+
|
58 |
+
def create_results_section():
|
59 |
+
"""
|
60 |
+
Creates the results section of the UI.
|
61 |
+
|
62 |
+
Returns:
|
63 |
+
dict: Dictionary containing results components.
|
64 |
+
"""
|
65 |
+
with gr.Column(visible=False) as results_container:
|
66 |
+
results_output = gr.Markdown(label="Evaluation Results")
|
67 |
+
|
68 |
+
# Results table - Initially hidden until evaluation completes
|
69 |
+
with gr.Column(visible=False) as results_table_container:
|
70 |
+
with gr.Row():
|
71 |
+
results_table = gr.DataFrame(
|
72 |
+
interactive=True,
|
73 |
+
label="Detailed Results (Sortable)",
|
74 |
+
visible=True
|
75 |
+
)
|
76 |
+
|
77 |
+
return {
|
78 |
+
'container': results_container,
|
79 |
+
'output': results_output,
|
80 |
+
'table_container': results_table_container,
|
81 |
+
'table': results_table
|
82 |
+
}
|
83 |
+
|
84 |
+
def create_action_buttons():
|
85 |
+
"""
|
86 |
+
Creates the action buttons for evaluation.
|
87 |
+
|
88 |
+
Returns:
|
89 |
+
dict: Dictionary containing button components.
|
90 |
+
"""
|
91 |
+
with gr.Row():
|
92 |
+
with gr.Column(scale=1):
|
93 |
+
eval_button = gr.Button("Run MMLU-Pro Evaluation", variant="primary", interactive=False)
|
94 |
+
cancel_button = gr.Button("Cancel Evaluation", variant="stop", visible=False)
|
95 |
+
|
96 |
+
return {
|
97 |
+
'eval_button': eval_button,
|
98 |
+
'cancel_button': cancel_button
|
99 |
+
}
|