liveBook · Manning

Language model

As explained in Fight Fraud with Machine Learning

A large language model is a language model trained on a very large text corpus, typically with many learned parameters, to process and generate human language.

A large language model (LLM) learns patterns in text by training on huge volumes of language data. Its core task is language modeling: estimate which word or word sequence is likely to follow a preceding sequence. GPT is a transformer-based LLM that generates text autoregressively, one next-token prediction at a time. section 5.0 section 5.2.1

Figure 5.7 Toy example of how an LLM predicts the next word (given the preceding words) by sampling from a distribution of likely words. In this example, the LLM always chooses the most likely next word – called the greedy search approach.

A next-word distribution makes the central behavior concrete: given preceding words, the model assigns likely continuations and can select the most likely one with greedy search. section 5.2.1

Learning which words occur together lets an LLM produce human-like text and support translation, summarization, question answering, and sentiment analysis. That broad text capability can be redirected to fraud work, including deciding whether an email is phishing or genuine. section 5.0 section 5.2.1

Phishing classification with prompting

An LLM can initially misclassify a phishing email. One-shot prompting supplies one genuine-email example and one phishing-email example before the target email, enabling ChatGPT to recognize a previously missed pattern. An application can send full email data and a detection prompt to the ChatGPT API, then use its yes/no result, explanation, or requested confidence score; a confidence threshold can tune precision, recall, and pass rate. section 5.2.4

LLMs can be put into a phishing workflow in two practical ways:

  • Use HuggingFace-hosted models from Python; access requires a HuggingFace account and API token. section 5.3
  • Use LangChain to run prompts and one-shot or few-shot prompt-engineering workflows. section 5.3
  • Load a locally downloaded Mistral model through GPT4All and LlamaCpp, avoiding an API token; configure model path, context length, batching, GPU layers, and temperature. section 5.4.1

How Fight Fraud with Machine Learning covers it

How deep it goes
Explains next-word probabilities and prompting, then demonstrates hosted and local inference rather than building an LLM from scratch.
Examples
Uses ChatGPT conversations, next-word completion, a missed phishing email, one-shot prompting, and a locally loaded Mistral model.
What it assumes
Introduces language modeling from a word-completion example while requiring Python dependencies and model-access setup for implementation.
What you can do after
Apply it via ChatGPT, HuggingFace, LangChain, or LlamaCpp to classify phishing emails and tune confidence-based decisions.
How it connects
Connects LLMs with language modeling, transformers, prompt engineering, one-shot learning, phishing detection, precision, and recall.

Also explained in

Compare how 89 books explain language model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fight Fraud with Machine Learning. The section links point to the parts of the book it draws on.