Spaces:
Sleeping
Sleeping
Alina Lozovskaya
commited on
Commit
ยท
d50990e
1
Parent(s):
089a447
Better login and description
Browse files- yourbench_space/app.py +96 -81
yourbench_space/app.py
CHANGED
@@ -17,15 +17,14 @@ from yourbench_space.utils import (
|
|
17 |
|
18 |
project_description = """
|
19 |
# YourBench ๐
|
20 |
-
|
21 |
-
- Produce diverse, up-to-date questions from real-world source documents
|
22 |
-
- Seamlessly handles ingestion, summarization, and multi-hop chunking for large or specialized datasets
|
23 |
-
- Emulates real-world usage scenarios by creating fresh tasks that guard against memorized knowledge
|
24 |
-
- Out-of-the-box pipeline stages, plus an easy plugin mechanism to accommodate custom models or domain constraints
|
25 |
|
26 |
-
|
|
|
|
|
27 |
"""
|
28 |
|
|
|
29 |
UPLOAD_DIRECTORY.mkdir(parents=True, exist_ok=True)
|
30 |
|
31 |
logger.remove()
|
@@ -41,6 +40,7 @@ citation_content = (
|
|
41 |
else "# Citation\n\nDocumentation file not found."
|
42 |
)
|
43 |
|
|
|
44 |
def generate_and_return(hf_org, hf_prefix):
|
45 |
generate_and_save_config(hf_org, hf_prefix)
|
46 |
for _ in range(5):
|
@@ -84,88 +84,103 @@ def update_hf_org_dropdown(oauth_token: gr.OAuthToken | None):
|
|
84 |
return gr.Dropdown([], label="Organization")
|
85 |
|
86 |
|
|
|
|
|
|
|
|
|
87 |
def enable_button(files):
|
88 |
return gr.update(interactive=bool(files))
|
89 |
|
90 |
|
91 |
-
with gr.Blocks() as app:
|
92 |
gr.Markdown(project_description)
|
93 |
-
gr.Markdown("## YourBench Setup")
|
94 |
|
95 |
with gr.Row():
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
)
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
)
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
with gr.Accordion("๐ Citation", open=False):
|
171 |
gr.Markdown(citation_content)
|
|
|
17 |
|
18 |
project_description = """
|
19 |
# YourBench ๐
|
20 |
+
**Dynamic Benchmark Generation for Language Models**
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
Quickly create zero-shot benchmarks from your documents โย keeping models accurate and adaptable
|
23 |
+
- ๐ [FAQ](#)
|
24 |
+
- ๐ป [GitHub](https://github.com/huggingface/yourbench/tree/v0.2-alpha-space)
|
25 |
"""
|
26 |
|
27 |
+
|
28 |
UPLOAD_DIRECTORY.mkdir(parents=True, exist_ok=True)
|
29 |
|
30 |
logger.remove()
|
|
|
40 |
else "# Citation\n\nDocumentation file not found."
|
41 |
)
|
42 |
|
43 |
+
|
44 |
def generate_and_return(hf_org, hf_prefix):
|
45 |
generate_and_save_config(hf_org, hf_prefix)
|
46 |
for _ in range(5):
|
|
|
84 |
return gr.Dropdown([], label="Organization")
|
85 |
|
86 |
|
87 |
+
def switch_to_run_generation_tab():
|
88 |
+
return gr.Tabs(selected=1)
|
89 |
+
|
90 |
+
|
91 |
def enable_button(files):
|
92 |
return gr.update(interactive=bool(files))
|
93 |
|
94 |
|
95 |
+
with gr.Blocks(theme=gr.themes.Default()) as app:
|
96 |
gr.Markdown(project_description)
|
|
|
97 |
|
98 |
with gr.Row():
|
99 |
+
gr.Markdown("## โ๏ธ YourBench Setup", elem_id="setup-title")
|
100 |
+
with gr.Column(scale=0, min_width=150):
|
101 |
+
login_btn = gr.LoginButton()
|
102 |
+
|
103 |
+
with gr.Tabs() as tabs:
|
104 |
+
with gr.Tab("Setup", id=0):
|
105 |
+
with gr.Row():
|
106 |
+
with gr.Accordion("Hugging Face Settings"):
|
107 |
+
hf_org_dropdown = gr.Dropdown(
|
108 |
+
choices=[], label="Organization", allow_custom_value=True
|
109 |
+
)
|
110 |
+
app.load(
|
111 |
+
update_hf_org_dropdown, inputs=None, outputs=hf_org_dropdown
|
112 |
+
)
|
113 |
+
|
114 |
+
hf_dataset_prefix = gr.Textbox(
|
115 |
+
label="Dataset Prefix",
|
116 |
+
value="yourbench",
|
117 |
+
info="Prefix applied to all datasets",
|
118 |
+
)
|
119 |
+
|
120 |
+
with gr.Accordion("Upload documents"):
|
121 |
+
file_input = gr.File(
|
122 |
+
label="Upload text files",
|
123 |
+
file_count="multiple",
|
124 |
+
file_types=[".txt", ".md", ".html"],
|
125 |
+
)
|
126 |
+
output = gr.Textbox(label="Log")
|
127 |
+
file_input.upload(
|
128 |
+
lambda files: save_files([file.name for file in files]),
|
129 |
+
file_input,
|
130 |
+
output,
|
131 |
+
)
|
132 |
+
|
133 |
+
preview_button = gr.Button("Generate New Config", interactive=False)
|
134 |
+
log_message = gr.Textbox(label="Log Message", visible=True)
|
135 |
+
download_button = gr.File(
|
136 |
+
label="Download Config", visible=False, interactive=False
|
137 |
+
)
|
138 |
+
|
139 |
+
file_input.change(enable_button, inputs=file_input, outputs=preview_button)
|
140 |
+
|
141 |
+
preview_button.click(
|
142 |
+
generate_and_return,
|
143 |
+
inputs=[hf_org_dropdown, hf_dataset_prefix],
|
144 |
+
outputs=[log_message, download_button],
|
145 |
+
)
|
146 |
+
preview_button.click(
|
147 |
+
switch_to_run_generation_tab,
|
148 |
+
inputs=None,
|
149 |
+
outputs=tabs,
|
150 |
+
)
|
151 |
+
|
152 |
+
with gr.Tab("Run Generation", id=1):
|
153 |
+
with gr.Row():
|
154 |
+
with gr.Accordion("Log Output", open=True):
|
155 |
+
log_output = gr.Code(language=None, lines=20, interactive=False)
|
156 |
+
|
157 |
+
with gr.Accordion("Stages", open=True):
|
158 |
+
stages_table = gr.CheckboxGroup(
|
159 |
+
choices=STAGES,
|
160 |
+
value=[],
|
161 |
+
label="Pipeline Stages Completed",
|
162 |
+
interactive=False,
|
163 |
+
)
|
164 |
+
|
165 |
+
log_timer = gr.Timer(1.0, active=True)
|
166 |
+
log_timer.tick(
|
167 |
+
manager.read_and_get_output, outputs=[log_output, stages_table]
|
168 |
+
)
|
169 |
+
|
170 |
+
with gr.Row():
|
171 |
+
process_status = gr.Checkbox(label="Process Status", interactive=False)
|
172 |
+
status_timer = gr.Timer(1.0, active=True)
|
173 |
+
status_timer.tick(manager.is_running, outputs=process_status)
|
174 |
+
|
175 |
+
with gr.Row():
|
176 |
+
start_button = gr.Button("Start Task")
|
177 |
+
start_button.click(prepare_task, inputs=[login_btn, hf_dataset_prefix])
|
178 |
+
|
179 |
+
stop_button = gr.Button("Stop Task")
|
180 |
+
stop_button.click(manager.stop_process)
|
181 |
+
|
182 |
+
kill_button = gr.Button("Kill Task")
|
183 |
+
kill_button.click(manager.kill_process)
|
184 |
|
185 |
with gr.Accordion("๐ Citation", open=False):
|
186 |
gr.Markdown(citation_content)
|