Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
490 changes: 475 additions & 15 deletions openworm_ai/quiz/QuizMaster.py

Large diffs are not rendered by default.

443 changes: 336 additions & 107 deletions openworm_ai/quiz/QuizMasterCorpus.py

Large diffs are not rendered by default.

75 changes: 62 additions & 13 deletions openworm_ai/quiz/Templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,83 @@

GENERATE_Q = """
Generate a list of <QUESTION_NUMBER> multiple choice questions to test someone's general knowledge.
The questions should be answerable by a reasonably intelligent adult, and should be on a wide range of subjects.
The questions should be answerable by an intelligent adult and should cover a wide range of topics,
such as history, geography, science, culture, technology, medicine, society, and everyday facts.
There should be <ANSWER_NUMBER> possible answers, only one of which is unambiguously correct, and all of the answers should be kept brief.
Each of the <QUESTION_NUMBER> question/answer sets should be presented in the following format:

"""

TEXT_ANSWER_EXAMPLE = """
QUESTION: What is the capital of France?
CORRECT ANSWER: Paris
WRONG ANSWER: Madrid
WRONG ANSWER: Rome
WRONG ANSWER: Dublin
QUESTION: What is the capital city of Japan?
CORRECT ANSWER: Tokyo
WRONG ANSWER: Osaka
WRONG ANSWER: Kyoto
WRONG ANSWER: Nagoya

"""

# New JSON-based MCQ generation template (v2)
GENERATE_Q_JSON = """
You are an expert academic question writer.

Generate <QUESTION_NUMBER> high-quality general-knowledge multiple-choice questions.
Cover a wide range of topics such as history, geography, science, culture, medicine,
society, world affairs, technology, and everyday factual knowledge.

Each question MUST:
- Be clearly and precisely worded.
- Be answerable by an intelligent adult without needing specialist knowledge.
- Have exactly ONE correct answer and three incorrect but plausible answers.
- Be unambiguous so that two well-informed people would independently choose the same correct option.

STRICTLY AVOID AMBIGUITY:
- Do NOT use vague terms like "main", "best", "most important", or "most likely"
unless the question defines them clearly.
- Do NOT write questions where more than one answer could be argued correct.
- Avoid vague pronouns ("this", "it", "they") if unclear what they refer to.
- Avoid questions whose answer might depend on opinion or interpretation.

For the incorrect options:
- They must be factually wrong.
- They must still sound plausible to someone with partial knowledge.
- Avoid joke answers or irrelevant answers.
- Do NOT use "All of the above" or "None of the above".

Return ONLY valid JSON, with no extra commentary. The JSON must be an array:

[
{
"question": "string",
"options": [
{"label": "A", "text": "string"},
{"label": "B", "text": "string"},
{"label": "C", "text": "string"},
{"label": "D", "text": "string"}
],
"correct_label": "A"
},
...
]

Do not include fewer or more than <QUESTION_NUMBER> objects in the array.
"""




ASK_Q = """You are to select the correct answer for a multiple choice question.
A number of answers will be presented and you should respond with only the letter corresponding to the correct answer.
For example if the question is:

What is the capital of France?
What is the capital city of Japan?

and the potential answers are:

E: Madrid
F: Paris
G: Rome
H: Dublin
E: Osaka
F: Tokyo
G: Kyoto
H: Nagoya

you should only answer:

Expand All @@ -44,14 +94,13 @@

<ANSWERS>

Remember: only respond with the letter of the correct answer!
"""

if __name__ == "__main__":
import sys

question = (
GENERATE_Q.replace("<QUESTION_NUMBER>", "100").replace("<ANSWER_NUMBER>", "4")
GENERATE_Q.replace("<QUESTION_NUMBER>", "5").replace("<ANSWER_NUMBER>", "4")
+ TEXT_ANSWER_EXAMPLE
)

Expand Down
49 changes: 49 additions & 0 deletions openworm_ai/quiz/TemplatesCelegans.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,55 @@

"""

# New JSON-based MCQ generation template (v2)
GENERATE_Q_JSON = """
You are an expert on *Caenorhabditis elegans* (C. elegans) biology and neuroscience.

Generate <QUESTION_NUMBER> high-quality multiple-choice questions about C. elegans.
Cover a range of topics (anatomy, nervous system, behaviour, genetics, development, physiology, lab techniques, and research significance).
Questions should be answerable by a scientifically literate, intelligent adult without needing to be a specialist in C. elegans.

Each question MUST:
- Be specific to C. elegans (not generic animal biology).
- Be clearly and precisely worded.
- Have exactly ONE correct answer and three incorrect but plausible answers.
- Be answerable in a way that two well-informed experts on C. elegans would agree on the same option.

