7 Detecting phishing with LLM

 

This chapter covers

  • Using deep learning to detect email phishing
  • How does ChatGPT work? How to use it for phishing detection
  • Using HuggingFace to access state-of-the-art LLMs
  • Using LangChain to detect phishing with any LLM
  • Building a phishing detection app using Gradio

. ChatGPT will be remembered as an important turning point in the way we interface with AI in the 21st century. At a high level, it is a chatbot to make conversations with. It can understand and generate human-like text. Anyone (with an email ID) can sign up to access the free version at https://chat.openai.com/. I asked ChatGPT a question – Can we eliminate fraud from this world? And, as you can see in figure 7.1, it generates a detailed answer identifying the challenges in completely eradicating fraud as well as providing foundational measures needed to combat fraud which includes using AI (machine learning) - something this book is all about.

ChatGPT is powered by a deep learning model – a transformer model to be precise – a generative pre-trained transformer (GPT) model to be more precise. The model is trained on huge volumes of text from all over the internet with the objective of language modeling - the task of figuring out the next word given a preceding sequence of words. This is why models like GPT are categorized as large language models (LLMs) - large representing the immense volume of data the model is trained on.

7.1 Deep learning versus classical ML for phishing detection

7.2 Email phishing detection using ChatGPT

7.2.1 How does ChatGPT work?

7.2.2 Using ChatGPT out of the box for phishing detection

7.2.3 Interpreting ChatGPT’s phishing detection

7.2.4 Using prompt engineering to improve phishing detection with ChatGPT

7.3 Using HuggingFace and LangChain to programmatically detect phishing with LLMs

7.3.1 Using LangChain on Google’s Flan-T5 model from HuggingFace

7.3.2 Running multiple requests on LangChain

7.4 Building PhiDeL – a phishing detector app using LangChain, GPT4All, and Gradio

7.4.1 Loading a Mistral LLM model from GPT4All

7.4.2 Using Mistral LLM to detect phishing

7.4.3 Building phishing detection app using Gradio

7.5 Fraud - a cat-and-mouse game

7.6 Summary