CoolFace
Apppublic

adnaan05/TruthCheck

sourceHugging Facemitupdated 1y agoView on Hugging Face
2likes
App README

TruthCheck: Fake News Detection with Fine-Tuned BERT

TruthCheck is an advanced fake news detection system leveraging a hybrid deep learning architecture. It combines a pre-trained BERT-base-uncased model with a BiLSTM and attention mechanism, fully fine-tuned on a curated dataset of real and fake news. The project includes robust preprocessing, feature extraction, model training, evaluation, and a Streamlit web app for interactive predictions.


๐Ÿš€ Features

  • โ€”Hybrid Model: BERT-base-uncased + BiLSTM + Attention
  • โ€”Full Fine-Tuning: All layers of BERT and additional layers are trainable and optimized on the fake news dataset
  • โ€”Comprehensive Preprocessing: Cleaning, tokenization, lemmatization, and more
  • โ€”Training & Evaluation: Scripts for training, validation, and test evaluation
  • โ€”Interactive App: Streamlit web app for real-time news classification
  • โ€”Ready for Deployment: Easily extendable for research or production

๐Ÿง  Model Details

  • โ€”Base Model: BERT-base-uncased
  • โ€”Architecture:
  • โ€”BERT encoder (pre-trained, all layers fine-tuned)
  • โ€”BiLSTM layer for sequential context
  • โ€”Attention mechanism for interpretability
  • โ€”Fully connected classification head
  • โ€”Fine-Tuning Technique:
  • โ€”All BERT layers are unfrozen and updated during training (full fine-tuning)
  • โ€”Additional layers (BiLSTM, attention, classifier) are trained from scratch

๐Ÿ“ฅ Download Data and Model

Raw and Processed Datasets: Google Drive Link

Trained Model(s): Google Drive Link

Instructions:

  1. 1.Download the datasets and place them in the data/ directory:
  2. 2.data/raw/ for raw files
  3. 3.data/processed/ for processed files
  4. 4.Download the trained model (e.g., final_model.pt or best_model.pt) and place it in models/saved/.

โš™๏ธ Setup

  1. 1.Clone the repository:
bash
    git clone https://github.com/adnaan-tariq/fake-news-detection.git
    cd fake-news-detection
  1. 1.Create and activate a virtual environment:
bash
    python -m venv venv
    .\venv\Scripts\activate
  1. 1.Install dependencies:
bash
    pip install --upgrade pip
    pip install -r requirements.txt

๐Ÿƒโ€โ™‚๏ธ Usage

Train the Model

If you want to train from scratch (after placing the data as described above):

bash
python -m src.train

Run the Streamlit App

bash
streamlit run app.py

Test the Model

  • โ€”The app and scripts will use the model in models/saved/final_model.pt by default.
  • โ€”For custom inference, see the example in src/app.py or ask for a sample script.

๐Ÿ“Š Results

  • โ€”Validation Accuracy: ~93%
  • โ€”Validation F1 Score: ~0.93
  • โ€”(See training logs and visualizations for more details.)

๐Ÿ“ฆ Data & Model Policy

  • โ€”Data and model files are NOT included in this repository.
  • โ€”Please download them from the provided Google Drive links above.

๐Ÿค Contributing

Pull requests and suggestions are welcome! For major changes, please open an issue first to discuss what you would like to change.


๐Ÿ“„ License

This project is licensed under the MIT License.