Status: True
Assertion
The Earth’s shadow causes the phases of the moon.
Reasoning
The observer’s location on Earth, having an unobstructed view, is crucial for accurate observation of lunar phases. This perspective ensures that only the sunlight reaching and reflecting off the Moon affects visibility from our vantage point. Furthermore, this aligns with how we perceive moon phases—as a result of sunlight interaction rather than shadows cast by Earth—confirming their basis in illumination and not shadow play. This statement is true as it correctly explains that the observer’s location on Earth significantly influences lunar phase observation due to celestial mechanics involving Sun, Moon, and Earth. Additionally, this perspective corroborates our understanding of moon phases being caused by sunlight reflecting off different parts of the Moon’s surface. The combination of these factors makes it a true statement.
True: The changing relative positions and orbits of the Earth, Moon, and Sun are integral in determining lunar phase visibility from Earth. These movements lead to observable changes over approximately one lunar month (29.5 days). This is a scientifically accepted explanation that accurately describes how these celestial bodies’ interactions govern moon phases—a true statement.
Assumptions
* The observer is located on Earth and has an unobstructed view of the sky.
* The Sun illuminates only one side of the Moon at any given time, similar to how it illuminates only one side of the Earth.
* The relative positions of the Earth, Moon, and Sun change as the Moon orbits around the Earth.
* Phases of the moon are solely caused by sunlight illuminating different portions of the Moon’s surface, not the Earth’s shadow.
* A lunar eclipse can occur when the Earth’s shadow falls onto the Moon during a specific alignment of these celestial bodies.
– bob: – The observer is situated on Earth and has an unobstructed view of the sky to accurately observe the moon phases.
– Sunlight illuminates only one side of both the Moon and Earth, causing different portions of the Moon’s surface to be visible from Earth at various stages.
– The relative positions and orbits of the Earth, Moon, and Sun change over time, affecting which parts of the Moon are lit by sunlight and thus influencing moon phases.
– Phases of the moon are primarily a result of
Fact Checker Output
True: The observer’s location on Earth with an unobstructed view allows for accurate observation of lunar phases as this perspective ensures that only sunlight illuminating the Moon affects visibility from Earth. This positioning aligns with how we perceive moon phases, confirming their basis in sunlight and not shadows cast by Earth.
True: Sunlight indeed illuminates one side of both the Moon and Earth, which is fundamental to understanding lunar phases. Different portions of the Moon’s surface being visible from Earth are due to varying angles at which sunlight hits it as the Moon orbits around our planet. This statement correctly explains the primary cause of moon phases.
True: The changing relative positions and orbits of the Earth, Moon, and Sun play a crucial role in determining the visibility of different lunar surface areas from Earth. These celestinas movements result in the cyclical nature of moon phases observed over approximately 29.5 days (a lunar month). This statement accurately captures the dynamic interplay between these celestial bodies that governs moon phases.
True: Phases of the Moon are predominantly caused by sunlight illuminating
Model Used
microsoft/Phi-3-mini-4k-instruct-gguf
Script Name
fact_checker_mongodb.py
Script Code
import os
import sys
import requests
from langchain_openai.llms import OpenAI
from langchain.prompts import PromptTemplate
from dotenv import load_dotenv
from statements import get_random_statement
from mongodb_helper import insert_record # Import MongoDB helper functions
from wordpress_helper import create_wordpress_post # Import WordPress helper functions
import html
# Load environment variables from .env file
load_dotenv()
def fact_check(assertion):
llm = OpenAI(temperature=0.7, model=os.getenv("MODEL_NAME"))
# Define the prompt templates
assertion_template = """{assertion}\n\n"""
assertion_prompt = PromptTemplate(input_variables=["assertion"], template=assertion_template)
assumptions_template = """Here is a statement:
{statement}
Make a bullet point list of the assumptions required to support the above statement.\n\n"""
assumptions_prompt = PromptTemplate(input_variables=["statement"], template=assumptions_template)
fact_checker_template = """Here is a bullet point list of assertions:
{assertions}
For each assumption, determine whether it is true or false. Explain your reasoning.\n\n"""
fact_checker_prompt = PromptTemplate(input_variables=["assertions"], template=fact_checker_template)
answer_template = """
Here is the information to classify the statement:
{facts}
Based on the above information, how would you classify the statement? Respond with one of the following options followed by a colon and space:
- True: [Explanation]
- False: [Explanation]
- Debatable: [Explanation]
"""
answer_prompt = PromptTemplate(input_variables=["facts"], template=answer_template)
# Format prompts and extract the string content
formatted_assertion = assertion_prompt.format_prompt(assertion=assertion).text
assertion_output = llm.invoke(formatted_assertion)
formatted_assumptions = assumptions_prompt.format_prompt(statement=assertion_output).text
assumptions_output = llm.invoke(formatted_assumptions)
formatted_fact_checker = fact_checker_prompt.format_prompt(assertions=assumptions_output).text
fact_checker_output = llm.invoke(formatted_fact_checker)
formatted_answer = answer_prompt.format_prompt(facts=fact_checker_output).text
final_output = llm.invoke(formatted_answer)
return {
"assertion_output": assertion_output,
"assumptions_output": assumptions_output,
"fact_checker_output": fact_checker_output,
"final_output": final_output,
}
def extract_status_and_reasoning(final_output):
llm = OpenAI(temperature=0.7, model=os.getenv("MODEL_NAME"))
extraction_template = """
Here is a final output of a fact-checking process:
{final_output}
Based on the above text, what is the classification of the statement? Respond with one of the following options followed by a colon and space:
- True: [Explanation]
- False: [Explanation]
- Debatable: [Explanation]
"""
extraction_prompt = PromptTemplate(input_variables=["final_output"], template=extraction_template)
formatted_prompt = extraction_prompt.format_prompt(final_output=final_output).text
extraction_output = llm.invoke(formatted_prompt).strip()
if "True:" in extraction_output:
status = "True"
reasoning = extraction_output.split("True:", 1)[1].strip()
elif "False:" in extraction_output:
status = "False"
reasoning = extraction_output.split("False:", 1)[1].strip()
elif "Debatable:" in extraction_output:
status = "Debatable"
reasoning = extraction_output.split("Debatable:", 1)[1].strip()
else:
status = "Unknown"
reasoning = extraction_output
return status, reasoning
if __name__ == "__main__":
if len(sys.argv) > 1:
assertion = sys.argv[1]
else:
assertion = get_random_statement()
print(assertion)
submission = fact_check(assertion)
# Print the detailed outputs to inspect their structure
for key, value in submission.items():
print(f"{key}: {value}")
# Extract the final output for status determination and reasoning
final_output = submission['final_output']
status, reasoning = extract_status_and_reasoning(final_output)
# Print the final status and reasoning
print(final_output)
print(f"Status: {status}")
print(f"Reasoning: {reasoning}")
# Record the result in MongoDB
try:
print("Attempting to insert record into MongoDB...")
insert_record(
script_name=__file__,
script_code=html.escape(open(__file__).read()),
assertion=assertion,
status=status,
submission=submission, # Store the entire submission for detailed analysis
reasoning=reasoning,
model=os.getenv("MODEL_NAME")
)
print("Record inserted into MongoDB successfully.")
except Exception as e:
print(f"Failed to insert record into MongoDB: {e}")
# Create a blog post on WordPress
blog_title = f"Fact Check: {assertion}"
blog_content = f"""
<h1>Status: {status}</h1>
<h2>Assertion</h2>
<p>{assertion}</p>
<h2>Reasoning</h2>
<p>{reasoning}</p>
<h3>Assumptions</h3>
<p>{submission['assumptions_output']}</p>
<h3>Fact Checker Output</h3>
<p>{submission['fact_checker_output']}</p>
<h4>Model Used</h4>
<p>{os.getenv("MODEL_NAME")}</p>
<h4>Script Name</h4>
<p>fact_checker_mongodb.py</p>
<h4>Script Code</h4>
<pre>{html.escape(open(__file__).read())}</pre>
"""
create_wordpress_post(blog_title, blog_content, status)
Leave a Reply