STRICTLY AVOID AMBIGUITY:
- Do NOT use vague terms like "main", "best", "most important", or "most likely"
unless the question explicitly defines them clearly enough that only one option fits.
- Do NOT ask questions where more than one option could reasonably be argued correct.
- Avoid vague pronouns ("this", "it", "they") if it might be unclear what they refer to.
- If a question could be interpreted in multiple ways, REWRITE it until the meaning is unique.

For the incorrect options:
- They must be factually wrong for C. elegans.
- They must still sound plausible to someone with partial understanding of C. elegans.
- Avoid obviously silly or irrelevant answers.
- Do NOT use "All of the above" or "None of the above".

Return ONLY valid JSON, with no extra commentary. The JSON must be an array:

[
{
"question": "string",
"options": [
{"label": "A", "text": "string"},
{"label": "B", "text": "string"},
{"label": "C", "text": "string"},
{"label": "D", "text": "string"}
],
"correct_label": "A"
},
...
]

Do not include fewer or more than <QUESTION_NUMBER> objects in the array.
"""




ASK_Q = """You are to select the correct answer for a multiple choice question.
A number of answers will be presented and you should respond with only the letter corresponding to the correct answer.
For example if the question is:
Expand Down
75 changes: 68 additions & 7 deletions openworm_ai/quiz/TemplatesScience.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

GENERATE_Q = """
Generate a list of <QUESTION_NUMBER> multiple choice questions to test someone's scientific knowledge.
The questions should be answerable by an intelligent adult, and should be on a wide range of subjects in scinece: biology, chemistry, physics and all the relevant fields.
The questions should be answerable by an intelligent adult, and should be on a wide range of subjects in science: biology, chemistry, physics and all the relevant fields.
There should be <ANSWER_NUMBER> possible answers, only one of which is unambiguously correct, and all of the answers should be kept brief.
Each of the <QUESTION_NUMBER> question/answer sets should be presented in the following format:

Expand All @@ -19,31 +19,92 @@

"""

ASK_Q = """You are to select the correct answer for a multiple choice question.
A number of answers will be presented and you should respond with only the letter corresponding to the correct answer.
For example if the question is:
# New JSON-based MCQ generation template (v2)
GENERATE_Q_JSON = """
You are an expert on *Science* including biology, chemistry, physics and mathematics and all relevant fields.

Generate <QUESTION_NUMBER> high-quality multiple-choice questions on a wide range of scientific topics.
Cover a range of topics (biology, chemistry, physics, mathematics and related disciplines, and all the subtopics within these fields).
Questions should be answerable by a scientifically literate, intelligent adult without needing to be a specialist in the specific topic area.

Each question MUST:
- Be specific to scientific knowledge.
- Be clearly and precisely worded.
- Have exactly ONE correct answer and three incorrect but plausible answers.
- Be answerable in a way that two well-informed experts on the scientific topic would agree on the same option.

STRICTLY AVOID AMBIGUITY:
- Do NOT use vague terms like "main", "best", "most important", or "most likely"
unless the question explicitly defines them clearly enough that only one option fits.
- Do NOT ask questions where more than one option could reasonably be argued correct.
- Avoid vague pronouns ("this", "it", "they") if it might be unclear what they refer to.
- If a question could be interpreted in multiple ways, REWRITE it until the meaning is unique.

For the incorrect options:
- They must be factually wrong for C. elegans.
- They must still sound plausible to someone with partial understanding of science.
- Avoid obviously silly or irrelevant answers.
- Do NOT use "All of the above" or "None of the above".

Return ONLY valid JSON, with no extra commentary. The JSON must be an array:

[
{
"question": "string",
"options": [
{"label": "A", "text": "string"},
{"label": "B", "text": "string"},
{"label": "C", "text": "string"},
{"label": "D", "text": "string"}
],
"correct_label": "A"
},
...
]

Do not include fewer or more than <QUESTION_NUMBER> objects in the array.
"""


ASK_Q = """
You are to select the correct answer for a multiple choice question.

A number of answers will be presented and you should respond with only the letter
corresponding to the correct answer.

Here is an example to show the format:

Example question:

What is the powerhouse of the cell responsible for cellular respiration?

and the potential answers are:
Example options:

E: Nucleus
F: Mitochondria
G: Ribosome
H: Golgi Apparatus

you should only answer:
In that example, the correct answer is option F, so you would answer with:

F

This is your question:
IMPORTANT: In the REAL questions below, the options will ALWAYS be labelled with the letters A, B, C, and D.
For those questions you MUST answer with exactly ONE of these letters: A, B, C, or D.

Do NOT answer with any other letter.
Do NOT repeat the question or options.
Do NOT add explanations, punctuation, or any extra text.

Now answer this question:

<QUESTION>

These are the potential answers:

<ANSWERS>

Respond with exactly ONE character: A, B, C, or D.
"""

if __name__ == "__main__":
Expand Down
Loading
Loading