Header Ads Widget

Responsive Advertisement

TruthScope: How I Built a Political News Bias Analyzer Using Gemini 2.0 Flash

🧩 The Problem: News Without Context

In today’s digital world, millions of people consume news without knowing its bias or credibility. Is this article liberal-leaning? Is it fact-based? Who wrote it? Most readers don’t have the time (or tools) to figure this out.

That’s where TruthScope comes in — my capstone project for the GenAI Intensive Course.

🛠️ My Approach: Gemini + Scrubbed MBFC Dataset

I combined Google's Gemini 2.0 Flash model with a cleaned version of the Media Bias Fact Check (MBFC) dataset to build a tool that does three things:

  • Summarizes any article
  • Detects political bias based on framing and tone
  • Cross-references the news source with a known bias/factuality rating

📜 Under the Hood: What the Code Does

1. I used Gemini to summarize and analyze the article:

def analyze_news_article(article_text):
    model = genai.GenerativeModel("gemini-2.0-flash")
    prompt = f'''
    You are a critical media analyst...

    Article: {article_text}
    '''
    return model.generate_content(prompt).text

2. I extracted the source domain and matched it with the MBFC dataset:

def lookup_source_bias(news_url):
    domain = extract_domain(news_url)
    match = bias_df[bias_df["url"].str.contains(domain, na=False)]
    ...

3. Then I combined everything into a single function to return a full analysis:

def full_news_analysis(article_text, article_url=None):
    gemini_result = analyze_news_article(article_text)
    source_info = lookup_source_bias(article_url)
    return gemini_result, source_info

📊 Sample Output

Given a Fox News article on climate policy, TruthScope returned:

  • A clear summary
  • A right-leaning bias with explanation
  • A "Mixed" factual reporting rating from MBFC

🚧 Limitations & Future Possibilities

While Gemini is powerful, it's not perfect:

  • It may miss subtle biases like tone or omission
  • It cannot access live web content in Kaggle
  • The MBFC dataset, while helpful, is still subjective

In the future, I’d love to:

  • Add multilingual support
  • Enable side-by-side article comparisons
  • Integrate real-time fact-checking APIs
  • Build a Chrome extension for real-time bias detection

✅ Final Thoughts

TruthScope began as a GenAI experiment, but I believe it can grow into a real-world tool for promoting digital literacy and media transparency. It has the potential to empower individuals with smarter, faster, and more responsible ways to consume information.

Special thanks to the teams at Google and Kaggle for this opportunity to explore what's possible with Generative AI.

Publicar un comentario

0 Comentarios