Skip to content

Instantly share code, notes, and snippets.

@brendancol
Last active December 19, 2024 04:30
Show Gist options
  • Save brendancol/3c5e408701c8674c8eefb9308b0a1933 to your computer and use it in GitHub Desktop.
Save brendancol/3c5e408701c8674c8eefb9308b0a1933 to your computer and use it in GitHub Desktop.
LLM Question Generator Example
question correct_answers incorrect_answer difficulty topic explanation
Identify the incorrect statement about basic properties of arithmetic operations. ['The commutative property states that the order in which two numbers are added does not affect the sum.', 'The associative property states that when three or more numbers are added, the way in which the numbers are grouped does not affect the sum.', 'The distributive property allows one to multiply a sum by multiplying each addend individually and then adding the products together.'] Subtraction is associative, which means the way numbers are grouped in subtraction does not change the result. 3 math The incorrect statement claims that subtraction is associative, which is false. The associative property applies to addition and multiplication, but not to subtraction or division. In subtraction, the grouping of numbers (i.e., the placement of parentheses) can change the result. For example, (5 - 3) - 2 equals 0, whereas 5 - (3 - 2) equals 4. This difference highlights why subtraction is not associative, and such a misunderstanding could lead to incorrect calculations.
Identify the incorrect statement about computer science: ['Computer science is the study of algorithms, data structures, and the principles of computing.', 'Programming languages like Python, Java, and C++ are tools used in computer science to implement solutions.', 'Computer science encompasses areas such as artificial intelligence, databases, and cybersecurity.'] Computer science is solely focused on hardware engineering and the physical components of computers. 2 computer_science The incorrect statement is misleading because computer science is not solely focused on hardware engineering. While computer science does involve understanding hardware at a certain level, it primarily deals with the theoretical foundations of information and computation, software development, algorithms, data manipulation, and problem-solving techniques rather than the physical construction of computer systems. Hardware engineering falls more under the discipline of computer engineering or electrical engineering, which is separate from computer science.
Identify the incorrect statement about the Renaissance art period from the following options: ['The Renaissance art period marked a revival of classical learning and wisdom, focusing on humanism and anatomy.', 'Leonardo da Vinci, Michelangelo, and Raphael were prominent figures of Renaissance art, known for their contributions to painting and sculpture.', 'Renaissance artists often used techniques such as linear perspective to create a sense of depth in their paintings.'] Renaissance art was characterized by the exclusive use of abstract forms and rejected realistic human representation entirely. 2 art The incorrect statement is misleading as Renaissance art was, in fact, celebrated for its realism and accurate depiction of the human figure, not for rejecting it. Artists during the Renaissance studied human anatomy meticulously and employed realistic proportions and perspectives to represent humans and the natural world accurately. This era was marked by a departure from more flat and stylized medieval art towards a more lifelike and three-dimensional representation.
Identify the incorrect statement about world geography: ['Mount Everest is the highest mountain in the world above sea level.', 'The Amazon River has the largest discharge volume of any river in the world.', 'The Sahara is the largest hot desert in the world in terms of area.'] Lake Baikal is the deepest and widest lake in the world. 2 geography While Lake Baikal is the deepest lake in the world, it is not the widest. The largest lake by surface area is the Caspian Sea, and the longest lake is Lake Tanganyika. This statement may be misleading because it combines two separate geographical records into one incorrect assertion.
In the study of geography, which of the following statements is incorrect? ['The Prime Meridian is an imaginary line located at 0° longitude, which divides the Earth into the Eastern and Western Hemispheres.',"The Amazon Rainforest is known as 'the lungs of the Earth' due to its vast capacity to produce oxygen and absorb carbon dioxide.","Plate tectonics explains the movement of the Earth's lithosphere, which is responsible for the formation of many geographical features, such as mountains and earthquakes."] Lake Baikal, the world’s largest freshwater lake by volume, is located in South America. 7 geography The incorrect statement is 'Lake Baikal, the world’s largest freshwater lake by volume, is located in South America.' In fact, Lake Baikal is located in Siberia, Russia, and it is the world's deepest and largest freshwater lake by volume. South America is home to other major lakes like Lake Titicaca, but not Lake Baikal. The incorrect statement might mislead students into confusing the locations of major lakes on different continents.
Identify the incorrect statement from the following regarding the Roman Empire: ['Julius Caesar was assassinated in 44 BC, which led to the rise of the Roman Empire.', 'The Roman Empire reached its greatest territorial extent under Emperor Trajan.', 'Latin was the official language of the Roman Empire.'] The Roman Empire was founded immediately after the fall of the Byzantine Empire. 1 history The incorrect statement is: 'The Roman Empire was founded immediately after the fall of the Byzantine Empire.' This is incorrect because the Roman Empire existed long before the Byzantine Empire came into being. In fact, the Byzantine Empire is considered the continuation of the Eastern Roman Empire after the western part fell. The Roman Empire traditionally dates back to the end of the Roman Republic in 27 BC with Augustus' rise to power, whereas the Byzantine Empire continued from the remnants of the Roman Empire into the Middle Ages after the fall of Rome in AD 476.
Identify the incorrect statement about the principles of thermodynamics. ['The First Law of Thermodynamics states that energy cannot be created or destroyed, only transformed from one form to another.', 'The Second Law of Thermodynamics introduces the concept of entropy, explaining that the total entropy of an isolated system can never decrease over time.', 'The Third Law of Thermodynamics states that as the temperature of a system approaches absolute zero, the entropy of a perfectly crystalline substance approaches zero.'] The Zeroth Law of Thermodynamics states that energy flows spontaneously from colder bodies to hotter bodies when not in equilibrium. 4 science The incorrect statement about the Zeroth Law of Thermodynamics is misleading because the law actually states that if two thermodynamic systems are each in thermal equilibrium with a third system, then they are in thermal equilibrium with each other. It establishes the concept of temperature and heat flow, but does not imply that energy flows from cold to hot bodies. In reality, energy flows spontaneously from hotter to colder bodies when not in equilibrium according to the Second Law of Thermodynamics.
Identify the incorrect statement about literature from the list below: ["William Shakespeare's works have been translated into numerous languages and are studied worldwide.","The term 'novel' is used to describe a long, fictional narrative which describes intimate human experiences.", 'The Romantic period in literature emphasized emotion and individualism, as well as glorifying the past and nature.', 'The Nobel Prize in Literature is awarded annually to authors who have produced outstanding work in the field of literature.'] Many of the well-known works of classical Latin literature originated during the 20th century. 1 literature The incorrect statement is: 'Many of the well-known works of classical Latin literature originated during the 20th century.'\nClassical Latin literature primarily refers to works produced during the late Roman Republic and the Roman Empire, spanning approximately the 1st century BC to the 2nd century AD. Therefore, it is misleading to say that these works originated in the 20th century. Works from classical Latin literature include those by authors such as Virgil, Horace, and Ovid, all of whom lived well before the 20th century.
Identify the incorrect statement about William Shakespeare's literary contributions. ['William Shakespeare wrote 37 plays and 154 sonnets, marking him as one of the most prolific writers of his time.',"Shakespeare's work is known for its vivid characters and profound exploration of human nature, traits that have given his plays enduring popularity.", 'His plays have been translated into every major living language and are performed more often than those of any other playwright.'] Shakespeare invented the genre of epic poetry through his works like 'The Iliad' and 'The Odyssey.' 8 literature The incorrect statement is that Shakespeare invented the genre of epic poetry through works like 'The Iliad' and 'The Odyssey.' This is misleading and false because 'The Iliad' and 'The Odyssey' are ancient Greek epic poems attributed to the poet Homer, not Shakespeare. Shakespeare is renowned for his contributions to drama and sonnets, not for epics. Epic poetry as a genre predates Shakespeare by centuries, having its origins in ancient civilizations long before his time.
Identify the incorrect statement about music. ['Ludwig van Beethoven was a pivotal figure in the transition between the Classical and Romantic eras in Western music.',"The Beatles are recognized as one of the most influential bands of all time, with hits like 'Hey Jude' and 'Let It Be'.", 'Johann Sebastian Bach was known for his complex compositions and masterful use of counterpoint.'] Wolfgang Amadeus Mozart was a prominent composer during the Baroque period, known for his elaborate orchestral works. 1 music The incorrect statement is misleading because Wolfgang Amadeus Mozart was not a composer of the Baroque era; he was actually a composer from the Classical period. The Baroque era preceded the Classical era, and composers like Johann Sebastian Bach and George Frideric Handel are rightly associated with it. Mozart's music, characterized by clarity, balance, and form, is typical of the Classical period, not the Baroque period. Therefore, describing him as a Baroque composer is incorrect.
Identify the incorrect statement about computer networks. ['A. TCP/IP is the foundational protocol suite for the internet, providing end-to-end data communication specifying how data should be packetized, addressed, transmitted, routed, and received.', 'B. The Domain Name System (DNS) translates human-readable domain names like www.example.com into IP addresses that computers use to identify each other on the network.', 'C. The OSI model is a conceptual framework used to understand network interactions through seven distinct layers, each providing specific functionalities and services.', 'D. Ethernet is a widely used networking technology that defines a set of wiring and signaling standards for data transmission over local area networks (LANs).'] E. HTTP is only used for sending emails between mail servers, ensuring the secure and reliable transmission of messages. 10 computer_science The incorrect statement is E. HTTP is not used for sending emails; it is a protocol primarily used for transferring hypertext documents on the World Wide Web, which includes web pages and web resources. The protocol used for sending emails is SMTP (Simple Mail Transfer Protocol). Therefore, saying that HTTP is used for email transmission is both incorrect and misleading, as it confuses HTTP with the correct email protocol, SMTP. HTTP isn't tasked with ensuring the secure and reliable transmission of emails; rather, SMTP combined with protocols like MIME and secure layers such as TLS or SSL achieves that in mail servers.
Identify the incorrect statement about World War I from the options below: ['World War I began in 1914 and ended in 1918.', 'The assassination of Archduke Franz Ferdinand of Austria was a trigger for the war.', 'World War I was characterized by trench warfare, especially on the Western Front.'] The Treaty of Versailles, which ended World War I, was signed in 1939. 2 history The incorrect statement is: 'The Treaty of Versailles, which ended World War I, was signed in 1939.' This is misleading because the Treaty of Versailles was actually signed on June 28, 1919. It is a common error to confuse it with events leading to World War II, which began in 1939. The treaty effectively ended the state of war between Germany and the Allied Powers and was a significant event that contributed to the conditions leading to World War II.
Consider the following statements about the Renaissance period in art. Identify the incorrect statement: ['The Renaissance period marked a renewed interest in the classical art and knowledge of Ancient Greece and Rome.', 'Leonardo da Vinci and Michelangelo are two of the most famous artists from the Renaissance period.', 'The Renaissance period saw the development of perspective in painting, giving depth and a three-dimensional appearance to the works.'] The Renaissance period was primarily focused on abstract and surrealist art styles. 1 art The incorrect statement is 'The Renaissance period was primarily focused on abstract and surrealist art styles.' This is incorrect because the Renaissance was characterized by a return to classical themes and techniques, realism, and the study of perspective to create a more lifelike representation of subjects. Abstract and surrealist art styles are modern movements that developed much later, primarily in the 20th century.
Identify the incorrect statement regarding the concept of evolution in science. ['Natural selection is one of the primary mechanisms by which evolution takes place, favoring traits that enhance survival and reproduction.', 'Mutations in genetic material can introduce new traits into a population, some of which may be beneficial and increase in frequency over generations.', 'Over long periods of time, evolutionary processes can lead to the development of new species from common ancestors.'] Evolutionary changes occur rapidly and uniformly across all species, leading to immediate adaptations to environmental changes. 7 science The incorrect statement is misleading because it suggests that evolutionary changes happen uniformly and rapidly across all species. In reality, evolution is typically a slow and gradual process that does not occur at the same rate for all species or for all traits within a species. The process of adaptation depends on numerous factors, including environmental pressures and genetic variation. Rapid changes can occur, but they are often exceptions rather than the rule, and they generally happen over many generations rather than being immediate.
Identify the incorrect statement about the role of music in film and television: ['Music is often used in films to evoke emotional responses from the audience.', 'Soundtracks can enhance storytelling by reinforcing themes and moods.', 'Musical motifs are frequently utilized to represent characters or ideas.', 'The volume of the music is never adjusted during dialogue scenes.'] The volume of the music is never adjusted during dialogue scenes. 2 music The incorrect statement is that 'The volume of the music is never adjusted during dialogue scenes.' In reality, the music's volume is often adjusted during dialogue scenes to ensure that the dialogue is clear and comprehensible to the audience. This practice is called 'ducking' or 'audio ducking,' and it involves lowering the music's volume when dialogue is present and raising it when there is no dialogue to maintain the acoustic balance in the film. Failing to adjust the volume could result in the dialogue being drowned out by the music, making it difficult for viewers to follow the storyline.
# This file contains the code for generating questions for "Find the Incorrect Statement" question type.
# Installation
# ------------
# if you have miniconda / anaconda installed, you should be able to setup the environment with the following command:
# $> conda env create -n question-generator python=3.12
# $> conda activate question-generator
# $> pip install magentic
# $> pip install pandas
# To use OpenAI, then you will need to set an environment variable in your shell called OPENAI_API_KEY with your API key.
# You can do this by running the following command in your terminal:
# $> export OPENAI_API_KEY=your-api-key
# $> python questions.py
# Then to run the example below if it were in a file called questions.py, you would run:
# $> python questions.py
# Standard Library Imports
from enum import Enum
from random import sample, shuffle, randint
from typing import List, Optional
# Third Party Imports (installed via pip in documentation above)
from magentic import prompt
from pandas import DataFrame
from pydantic import BaseModel
# Create an Enum with your topics of interest
class FocusArea(str, Enum):
MATH = "math"
SCIENCE = "science"
HISTORY = "history"
LITERATURE = "literature"
GEOGRAPHY = "geography"
COMPUTER_SCIENCE = "computer_science"
ART = "art"
MUSIC = "music"
def __str__(self):
return self.value
def __repr__(self):
return self.value
# Create a function to generate a list of focus areas at a desired distribution
def generate_focus_areas(n: int):
all_areas = list(FocusArea)
num_areas = len(all_areas)
base_count = n // num_areas
remainder = n % num_areas
result = [area for area in all_areas for _ in range(base_count)]
if remainder > 0:
extra_areas = sample(all_areas, remainder)
result.extend(extra_areas)
shuffle(result)
return result
# Create an object to represent the question
# Properties here will be the columns in CSV output
class FindTheIncorrectStatementQuestion(BaseModel):
question: str
correct_answers: List[str]
incorrect_answer: str
difficulty: int
topic: FocusArea
explanation: Optional[str]
# Use Magentic `prompt` decorator to interact with LLM
@prompt('''
Your Task:
Create a single, university-level question based on the specified topic at a difficulty level based on the difficulty index value provided. The question should present four statements, three of which are correct and one of which is incorrect. The student must identify the incorrect statement.
Requirements:
Topic: {focus_area}
Difficulty: {difficulty} out of 10
Provide 3 correct statements about the topic {focus_area}, each one a complete and accurate sentence.
Provide 1 incorrect statement, also a complete sentence, indistinguishable in sentence structure from companion statements, that seems plausible but is actually false or misleading.
After listing all four statements, prompt the student to identify which one is incorrect.
Include an explanation section after the statements that clearly explains why the incorrect statement is wrong and how it could be misleading.
Explanation:
[Explain why the incorrect statement is wrong and misleading, providing any necessary clarifications or corrections.]''')
def generate_question(focus_area: FocusArea, difficulty: int) -> FindTheIncorrectStatementQuestion:
...
N = 15 # How many questions to generate
focus_areas = generate_focus_areas(N)
difficulties = [randint(1, 10) for _ in range(N)]
questions = map(generate_question, focus_areas, difficulties)
questions_df = DataFrame([q.model_dump() for q in questions])
questions_df.to_csv("find_the_incorrect_statement_questions.csv", index=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment