Alina Lozovskaya commited on
Commit
d50990e
ยท
1 Parent(s): 089a447

Better login and description

Browse files
Files changed (1) hide show
  1. 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
- A Dynamic Benchmark Generation Framework
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
- [๐Ÿ“– Github Page](https://github.com/huggingface/yourbench/tree/v0.2-alpha-space)
 
 
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
- login_btn = gr.LoginButton()
97
-
98
- with gr.Tab("Setup"):
99
- with gr.Row():
100
- with gr.Accordion("Hugging Face Settings"):
101
- hf_org_dropdown = gr.Dropdown(
102
- choices=[], label="Organization", allow_custom_value=True
103
- )
104
- app.load(update_hf_org_dropdown, inputs=None, outputs=hf_org_dropdown)
105
-
106
- hf_dataset_prefix = gr.Textbox(
107
- label="Dataset Prefix",
108
- value="yourbench",
109
- info="Prefix applied to all datasets",
110
- )
111
-
112
- with gr.Accordion("Upload documents"):
113
- file_input = gr.File(
114
- label="Upload text files",
115
- file_count="multiple",
116
- file_types=[".txt", ".md", ".html"],
117
- )
118
- output = gr.Textbox(label="Log")
119
- file_input.upload(
120
- lambda files: save_files([file.name for file in files]),
121
- file_input,
122
- output,
123
- )
124
-
125
- preview_button = gr.Button("Generate New Config", interactive=False)
126
- log_message = gr.Textbox(label="Log Message", visible=True)
127
- download_button = gr.File(
128
- label="Download Config", visible=False, interactive=False
129
- )
130
-
131
- file_input.change(enable_button, inputs=file_input, outputs=preview_button)
132
-
133
- preview_button.click(
134
- generate_and_return,
135
- inputs=[hf_org_dropdown, hf_dataset_prefix],
136
- outputs=[log_message, download_button],
137
- )
138
-
139
- with gr.Tab("Run Generation"):
140
- with gr.Row():
141
- with gr.Accordion("Log Output", open=True):
142
- log_output = gr.Code(language=None, lines=20, interactive=False)
143
-
144
- with gr.Accordion("Stages", open=True):
145
- stages_table = gr.CheckboxGroup(
146
- choices=STAGES,
147
- value=[],
148
- label="Pipeline Stages Completed",
149
- interactive=False,
150
- )
151
-
152
- log_timer = gr.Timer(1.0, active=True)
153
- log_timer.tick(manager.read_and_get_output, outputs=[log_output, stages_table])
154
-
155
- with gr.Row():
156
- process_status = gr.Checkbox(label="Process Status", interactive=False)
157
- status_timer = gr.Timer(1.0, active=True)
158
- status_timer.tick(manager.is_running, outputs=process_status)
159
-
160
- with gr.Row():
161
- start_button = gr.Button("Start Task")
162
- start_button.click(prepare_task, inputs=[login_btn, hf_dataset_prefix])
163
-
164
- stop_button = gr.Button("Stop Task")
165
- stop_button.click(manager.stop_process)
166
-
167
- kill_button = gr.Button("Kill Task")
168
- kill_button.click(manager.kill_process)
 
 
 
 
 
 
 
 
 
 
 
 
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)