Raniahossam33's picture
Upload folder using huggingface_hub
14b2318 verified
Raw
History Blame Contribute Delete
21.6 kB
"""
Configuration for Knowledge Drift Dataset Collection
=====================================================
Model: Qwen 2.5 7B
Knowledge Cutoff: August 2024
Collection Date: February 2025
"""
# ============================================================
# TEMPORAL BOUNDARIES
# ============================================================
MODEL_CUTOFF = "2024-08-01"
COLLECTION_DATE = "2025-02-25"
# Time periods for temporal variants
TIMESTAMP_YEARS = [2015, 2018, 2020, 2022, 2023, 2024, 2025]
# ============================================================
# WIKIDATA PROPERTIES FOR TEMPORAL FACTS
# ============================================================
TEMPORAL_RELATIONS = [
{
"property": "P6",
"label": "head of government",
"knowledge_type": "entity_role",
"templates": [
"In {year}, the head of government of {subject} was {object}.",
"Who was the head of government of {subject} in {year}?",
"As of {year}, {subject} was led by {object}.",
],
"subject_type": "Q6256",
"example": "UK → PM"
},
{
"property": "P35",
"label": "head of state",
"knowledge_type": "entity_role",
"templates": [
"In {year}, the head of state of {subject} was {object}.",
"Who was the head of state of {subject} in {year}?",
],
"subject_type": "Q6256",
"example": "US → President"
},
{
"property": "P169",
"label": "chief executive officer",
"knowledge_type": "entity_role",
"templates": [
"In {year}, the CEO of {subject} was {object}.",
"Who was the CEO of {subject} in {year}?",
"As of {year}, {subject} was led by CEO {object}.",
],
"subject_type": "Q4830453",
"example": "Google → CEO"
},
{
"property": "P286",
"label": "head coach",
"knowledge_type": "entity_role",
"templates": [
"In {year}, the head coach of {subject} was {object}.",
"Who coached {subject} in {year}?",
],
"subject_type": "Q476028",
"example": "Real Madrid → Coach"
},
]
# ============================================================
# WIKIDATA SPARQL QUERIES
# ============================================================
SPARQL_POST_CUTOFF_CHANGES = """
SELECT DISTINCT ?subject ?subjectLabel ?property ?propertyLabel
?old_value ?old_valueLabel ?old_start ?old_end
?new_value ?new_valueLabel ?new_start
WHERE {{
?subject p:{prop} ?new_statement .
?new_statement ps:{prop} ?new_value .
OPTIONAL {{ ?new_statement pq:P580 ?new_start . }}
?subject p:{prop} ?old_statement .
?old_statement ps:{prop} ?old_value .
OPTIONAL {{ ?old_statement pq:P580 ?old_start . }}
OPTIONAL {{ ?old_statement pq:P582 ?old_end . }}
FILTER(BOUND(?old_end) && ?old_end >= "{cutoff_date}"^^xsd:dateTime)
FILTER(?new_value != ?old_value)
?subject wdt:P31/wdt:P279* wd:{subject_type} .
SERVICE wikibase:label {{ bd:serviceParam wikibase:language "en". }}
}}
LIMIT {limit}
"""
SPARQL_PRE_CUTOFF_CHANGES = """
SELECT DISTINCT ?subject ?subjectLabel
?old_value ?old_valueLabel ?old_start ?old_end
?new_value ?new_valueLabel ?new_start ?new_end
WHERE {{
?subject p:{prop} ?new_statement .
?new_statement ps:{prop} ?new_value .
OPTIONAL {{ ?new_statement pq:P580 ?new_start . }}
OPTIONAL {{ ?new_statement pq:P582 ?new_end . }}
?subject p:{prop} ?old_statement .
?old_statement ps:{prop} ?old_value .
OPTIONAL {{ ?old_statement pq:P580 ?old_start . }}
?old_statement pq:P582 ?old_end .
FILTER(?old_end >= "2020-01-01"^^xsd:dateTime && ?old_end < "{cutoff_date}"^^xsd:dateTime)
FILTER(?new_value != ?old_value)
?subject wdt:P31/wdt:P279* wd:{subject_type} .
SERVICE wikibase:label {{ bd:serviceParam wikibase:language "en". }}
}}
LIMIT {limit}
"""
SPARQL_STABLE_TEMPORAL = """
SELECT DISTINCT ?subject ?subjectLabel
?value ?valueLabel ?start_time
WHERE {{
?subject p:{prop} ?statement .
?statement ps:{prop} ?value .
OPTIONAL {{ ?statement pq:P580 ?start_time . }}
FILTER NOT EXISTS {{ ?statement pq:P582 ?end_time . }}
FILTER(!BOUND(?start_time) || ?start_time < "{cutoff_date}"^^xsd:dateTime)
?subject wdt:P31/wdt:P279* wd:{subject_type} .
SERVICE wikibase:label {{ bd:serviceParam wikibase:language "en". }}
}}
LIMIT {limit}
"""
# ============================================================
# STABLE FACTS (Category 1)
# ============================================================
STABLE_FACTS = {
"geographical": [
{"query": "The capital of {country} is ___", "pairs": [
("France", "Paris"), ("Japan", "Tokyo"), ("Egypt", "Cairo"),
("Germany", "Berlin"), ("Brazil", "Brasília"), ("Australia", "Canberra"),
("Canada", "Ottawa"), ("Italy", "Rome"), ("South Korea", "Seoul"),
("Saudi Arabia", "Riyadh"), ("United Arab Emirates", "Abu Dhabi"),
("Morocco", "Rabat"), ("Turkey", "Ankara"), ("India", "New Delhi"),
("China", "Beijing"), ("Russia", "Moscow"), ("Mexico", "Mexico City"),
("Argentina", "Buenos Aires"), ("South Africa", "Pretoria"),
("Indonesia", "Jakarta"), ("Thailand", "Bangkok"), ("Vietnam", "Hanoi"),
("Poland", "Warsaw"), ("Sweden", "Stockholm"), ("Norway", "Oslo"),
("Spain", "Madrid"), ("Portugal", "Lisbon"), ("Greece", "Athens"),
("Ireland", "Dublin"), ("Switzerland", "Bern"),
]},
{"query": "The largest continent by area is ___", "answer": "Asia"},
{"query": "The longest river in the world is ___", "answer": "the Nile"},
{"query": "The highest mountain in the world is ___", "answer": "Mount Everest"},
{"query": "The largest ocean is ___", "answer": "the Pacific Ocean"},
{"query": "The largest desert in the world is ___", "answer": "the Sahara Desert"},
{"query": "{country} is located in {continent}", "pairs": [
("Japan", "Asia"), ("Brazil", "South America"), ("Nigeria", "Africa"),
("France", "Europe"), ("Australia", "Oceania"), ("Egypt", "Africa"),
("Canada", "North America"), ("India", "Asia"), ("Argentina", "South America"),
]},
],
"scientific": [
{"query": "Water boils at ___ degrees Celsius at standard pressure", "answer": "100"},
{"query": "The speed of light is approximately ___ km/s", "answer": "300,000"},
{"query": "The chemical formula for water is ___", "answer": "H2O"},
{"query": "The chemical formula for table salt is ___", "answer": "NaCl"},
{"query": "The atomic number of hydrogen is ___", "answer": "1"},
{"query": "The atomic number of carbon is ___", "answer": "6"},
{"query": "The atomic number of oxygen is ___", "answer": "8"},
{"query": "DNA stands for ___", "answer": "deoxyribonucleic acid"},
{"query": "The Earth orbits around ___", "answer": "the Sun"},
{"query": "Photosynthesis converts sunlight into ___ for plants", "answer": "energy"},
{"query": "The force of gravity on Earth is approximately ___ m/s²", "answer": "9.8"},
{"query": "Absolute zero is ___ degrees Celsius", "answer": "-273.15"},
],
"mathematical": [
{"query": "The value of pi to two decimal places is ___", "answer": "3.14"},
{"query": "The square root of 144 is ___", "answer": "12"},
{"query": "The square root of 169 is ___", "answer": "13"},
{"query": "2 to the power of 10 is ___", "answer": "1024"},
{"query": "The sum of angles in a triangle is ___ degrees", "answer": "180"},
{"query": "The derivative of x² is ___", "answer": "2x"},
{"query": "The integral of 2x is ___", "answer": "x²"},
{"query": "Euler's number e is approximately ___", "answer": "2.718"},
{"query": "The Pythagorean theorem states that a² + b² = ___", "answer": "c²"},
{"query": "The factorial of 5 (5!) is ___", "answer": "120"},
],
"historical": [
{"query": "World War I started in ___", "answer": "1914"},
{"query": "World War II ended in ___", "answer": "1945"},
{"query": "The first moon landing was in ___", "answer": "1969"},
{"query": "The Berlin Wall fell in ___", "answer": "1989"},
{"query": "The United Nations was founded in ___", "answer": "1945"},
{"query": "The French Revolution began in ___", "answer": "1789"},
{"query": "The Titanic sank in ___", "answer": "1912"},
{"query": "The first iPhone was released in ___", "answer": "2007"},
{"query": "The Internet was invented in ___", "answer": "1969"},
{"query": "Islam's Prophet Muhammad was born in ___", "answer": "570 CE"},
{"query": "The pyramids of Giza were built in ancient ___", "answer": "Egypt"},
],
"cultural_religious": [
{"query": "The holy book of Islam is ___", "answer": "the Quran"},
{"query": "The holy city of Islam is ___", "answer": "Mecca"},
{"query": "The language of the Quran is ___", "answer": "Arabic"},
{"query": "The five pillars of Islam include Shahada, Salah, Zakat, Sawm, and ___", "answer": "Hajj"},
{"query": "The author of Romeo and Juliet is ___", "answer": "William Shakespeare"},
{"query": "The Mona Lisa was painted by ___", "answer": "Leonardo da Vinci"},
{"query": "The theory of relativity was developed by ___", "answer": "Albert Einstein"},
{"query": "The inventor of the telephone was ___", "answer": "Alexander Graham Bell"},
],
}
# ============================================================
# KNOWN POST-CUTOFF CHANGES (Category 3)
# ============================================================
VERIFIED_POST_CUTOFF_CHANGES = [
{
"entity": "United Kingdom",
"relation": "head of government",
"knowledge_type": "entity_role",
"old_answer": "Rishi Sunak",
"new_answer": "Keir Starmer",
"change_date": "2024-07-05",
"templates": [
"In {year}, the Prime Minister of the United Kingdom was ___",
"Who was the Prime Minister of the UK in {year}?",
"As of {year}, the UK was governed by Prime Minister ___",
],
"pre_cutoff_history": [
{"year": 2020, "answer": "Boris Johnson"},
{"year": 2022, "answer": "Rishi Sunak"},
{"year": 2023, "answer": "Rishi Sunak"},
]
},
{
"entity": "United States",
"relation": "president",
"knowledge_type": "entity_role",
"old_answer": "Joe Biden",
"new_answer": "Donald Trump",
"change_date": "2025-01-20",
"templates": [
"In {year}, the President of the United States was ___",
"Who was the US President in {year}?",
"As of {year}, the United States was led by President ___",
],
"pre_cutoff_history": [
{"year": 2018, "answer": "Donald Trump"},
{"year": 2020, "answer": "Donald Trump"},
{"year": 2022, "answer": "Joe Biden"},
{"year": 2023, "answer": "Joe Biden"},
]
},
{
"entity": "Japan",
"relation": "prime minister",
"knowledge_type": "entity_role",
"old_answer": "Fumio Kishida",
"new_answer": "Shigeru Ishiba",
"change_date": "2024-10-01",
"templates": [
"In {year}, the Prime Minister of Japan was ___",
"Who was Japan's Prime Minister in {year}?",
],
"pre_cutoff_history": [
{"year": 2020, "answer": "Yoshihide Suga"},
{"year": 2022, "answer": "Fumio Kishida"},
{"year": 2023, "answer": "Fumio Kishida"},
]
},
{
"entity": "European Commission",
"relation": "president",
"knowledge_type": "entity_role",
"old_answer": "Ursula von der Leyen",
"new_answer": "Ursula von der Leyen",
"change_date": "2024-07-18",
"note": "Same person re-elected — control for change event without answer change",
"templates": [
"In {year}, the President of the European Commission was ___",
],
"pre_cutoff_history": [
{"year": 2020, "answer": "Ursula von der Leyen"},
{"year": 2023, "answer": "Ursula von der Leyen"},
]
},
{
"entity": "Syria",
"relation": "political situation",
"knowledge_type": "event",
"old_answer": "Bashar al-Assad",
"new_answer": "Ahmad al-Sharaa (transitional government)",
"change_date": "2024-12-08",
"templates": [
"In {year}, the leader of Syria was ___",
"Who controlled Syria in {year}?",
],
"pre_cutoff_history": [
{"year": 2020, "answer": "Bashar al-Assad"},
{"year": 2023, "answer": "Bashar al-Assad"},
]
},
{
"entity": "BRICS",
"relation": "member countries expansion",
"knowledge_type": "relational",
"old_answer": "Brazil, Russia, India, China, South Africa",
"new_answer": "Brazil, Russia, India, China, South Africa, Iran, Egypt, Ethiopia, UAE, Saudi Arabia",
"change_date": "2024-01-01",
"note": "Expansion announced 2023 but effective Jan 2024",
"templates": [
"In {year}, the members of BRICS included ___",
"Which countries were part of BRICS in {year}?",
],
"pre_cutoff_history": [
{"year": 2020, "answer": "Brazil, Russia, India, China, South Africa"},
{"year": 2023, "answer": "Brazil, Russia, India, China, South Africa"},
]
},
{
"entity": "OpenAI",
"relation": "board and leadership changes",
"knowledge_type": "relational",
"old_answer": "nonprofit-controlled structure",
"new_answer": "for-profit transition announced",
"change_date": "2024-12-01",
"templates": [
"In {year}, OpenAI's corporate structure was ___",
"As of {year}, OpenAI was organized as ___",
],
"pre_cutoff_history": [
{"year": 2022, "answer": "nonprofit-controlled with capped-profit subsidiary"},
{"year": 2023, "answer": "nonprofit-controlled with capped-profit subsidiary"},
]
},
{
"entity": "Twitter/X",
"relation": "CEO",
"knowledge_type": "entity_role",
"old_answer": "Linda Yaccarino",
"new_answer": "Linda Yaccarino",
"change_date": None,
"note": "Control: same type (tech CEO) but did NOT change",
"templates": [
"In {year}, the CEO of X (formerly Twitter) was ___",
],
"pre_cutoff_history": [
{"year": 2022, "answer": "Elon Musk (interim)"},
{"year": 2023, "answer": "Linda Yaccarino"},
]
},
]
# ============================================================
# VERIFIED POST-CUTOFF UNCHANGED (Category 4)
# ============================================================
VERIFIED_UNCHANGED_POST_CUTOFF = [
{
"entity": "Saudi Arabia",
"relation": "head of state",
"knowledge_type": "entity_role",
"answer": "King Salman bin Abdulaziz",
"stable_since": "2015-01-23",
"templates": [
"In {year}, the King of Saudi Arabia was ___",
"Who was the King of Saudi Arabia in {year}?",
],
},
{
"entity": "United Arab Emirates",
"relation": "president",
"knowledge_type": "entity_role",
"answer": "Mohamed bin Zayed Al Nahyan",
"stable_since": "2022-05-14",
"templates": ["In {year}, the President of the UAE was ___"],
},
{
"entity": "Apple Inc.",
"relation": "CEO",
"knowledge_type": "entity_role",
"answer": "Tim Cook",
"stable_since": "2011-08-24",
"templates": ["In {year}, the CEO of Apple was ___", "Who was Apple's CEO in {year}?"],
},
{
"entity": "Microsoft",
"relation": "CEO",
"knowledge_type": "entity_role",
"answer": "Satya Nadella",
"stable_since": "2014-02-04",
"templates": ["In {year}, the CEO of Microsoft was ___"],
},
{
"entity": "Amazon",
"relation": "CEO",
"knowledge_type": "entity_role",
"answer": "Andy Jassy",
"stable_since": "2021-07-05",
"templates": ["In {year}, the CEO of Amazon was ___"],
},
{
"entity": "Russia",
"relation": "president",
"knowledge_type": "entity_role",
"answer": "Vladimir Putin",
"stable_since": "2012-05-07",
"templates": ["In {year}, the President of Russia was ___"],
},
{
"entity": "China",
"relation": "president",
"knowledge_type": "entity_role",
"answer": "Xi Jinping",
"stable_since": "2013-03-14",
"templates": ["In {year}, the President of China was ___"],
},
{
"entity": "France",
"relation": "president",
"knowledge_type": "entity_role",
"answer": "Emmanuel Macron",
"stable_since": "2017-05-14",
"templates": ["In {year}, the President of France was ___"],
},
{
"entity": "Germany",
"relation": "chancellor",
"knowledge_type": "entity_role",
"answer": "Olaf Scholz",
"stable_since": "2021-12-08",
"templates": ["In {year}, the Chancellor of Germany was ___"],
},
{
"entity": "Egypt",
"relation": "president",
"knowledge_type": "entity_role",
"answer": "Abdel Fattah el-Sisi",
"stable_since": "2014-06-08",
"templates": ["In {year}, the President of Egypt was ___"],
},
{
"entity": "Tesla",
"relation": "CEO",
"knowledge_type": "entity_role",
"answer": "Elon Musk",
"stable_since": "2008-10-01",
"templates": ["In {year}, the CEO of Tesla was ___"],
},
{
"entity": "Google/Alphabet",
"relation": "CEO",
"knowledge_type": "entity_role",
"answer": "Sundar Pichai",
"stable_since": "2015-10-02",
"templates": ["In {year}, the CEO of Google was ___"],
},
]
# ============================================================
# ARABIC KNOWLEDGE (Category 5)
# ============================================================
ARABIC_KNOWLEDGE = {
"entity_role_arabic": [
{
"entity": "المملكة العربية السعودية",
"entity_en": "Saudi Arabia",
"relation": "ولي العهد",
"relation_en": "Crown Prince",
"answer": "محمد بن سلمان",
"answer_en": "Mohammed bin Salman",
"stable": True,
"templates_ar": ["في عام {year}، ولي عهد المملكة العربية السعودية هو ___"],
"templates_en": ["In {year}, the Crown Prince of Saudi Arabia was ___"],
},
{
"entity": "سوريا",
"entity_en": "Syria",
"relation": "رئيس",
"relation_en": "leader",
"old_answer_ar": "بشار الأسد",
"new_answer_ar": "أحمد الشرع",
"old_answer_en": "Bashar al-Assad",
"new_answer_en": "Ahmad al-Sharaa",
"stable": False,
"change_date": "2024-12-08",
"templates_ar": [
"في عام {year}، كان رئيس سوريا هو ___",
"من كان يحكم سوريا في عام {year}؟",
],
"templates_en": [
"In {year}, the president of Syria was ___",
"Who ruled Syria in {year}?",
],
},
{
"entity": "المملكة المتحدة",
"entity_en": "United Kingdom",
"relation": "رئيس الوزراء",
"relation_en": "Prime Minister",
"old_answer_ar": "ريشي سوناك",
"new_answer_ar": "كير ستارمر",
"old_answer_en": "Rishi Sunak",
"new_answer_en": "Keir Starmer",
"stable": False,
"change_date": "2024-07-05",
"templates_ar": ["في عام {year}، رئيس وزراء المملكة المتحدة هو ___"],
"templates_en": ["In {year}, the Prime Minister of the UK was ___"],
},
],
"islamic_finance": [
{
"entity": "هيئة المحاسبة والمراجعة للمؤسسات المالية الإسلامية",
"entity_en": "AAOIFI",
"relation": "معايير الصكوك",
"relation_en": "sukuk standards",
"templates_ar": ["معايير هيئة AAOIFI للصكوك الإسلامية تتطلب ___"],
"templates_en": ["AAOIFI standards for Islamic sukuk require ___"],
"knowledge_type": "procedural",
"note": "Connect to SAHM project",
},
],
}
# ============================================================
# WIKIDATA ENDPOINT
# ============================================================
WIKIDATA_ENDPOINT = "https://query.wikidata.org/sparql"
WIKIDATA_USER_AGENT = "KnowledgeDriftResearch/1.0 (academic research)"
RESULTS_PER_QUERY = 200