Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
46a7ad8
1
Parent(s):
ba45294
update
Browse files
app.py
CHANGED
@@ -223,7 +223,7 @@ custom_css = """
|
|
223 |
}
|
224 |
"""
|
225 |
|
226 |
-
# Create the Gradio interface
|
227 |
with gr.Blocks(
|
228 |
theme=gr.themes.Monochrome(
|
229 |
primary_hue="indigo",
|
@@ -233,20 +233,20 @@ with gr.Blocks(
|
|
233 |
css=custom_css
|
234 |
) as demo:
|
235 |
|
236 |
-
# Define
|
237 |
temperature = gr.State(value=0.3)
|
238 |
top_p = gr.State(value=0.95)
|
239 |
max_tokens = gr.State(value=2)
|
240 |
|
241 |
-
# Main container
|
242 |
-
with gr.
|
243 |
# Header
|
244 |
-
with gr.
|
245 |
gr.Markdown(
|
246 |
"""
|
247 |
# TinyV - Answer Verification Tool
|
248 |
|
249 |
-
Verify if model-generated answers are correct compared to ground truth
|
250 |
"""
|
251 |
)
|
252 |
|
@@ -254,13 +254,14 @@ with gr.Blocks(
|
|
254 |
with gr.Row(equal_height=True):
|
255 |
# Left column - Inputs
|
256 |
with gr.Column(scale=3):
|
257 |
-
|
|
|
258 |
gr.Markdown("### Input", elem_classes="label")
|
259 |
|
260 |
question = gr.Textbox(
|
261 |
lines=3,
|
262 |
label="Question",
|
263 |
-
placeholder="Enter the problem or question here...",
|
264 |
elem_classes="input-field"
|
265 |
)
|
266 |
|
@@ -285,7 +286,7 @@ with gr.Blocks(
|
|
285 |
|
286 |
# Right column - Result
|
287 |
with gr.Column(scale=2):
|
288 |
-
with gr.
|
289 |
gr.Markdown("### Verification Result", elem_classes="label")
|
290 |
result = gr.Textbox(
|
291 |
placeholder="The verification result will appear here...",
|
@@ -295,26 +296,27 @@ with gr.Blocks(
|
|
295 |
|
296 |
# Examples section
|
297 |
gr.Markdown("### Examples", elem_classes="label")
|
298 |
-
with gr.
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
|
|
311 |
|
312 |
# Advanced Settings in accordion
|
313 |
with gr.Accordion("Advanced Settings", open=False, elem_classes="accordions-container"):
|
314 |
with gr.Row():
|
315 |
temp_slider = gr.Slider(0, 1, value=0.3, step=0.1, label="Temperature")
|
316 |
top_p_slider = gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
|
317 |
-
max_tokens_slider = gr.Slider(1, 128, value=
|
318 |
|
319 |
# Connect sliders to state values
|
320 |
temp_slider.change(lambda x: x, inputs=[temp_slider], outputs=[temperature])
|
@@ -335,7 +337,7 @@ with gr.Blocks(
|
|
335 |
model_answer="Paris is the capital of France.",
|
336 |
temperature=0.3,
|
337 |
top_p=0.95,
|
338 |
-
max_tokens=
|
339 |
api_name="/verify_answer"
|
340 |
)
|
341 |
print(result)
|
@@ -346,7 +348,7 @@ with gr.Blocks(
|
|
346 |
# Footer
|
347 |
gr.Markdown(
|
348 |
"""
|
349 |
-
Powered by TinyV-1.5B model. This tool verifies semantic equivalence between answers.
|
350 |
""",
|
351 |
elem_classes="footer"
|
352 |
)
|
|
|
223 |
}
|
224 |
"""
|
225 |
|
226 |
+
# Create the Gradio interface with proper component initialization
|
227 |
with gr.Blocks(
|
228 |
theme=gr.themes.Monochrome(
|
229 |
primary_hue="indigo",
|
|
|
233 |
css=custom_css
|
234 |
) as demo:
|
235 |
|
236 |
+
# Define states (invisible components to store values)
|
237 |
temperature = gr.State(value=0.3)
|
238 |
top_p = gr.State(value=0.95)
|
239 |
max_tokens = gr.State(value=2)
|
240 |
|
241 |
+
# Main container (using Column with elem_classes instead of Box)
|
242 |
+
with gr.Column(elem_classes="main-container"):
|
243 |
# Header
|
244 |
+
with gr.Column(elem_classes="header"):
|
245 |
gr.Markdown(
|
246 |
"""
|
247 |
# TinyV - Answer Verification Tool
|
248 |
|
249 |
+
Verify if model-generated answers are semantically correct compared to ground truth, even with formatting differences
|
250 |
"""
|
251 |
)
|
252 |
|
|
|
254 |
with gr.Row(equal_height=True):
|
255 |
# Left column - Inputs
|
256 |
with gr.Column(scale=3):
|
257 |
+
# Using Column as a panel
|
258 |
+
with gr.Column(elem_classes="panel"):
|
259 |
gr.Markdown("### Input", elem_classes="label")
|
260 |
|
261 |
question = gr.Textbox(
|
262 |
lines=3,
|
263 |
label="Question",
|
264 |
+
placeholder="Enter the mathematical problem or question here...",
|
265 |
elem_classes="input-field"
|
266 |
)
|
267 |
|
|
|
286 |
|
287 |
# Right column - Result
|
288 |
with gr.Column(scale=2):
|
289 |
+
with gr.Column(elem_classes="panel"):
|
290 |
gr.Markdown("### Verification Result", elem_classes="label")
|
291 |
result = gr.Textbox(
|
292 |
placeholder="The verification result will appear here...",
|
|
|
296 |
|
297 |
# Examples section
|
298 |
gr.Markdown("### Examples", elem_classes="label")
|
299 |
+
with gr.Column(elem_classes="examples-container"):
|
300 |
+
with gr.Row():
|
301 |
+
for i, ex in enumerate(EXAMPLES):
|
302 |
+
btn = gr.Button(ex["name"], elem_classes="example-btn")
|
303 |
+
btn.click(
|
304 |
+
fn=lambda idx=i: load_example(idx),
|
305 |
+
outputs=[question, ground_truth, model_answer, temperature, top_p, max_tokens]
|
306 |
+
)
|
307 |
+
# Also run verification when example is loaded
|
308 |
+
btn.click(
|
309 |
+
fn=verify_answer,
|
310 |
+
inputs=[question, ground_truth, model_answer, temperature, top_p, max_tokens],
|
311 |
+
outputs=result
|
312 |
+
)
|
313 |
|
314 |
# Advanced Settings in accordion
|
315 |
with gr.Accordion("Advanced Settings", open=False, elem_classes="accordions-container"):
|
316 |
with gr.Row():
|
317 |
temp_slider = gr.Slider(0, 1, value=0.3, step=0.1, label="Temperature")
|
318 |
top_p_slider = gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
|
319 |
+
max_tokens_slider = gr.Slider(1, 128, value=2, step=1, label="Max Tokens")
|
320 |
|
321 |
# Connect sliders to state values
|
322 |
temp_slider.change(lambda x: x, inputs=[temp_slider], outputs=[temperature])
|
|
|
337 |
model_answer="Paris is the capital of France.",
|
338 |
temperature=0.3,
|
339 |
top_p=0.95,
|
340 |
+
max_tokens=2,
|
341 |
api_name="/verify_answer"
|
342 |
)
|
343 |
print(result)
|
|
|
348 |
# Footer
|
349 |
gr.Markdown(
|
350 |
"""
|
351 |
+
Powered by TinyV-1.5B model. This tool verifies semantic equivalence between answers, allowing for different formatting, ordering, notation, and phrasing.
|
352 |
""",
|
353 |
elem_classes="footer"
|
354 |
)
|