Skip to content

Detecting Neural Fake News and Synthetic Text on Twitter using fine-tuned language models

Notifications You must be signed in to change notification settings

BenF99/Twitter-NFN-Detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitter-NFN-Detector

A project created during my final year at university that provides a system to detect neural fake news/machine-generated Text on Twitter.

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage

About The Project

https://twitter-nfn-bf.anvil.app/

Dissertation Abstract

Neural Fake News (NFN), defined as neurally-generated misinformation masquerading as legitimate news, can be a critical societal issue. In recent years, unsupervised language models (ULMs) such as Generative Pre-trained Transformer-2 (GPT-2) have proven to generate extremely coherent paragraphs of text. These systems enable malicious actors to scale up their operations by delivering automatically generated disinformation across social media. Developing defence mechanisms against NFN is critical in preventing sites such as Twitter falling victim to an upsurge in the spread of synthetic text. I thus present a system that detects machine generated text that is broadcasted on Twitter, utilising fine-tuned pre-trained language models (PTLM) trained on the classification of outputs released with GPT-2. My system applies the weights released with the OpenAI detector model and two fine-tuned models: DeBERTa and XLNet, to classify real (human-written) and fake (machine-generated) text. I find that DeBERTa achieves a 96% classification accuracy with limited resources, competing with the OpenAI detector model that achieved ~95% across three sampling methods. I argue that with access to more powerful hardware capable of processing large sequence lengths, fine-tuning DeBERTa will likely outperform OpenAI’s detector. I also investigate the presence of machine-generated tweets on Twitter and find that they are not currently ubiquitous on social media. I conclude by discussing the importance of research into the detection of machine generated content and suggest that social media platforms implement classification systems as natural language generative models popularise.

Built With

Getting Started

Prerequisites

  1. Install models and fine-tuned weights:

OpenAI RoBERTa Detector:

wget https://openaipublic.azureedge.net/gpt-2/detector-models/v1/detector-base.pt

Model: https://huggingface.co/roberta-large

Fine-tuned DeBERTa-large - (5e-6, batch: 16, epochs: 4, warmup: 50, decay: 0.01)

https://drive.google.com/drive/folders/1P-EewnfcXvQR5UVzgavB9I_py1YFwQc7?usp=sharing

MCC: 0.913 | Accuracy: 0.956

Model: https://huggingface.co/microsoft/deberta-large

Fine-tuned XLNet-large-cased - (1e-5, batch: 16, epochs: 2, warmup: 100):

https://drive.google.com/drive/folders/1vtJ7Q2GqtOpNM7iIO5nX06we3BQJxUNr?usp=sharing

MCC: 0.771 | Accuracy: 0.878

Model: https://huggingface.co/xlnet-large-cased

(XLNet and DeBERTa were fine-tuned on the outputs from the 1.5B GPT-2 model (xl-1542M) versus WebText, the dataset used to train the GPT-2 model)

  1. Registration:

Installation

  1. Download models + fine-tuned weights and store in an accessible location

  2. Generate FireBase SDK Private Key and place credentials file within Project_Main

  3. Initialize realtime database with fake and real nodes (example)

  4. Clone the anvil app:

    https://anvil.works/build#clone:YG6YJDUEBCRAHCKA=Y4ALXWHEKMF34YBT4GEPCXJM
  5. Set Anvil UPLINK key in main_.py and Twitter API keys in TweetGetter.py

  6. Run the server file:

# (on the top-level directory of this repository)
pip install -r requirements.txt
python -m main_
  1. Visit the anvil application link!

Usage

Load Tweet: Pressing 'Load Tweet' requests and classifies (fake/real probablities) the latest available Tweet containing "#news", unless specified otherwise

Custom Input: Selecting the 'Custom Input' checkbox provides the option to provide a Twitter URL or any arbitrary input to be classified (fake/real probablities)

About

Detecting Neural Fake News and Synthetic Text on Twitter using fine-tuned language models

Resources

Stars

Watchers

Forks

Languages