liveBook · Manning

Prompt engineering

As explained in Fight Fraud with Machine Learning

Prompt engineering is the deliberate design and modification of inputs provided to a generative model to elicit desired outputs or behavior.

Prompt engineering deliberately designs and modifies inputs to guide a generative model toward a desired output or behavior. In phishing detection, specifying a strictly yes-or-no response improves formatting, while removing that constraint invites an explanation of suspicious email characteristics. section 5.2.2 section 5.2.3

A practical prompt-engineering workflow includes:

  • Define the expected response format, such as a strictly yes-or-no classification. section 5.2.2
  • Remove or revise constraints when a rationale is needed, allowing the model to list suspicious email characteristics. section 5.2.3
  • Supply one representative genuine or phishing email before asking the model to classify a new message; this is one-shot prompting. section 5.2.4
  • Pass complete email data and a classification prompt to an API when embedding detection in software. section 5.2.4

Teaching detection of a ghost domain

ChatGPT initially treats an email from the nonexistent domain emailinspector.net as genuine. A prompt containing examples of genuine and phishing emails enables it to recognize the same message as phishing, illustrating one-shot prompting. section 5.2.4

Figure 5.18 One-shot prompting to teach ChatGPT to catch a particular kind of phishing email from a specific domain.

Shows one-shot prompting applied to a particular phishing pattern from a specific domain. section 5.2.4

How Fight Fraud with Machine Learning covers it

How deep it goes
Explains output constraints, rationale requests, one-shot examples, and API use, but does not develop model internals or systematic evaluation.
Examples
Uses suspicious and genuine emails, a nonexistent emailinspector.net domain, yes-or-no prompts, explanations, and one-shot demonstrations.
What it assumes
Assumes access to ChatGPT or an LLM and email examples, while introducing prompt terminology, one-shot learning, and API-based use.
What you can do after
Apply it via prompts or an API to classify emails, request rationales, and improve recognition of narrowly represented phishing patterns.
How it connects
Connects prompt engineering to phishing detection, large language models, one-shot learning, few-shot learning, APIs, HuggingFace, and LangChain.

Also explained in

Compare how 51 books explain prompt engineering →

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.