added all models to distractors button click input
Browse files- app.py +11 -1
- config/templates.py +19 -15
app.py
CHANGED
|
@@ -84,6 +84,7 @@ async def run_distractors(
|
|
| 84 |
user_query: str,
|
| 85 |
model_choice_distractors_1: str,
|
| 86 |
model_choice_distractors_2: str,
|
|
|
|
| 87 |
exercise_format_distractors: str,
|
| 88 |
sampling_count_distractors: str,
|
| 89 |
intermediate_distractors_specification: str,
|
|
@@ -367,7 +368,16 @@ with gr.Blocks() as interface:
|
|
| 367 |
|
| 368 |
distractors_button.click(
|
| 369 |
fn=run_distractors,
|
| 370 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
outputs=[
|
| 372 |
distractors_response_1,
|
| 373 |
distractors_response_2,
|
|
|
|
| 84 |
user_query: str,
|
| 85 |
model_choice_distractors_1: str,
|
| 86 |
model_choice_distractors_2: str,
|
| 87 |
+
model_choice_distractors_3: str,
|
| 88 |
exercise_format_distractors: str,
|
| 89 |
sampling_count_distractors: str,
|
| 90 |
intermediate_distractors_specification: str,
|
|
|
|
| 368 |
|
| 369 |
distractors_button.click(
|
| 370 |
fn=run_distractors,
|
| 371 |
+
inputs=[
|
| 372 |
+
distractors_input,
|
| 373 |
+
model_choice_distractors_1,
|
| 374 |
+
model_choice_distractors_2,
|
| 375 |
+
exercise_format_distractors,
|
| 376 |
+
sampling_count_distractors,
|
| 377 |
+
intermediate_distractors_specification,
|
| 378 |
+
model_choice_distractors_3,
|
| 379 |
+
final_distractors_specification,
|
| 380 |
+
],
|
| 381 |
outputs=[
|
| 382 |
distractors_response_1,
|
| 383 |
distractors_response_2,
|
config/templates.py
CHANGED
|
@@ -4,7 +4,8 @@ from langchain_core.prompts.chat import ChatPromptTemplate
|
|
| 4 |
# Template to standardize the exercise description.
|
| 5 |
standardize_template = ChatPromptTemplate(
|
| 6 |
messages=[
|
| 7 |
-
("system", "You reformat data on multiple choice exercises. Convert the given exercise(s) into a standardized format. {formatting_instructions}"
|
|
|
|
| 8 |
("human", "{user_input}")
|
| 9 |
],
|
| 10 |
input_variables=["user_input", "formatting_instructions"]
|
|
@@ -200,35 +201,38 @@ template_distractors_brainstorm_2 = ChatPromptTemplate(
|
|
| 200 |
messages=[
|
| 201 |
("system", "Help me brainstorm answer options for a multiple choice exercise. Based on the given question, come up with{intermediate_distractors_specification}additional alternative distractors: "
|
| 202 |
"alternative answer options that are not correct, yet neither so implausible that even poorly informed students could immediately dismiss and eliminate them.\n\n"
|
| 203 |
-
"You can think about this as a spectrum between 'too correct' & 'too obviously false'. Or, in other words, a spectrum between two extreme ends that
|
| 204 |
-
"'An answer option that is not the correct answer to the question, yet extremely similar in meaning and scope to the correct answer, such that it's very debatable whether this answer option is not in fact actually
|
| 205 |
"'An answer option that is exceedingly unlikely, fantastical, off-base or ridiculous and therefore maximally obviously incorrect, such that no one who can read would think this could ever be the correct answer to the question'\n"
|
| 206 |
-
"Whether any particular distractor falls on the 'too correct' or 'too obviously incorrect'
|
| 207 |
-
"This often depends on many aspects to do with
|
| 208 |
-
"and assumptions about what test takers in the target group for this exercise already can be assumed to know or not know, and their intelligence
|
|
|
|
| 209 |
"Therefore, really try to go about your task here methodically: first establish the borders of the acceptable range of distractors by lingering there for a bit; taking into account the specific context of the given question, as follows.\n\n"
|
| 210 |
"Before drafting the final list, first come up with one or two faulty distractors, that are faulty in the sense that they would be júst too much on the 'too correct' side of the aforementioned spectrum.\n"
|
| 211 |
"Then, come up with one or two distractors that are júst faulty on the other side of that spectrum: júst too much on the side of 'too obviously false'.\n"
|
| 212 |
"As an intuition pump for the first category (distractors that are júst too correct), try to imagine experts in the question's domain discussing the answer option, and some of them arguing that the distractor would also be a valid answer to the given question. "
|
| 213 |
-
"As an intuition pump for the second category (distractors that are júst too obviously incorrect), try to image a student who is both generally stupid (bottom of his class) ánd uninformed about the given topic (didn't prepare for the test). Would even they
|
| 214 |
-
"
|
| 215 |
-
"
|
| 216 |
-
"
|
| 217 |
-
""),
|
| 218 |
("human", "{standardized_exercise}")
|
| 219 |
],
|
| 220 |
input_variables=["standardized_exercise", "intermediate_distractors_specification"]
|
| 221 |
)
|
| 222 |
|
| 223 |
|
|
|
|
|
|
|
| 224 |
template_consolidate_distractors = ChatPromptTemplate(
|
| 225 |
messages=[
|
| 226 |
("system", "You are given several lists of potential distractors (answer options to a multiple choice exercise), that need to be consolidated into one list. "
|
| 227 |
"Filter out duplicates, do some logical sorting, and just return one plain list{final_distractors_specification}. "
|
| 228 |
-
"Only focus on the distractors (answer options) themselves, ignore any reasoning about them. Return only the list, nothing else. Format the list without numbering or bullet points, just put every distractor on its own line. Use the same language as the existing exercise
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
"{brainstorm_outputs} ")
|
| 233 |
],
|
| 234 |
input_variables=["standardized_exercise", "brainstorm_outputs", "final_distractors_specification"]
|
|
|
|
| 4 |
# Template to standardize the exercise description.
|
| 5 |
standardize_template = ChatPromptTemplate(
|
| 6 |
messages=[
|
| 7 |
+
("system", "You reformat data on multiple choice exercises. Convert the given exercise(s) into a standardized format. {formatting_instructions}\n"
|
| 8 |
+
"Only return an exercise with the minimum required content, no need to make up any unrequired new content if it is not present in the given exercise (like the 'Theorie' part)"),
|
| 9 |
("human", "{user_input}")
|
| 10 |
],
|
| 11 |
input_variables=["user_input", "formatting_instructions"]
|
|
|
|
| 201 |
messages=[
|
| 202 |
("system", "Help me brainstorm answer options for a multiple choice exercise. Based on the given question, come up with{intermediate_distractors_specification}additional alternative distractors: "
|
| 203 |
"alternative answer options that are not correct, yet neither so implausible that even poorly informed students could immediately dismiss and eliminate them.\n\n"
|
| 204 |
+
"You can think about this as a spectrum between 'too correct' & 'too obviously false'. Or, in other words, a spectrum between two extreme ends that can be described as: "
|
| 205 |
+
"'An answer option that is not the correct answer to the question, yet extremely similar in meaning and scope to the correct answer, such that it's very debatable whether this answer option is not in fact also actually correct' & "
|
| 206 |
"'An answer option that is exceedingly unlikely, fantastical, off-base or ridiculous and therefore maximally obviously incorrect, such that no one who can read would think this could ever be the correct answer to the question'\n"
|
| 207 |
+
"Whether any particular distractor falls on the 'too correct' or 'too obviously incorrect' parts of the spectrum, is highly context-dependent. "
|
| 208 |
+
"This often depends on many aspects to do with question, for example its exact phrasing, specific (background) domain-knowledge related to the subject, "
|
| 209 |
+
"and assumptions about what test takers in the target group for this exercise already can be assumed to know or not know, and their intelligence.\n"
|
| 210 |
+
"In other words, it is not easy to pick distractors that are positioned inside the acceptable range on this spectrum. "
|
| 211 |
"Therefore, really try to go about your task here methodically: first establish the borders of the acceptable range of distractors by lingering there for a bit; taking into account the specific context of the given question, as follows.\n\n"
|
| 212 |
"Before drafting the final list, first come up with one or two faulty distractors, that are faulty in the sense that they would be júst too much on the 'too correct' side of the aforementioned spectrum.\n"
|
| 213 |
"Then, come up with one or two distractors that are júst faulty on the other side of that spectrum: júst too much on the side of 'too obviously false'.\n"
|
| 214 |
"As an intuition pump for the first category (distractors that are júst too correct), try to imagine experts in the question's domain discussing the answer option, and some of them arguing that the distractor would also be a valid answer to the given question. "
|
| 215 |
+
"As an intuition pump for the second category (distractors that are júst too obviously incorrect), try to image a student who is both generally stupid (bottom of his class) ánd uninformed about the given topic (didn't prepare for the test). Would even they júst so find it easy to eliminate the faulty distractor as clearly false?\n"
|
| 216 |
+
"Those are the two bounds of the spectrum range we aim to operate between during brainstorming.\n"
|
| 217 |
+
"So, through the above process of picking some júst faulty distractors in the context of the given question, both barely too correct and barely too obviously false, you establish the two bounds of acceptable distractors. When brainstorming, don't play it entirely safe though; when in doubt about where exactly on the spectrum the distractor would lie, just list the distractor you came up with anyway.\n\n"
|
| 218 |
+
"Next, in the brainstorming phase, it's most important that you get really creative and really try to think outside the box, to come up with the required potential alternative answer options to the exercise. We want to approach this task from all different angles, "
|
| 219 |
+
"to arrive at a varied selection of options, to serve as inspiration for a later stage of final selection (not now) to make the exercise the best it can be. For now, carry out the above-described prep in writing, then draft the list of{intermediate_distractors_specification} alternative distractors (in the same language as the existing exercise)."),
|
| 220 |
("human", "{standardized_exercise}")
|
| 221 |
],
|
| 222 |
input_variables=["standardized_exercise", "intermediate_distractors_specification"]
|
| 223 |
)
|
| 224 |
|
| 225 |
|
| 226 |
+
|
| 227 |
+
|
| 228 |
template_consolidate_distractors = ChatPromptTemplate(
|
| 229 |
messages=[
|
| 230 |
("system", "You are given several lists of potential distractors (answer options to a multiple choice exercise), that need to be consolidated into one list. "
|
| 231 |
"Filter out duplicates, do some logical sorting, and just return one plain list{final_distractors_specification}. "
|
| 232 |
+
"Only focus on the distractors (answer options) themselves, ignore any reasoning about them. Return only the list, nothing else. Format the list without numbering or bullet points, just put every distractor on its own line. Use the same language as the existing exercise.\n\n"
|
| 233 |
+
"For context, this is the exercise that the distractors are about:\n "
|
| 234 |
+
"{standardized_exercise}"),
|
| 235 |
+
("human", "Here are the lists:\n "
|
| 236 |
"{brainstorm_outputs} ")
|
| 237 |
],
|
| 238 |
input_variables=["standardized_exercise", "brainstorm_outputs", "final_distractors_specification"]
|