Skip to content

100rabhsah/FakeNews

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Hybrid Fake News Detection Model

A hybrid deep learning model for fake news detection using BERT and BiLSTM with attention mechanism.

Project Overview

This project implements a state-of-the-art fake news detection system that combines the power of BERT (Bidirectional Encoder Representations from Transformers) with BiLSTM (Bidirectional Long Short-Term Memory) and attention mechanisms. The model is designed to effectively identify fake news articles by analyzing their textual content and linguistic patterns.

Data and Model Files

The project uses the following datasets and model files:

Datasets

  • Raw and processed datasets are available at: Data Files
    • Contains both raw and processed versions of the datasets
    • Includes LIAR and Kaggle Fake News datasets
    • Preprocessed versions ready for training

Model Files

  • Trained model checkpoints are available at: Model Files
    • Contains saved model weights
    • Includes best model checkpoints
    • Model evaluation results

Project Structure

.
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ raw/           # Raw datasets
β”‚   └── processed/     # Processed data
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ saved/        # Saved model checkpoints
β”‚   └── checkpoints/  # Training checkpoints
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/       # Configuration files
β”‚   β”œβ”€β”€ data/         # Data processing modules
β”‚   β”œβ”€β”€ models/       # Model architecture
β”‚   β”œβ”€β”€ utils/        # Utility functions
β”‚   └── visualization/# Visualization modules
β”œβ”€β”€ tests/            # Unit tests
β”œβ”€β”€ notebooks/        # Jupyter notebooks
└── visualizations/   # Generated plots and graphs

Features

  • Hybrid architecture combining BERT and BiLSTM
  • Attention mechanism for better interpretability
  • Comprehensive text preprocessing pipeline
  • Support for multiple feature extraction methods
  • Early stopping and model checkpointing
  • Detailed evaluation metrics and saved reports (evaluation_report.json)
  • Reproducible runs via global seeding
  • Mixed-precision (AMP) training and linear warmup scheduler
  • Optional TensorBoard logging (runs/hybrid_model)
  • Interactive visualizations of model performance
  • Support for multiple datasets (LIAR, Kaggle Fake News)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/fake-news-detection.git
cd fake-news-detection
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Usage

  1. Download the required files:

    • Download datasets from the Data Files link
    • Download pre-trained models from the Model Files link
    • Place the files in their respective directories as shown in the project structure
  2. Prepare your dataset:

    • Place your dataset in the data/raw directory
    • The dataset should have at least two columns: 'text' and 'label'
    • Supported formats: CSV, TSV
  3. Train the model:

python src/train.py
  1. Outputs:

    • Final weights: models/saved/final_model.pt
    • Best checkpoint (val F1): models/checkpoints/best_model.pt
    • Metrics JSON: evaluation_report.json
    • Plots: visualizations/ (history, confusion matrix, comparison, feature importance)
    • TensorBoard logs (optional): runs/hybrid_model
  2. (Optional) Launch TensorBoard to inspect logs:

tensorboard --logdir runs/hybrid_model

Model Architecture

The model combines:

  • BERT for contextual embeddings
  • BiLSTM for sequence modeling
  • Attention mechanism for focusing on important parts
  • Classification head for final prediction

Key Components:

  • BERT Layer: Extracts contextual word embeddings
  • BiLSTM Layer: Captures sequential patterns
  • Attention Layer: Identifies important text segments
  • Classification Head: Makes final prediction

Configuration

Key parameters can be modified in src/config/config.py:

  • Model hyperparameters
  • Training parameters
  • Data processing settings
  • Feature extraction options

Performance Metrics

The model is evaluated using:

  • Accuracy
  • Precision
  • Recall
  • F1 Score
  • Confusion Matrix

Future Improvements

  • Add support for image/video metadata
  • Implement real-time detection
  • Add social graph analysis
  • Improve model interpretability
  • Add API endpoints for inference
  • Support for multilingual fake news detection
  • Integration with fact-checking databases

Acknowledgments

I would like to express our sincere gratitude to Dr. Kirti Kumari for her invaluable guidance and support throughout the development of this project. Her expertise in data mining and machine learning has been instrumental in shaping this work.

Special thanks to:

  • Open-source community for their excellent tools and libraries
  • Dataset providers (LIAR, Kaggle)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For any queries or suggestions, please feel free to reach out to me.

About

πŸš€ A hybrid deep learning model for fake news detection using BERT and BiLSTM with attention mechanism.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors