Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦠 Misinformation Drift Detector

Message Propagation & Semantic Mutation Analyzer

An end-to-end Machine Learning pipeline designed to track, quantify, and visualize how factual information mutates into dangerous misinformation as it propagates through social networks. This system uses HuggingFace Transformers, Graph theory, and XGBoost to calculate a live "Threat Level" for forwarding chains.


📸 Demo & Screenshots

App Screenshot App Screenshot


🛠️ Tech Stack

Frontend & Visualization

  • Streamlit: Interactive web framework.
  • Plotly: Live network graph rendering.
  • Custom HTML/CSS: WhatsApp-style responsive chat UI with difflib text highlighting.

Machine Learning & NLP (Local Inference)

  • HuggingFace Transformers: cross-encoder/nli-distilroberta-base (Zero-shot exaggeration detection).
  • SentenceTransformers: all-MiniLM-L6-v2 (Semantic drift via cosine similarity).
  • XGBoost: XGBClassifier (Probability scoring for misinformation risk).
  • NetworkX: Graph topology and propagation depth modeling.
  • Data Processing: Pandas, NumPy, Scikit-learn.

🧠 Architecture & Approach

This system abandons black-box LLM APIs in favor of a robust, deterministic, and locally-hosted architecture split into two distinct pipelines:

  1. Offline Training Pipeline: Ingests highly nested, non-linear social media threads (e.g., the PHEME dataset). It utilizes Transformer embeddings and Graph metrics to engineer features like Information Mutation Rate and Semantic Drift, training an XGBoost classifier to output a calibrated risk probability.
  2. Online Inference Engine: A real-time Streamlit dashboard that simulates social media spread. It feeds messages one-by-one into the inference engine, calculating live feature deltas and updating the UI dynamically without recalculating the entire graph.

🔄 System Process Flow

  1. Scenario Selection: User selects a pre-loaded dataset (e.g., Sydney Siege) or inputs a custom rumor chain.
  2. NLP Feature Extraction: The message is passed through DistilRoBERTa and MiniLM to extract semantic embeddings and zero-shot panic/conspiracy probabilities.
  3. Graph Topology Update: NetworkX updates the directed acyclic graph (DAG) to calculate the message's hop depth and branching factor.
  4. Threat Scoring: The engineered feature vector [semantic_drift, exaggeration_score, graph_depth, mutation_rate] is passed to the cached XGBoost model.
  5. UI Rendering: The dashboard updates the Live Threat Meter, plots the new node on the Plotly graph, and highlights the mutated text in red inside the WhatsApp-style chat interface.

📂 Project Structure

misinformation-drift-detector/
│
├── app/
│   └── app.py        # Streamlit frontend & simulation loop
│
├── data/
│   ├── raw/                      # Optional: Raw dataset JSONs
│   └── models/
│       └── xgb_model.pkl         # Trained XGBoost artifact
│
├── demo/                         # Screenshots for README
│
├── src/
│   ├── __init__.py
│   ├── data_model.py             # Message dataclass definition
│   ├── graph_model.py            # NetworkX graph topology engine
│   │
│   ├── data_pipeline/
│   │   └── dataset_parser.py     # Parses complex thread trees (PHEME format)
│   │
│   ├── ml/
│   │   ├── feature_engineer.py   # Maps text/graph data to tabular Pandas structures
│   │   └── train_model.py        # XGBoost training and evaluation script
│   │
│   └── nlp/
│       └── transformer_engine.py # HuggingFace inference pipelines
│
├── requirements.txt
├── .gitignore
└── README.md

🚀 Setup Instructions

1. Clone the repository

git clone [https://github.com/yourusername/misinformation-drift-detector.git](https://github.com/yourusername/misinformation-drift-detector.git)
cd misinformation-drift-detector

2. Create and activate a virtual environment

# Windows
python -m venv venv
venv\Scripts\activate

# Mac/Linux
python3 -m venv venv
source venv/bin/activate

3. Install dependencies Note: This project uses the CPU-only version of PyTorch for maximum compatibility and lightweight deployment.

pip install torch torchvision torchaudio --index-url [https://download.pytorch.org/whl/cpu](https://download.pytorch.org/whl/cpu)
pip install -r requirements.txt

4. Train the ML Model (Offline Pipeline) Before running the app, you must train the XGBoost classifier to generate the .pkl artifact.

python src/ml/train_model.py

5. Launch the Application

streamlit run app/app.py

About

AI-powered misinformation propagation simulator that analyzes semantic drift, exaggeration, and viral spread across social networks using NLP and transformer models.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages