/fake_news_detection

A collection of PyTorch Lightning models for fake news detection.

Primary LanguagePython

Fake News Detection

PyTorch Lightning Config: Hydra Template

Description

A collection of PyTorch Lightning models for fake news detection.

How to run

Install dependencies

# clone project
git clone https://github.com/KLOSYX/fake_news_detection.git
cd fake_news_detection

# [OPTIONAL] create conda environment
conda create -n myenv python=3.9
conda activate myenv

# install pytorch according to instructions
# https://pytorch.org/get-started/

# install requirements
pip install -r requirements.txt

Preprocess data

# download data
# twitter: https://github.com/MKLab-ITI/image-verification-corpus
# weibo: https://drive.google.com/file/d/14VQ7EWPiFeGzxp3XC2DeEHi-BEisDINn/view?usp=sharing
# extract the data to the data folder

# preprocess twitter data
python data/preprocess_twitter.py
# preprocess weibo data
python data/preprocess_weibo.py

Train model with default configuration

# train on CPU
python src/train.py trainer=cpu

# train on GPU
python src/train.py trainer=gpu

Train model with chosen experiment configuration from configs/experiment/

python src/train.py experiment=experiment_name.yaml

You can override any parameter from command line like this

python src/train.py trainer.max_epochs=20 datamodule.batch_size=64

Available models

SpotFake

# on weibo dataset
python src/train.py experiment=spotfake_weibo

# on twitter dataset
python src/train.py experiment=spotfake_twitter

Reference:

BDANN

# on weibo dataset
python src/train.py experiment=bdann_weibo

# on twitter dataset
python src/train.py experiment=bdann_twitter

Reference:

  • xiaolan98/BDANN-IJCNN2020
  • Zhang, T., Wang, D., Chen, H., Zeng, Z., Guo, W., Miao, C., & Cui, L. (n.d.). BDANN: BERT-Based Domain Adaptation Neural Network for Multi-Modal Fake News Detection. 9.