Spaces:
Sleeping
Sleeping
Blair Yang
commited on
Commit
•
de1d92a
1
Parent(s):
07a63f0
Bugs?
Browse files- __pycache__/Sample.cpython-311.pyc +0 -0
- app.py +40 -45
__pycache__/Sample.cpython-311.pyc
CHANGED
Binary files a/__pycache__/Sample.cpython-311.pyc and b/__pycache__/Sample.cpython-311.pyc differ
|
|
app.py
CHANGED
@@ -1,60 +1,55 @@
|
|
1 |
import gradio as gr
|
2 |
-
from Sample import
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
def evaluate_guess(reasoning, correctness, confidence):
|
18 |
-
|
19 |
-
#
|
20 |
-
#
|
21 |
-
correct_answer = "Correctly"
|
22 |
evaluation_response = "Correct" if correctness == correct_answer else "Incorrect"
|
23 |
-
|
24 |
-
actual_model = info_dict['model']
|
25 |
-
actual_completion = info_dict['completion']
|
26 |
|
27 |
-
#
|
28 |
-
|
29 |
-
|
30 |
-
# Return the evaluation response and the completion text to update the interface
|
31 |
-
return evaluation_response, model, completion_text
|
32 |
|
|
|
|
|
|
|
33 |
|
34 |
-
|
35 |
-
|
|
|
36 |
|
37 |
with gr.Blocks() as app:
|
|
|
38 |
with gr.Row():
|
39 |
-
with gr.Column(scale=2):
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
completion = gr.Textbox(value="", label="Model's Completion", interactive=False)
|
44 |
-
|
45 |
with gr.Column(scale=1):
|
46 |
-
# Display the sampled question in a Textbox
|
47 |
question = gr.Textbox(value=question_text, label="Question", interactive=False)
|
48 |
reasoning = gr.Textbox(lines=5, placeholder="Your reasoning (optional)")
|
49 |
correctness = gr.Radio(choices=["Correct", "Incorrect"], label="I believe the model will answer this question")
|
50 |
confidence = gr.Slider(minimum=0, maximum=10, step=1, label="Confidence")
|
51 |
-
output_text = gr.Text(label="Evaluation Output")
|
52 |
submit_button = gr.Button("Submit")
|
|
|
|
|
|
|
|
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
# When the button is clicked, it will update the content of the completion textbox
|
58 |
-
submit_button.click(fn=evaluate_guess, inputs=[reasoning, correctness, confidence], outputs=[output_text, model, completion])
|
59 |
-
|
60 |
-
app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from Sample import sample_random_entry
|
3 |
+
from Config import TOPICS
|
4 |
+
|
5 |
+
info_dict = {}
|
6 |
+
|
7 |
+
def sample_and_display(topic):
|
8 |
+
# If a topic is selected, use it to sample a new entry
|
9 |
+
global info_dict
|
10 |
+
display_dict, info_dict = sample_random_entry(topic=topic) if topic else sample_random_entry()
|
11 |
+
question_text = display_dict['qa']
|
12 |
+
evaluation_card_text = display_dict['card']
|
13 |
+
model_name = '' # Clear the model name
|
14 |
+
completion_text = '' # Clear the completion text
|
15 |
+
return question_text, evaluation_card_text, model_name, completion_text
|
16 |
+
|
17 |
+
def evaluate_guess(reasoning, correctness, confidence, topic):
|
18 |
+
global info_dict
|
19 |
+
# Here your logic will go to evaluate the guess
|
20 |
+
# Placeholder for the correct logic to determine the correct answer
|
21 |
+
correct_answer = "Correctly"
|
22 |
evaluation_response = "Correct" if correctness == correct_answer else "Incorrect"
|
|
|
|
|
|
|
23 |
|
24 |
+
# Assuming info_dict is updated by sample_and_display function
|
25 |
+
actual_model = info_dict.get('model', 'Unknown Model')
|
26 |
+
actual_completion = info_dict.get('completion', 'No completion available.')
|
|
|
|
|
27 |
|
28 |
+
# Update the completion text
|
29 |
+
completion_text = f"Completion: {actual_completion}\n\nChoice: {chr(info_dict.get('verdict', 0) + 65)}"
|
30 |
+
return evaluation_response, actual_model, completion_text
|
31 |
|
32 |
+
# Initial sampling
|
33 |
+
initial_topic = TOPICS['mmlu'][0] # Assuming TOPICS is a list of topics
|
34 |
+
question_text, evaluation_card_text, model_name, completion_text = sample_and_display(initial_topic)
|
35 |
|
36 |
with gr.Blocks() as app:
|
37 |
+
topic = gr.Dropdown(choices=TOPICS['mmlu'], label="Select Topic", value=initial_topic)
|
38 |
with gr.Row():
|
39 |
+
with gr.Column(scale=2):
|
40 |
+
evaluation_card = gr.Textbox(value=evaluation_card_text, label="Evaluation Card", interactive=False)
|
41 |
+
model = gr.Textbox(value=model_name, label="Model", interactive=False)
|
42 |
+
completion = gr.Textbox(value=completion_text, label="Model's Completion", interactive=False)
|
|
|
|
|
43 |
with gr.Column(scale=1):
|
|
|
44 |
question = gr.Textbox(value=question_text, label="Question", interactive=False)
|
45 |
reasoning = gr.Textbox(lines=5, placeholder="Your reasoning (optional)")
|
46 |
correctness = gr.Radio(choices=["Correct", "Incorrect"], label="I believe the model will answer this question")
|
47 |
confidence = gr.Slider(minimum=0, maximum=10, step=1, label="Confidence")
|
48 |
+
output_text = gr.Text(label="Evaluation Output")
|
49 |
submit_button = gr.Button("Submit")
|
50 |
+
next_button = gr.Button("Next Entry")
|
51 |
+
|
52 |
+
submit_button.click(fn=evaluate_guess, inputs=[reasoning, correctness, confidence, topic], outputs=[output_text, model, completion])
|
53 |
+
next_button.click(fn=sample_and_display, inputs=[topic], outputs=[question, evaluation_card, model, completion])
|
54 |
|
55 |
+
app.launch()
|
|
|
|
|
|
|
|
|
|
|
|