liveBook · Manning

Prompt

As explained in Fight Fraud with Machine Learning

A prompt is text supplied to a generative language model as the conditioning input for producing an output.

A prompt is input supplied to a generative model to condition what it produces. In GPT-style generation, the input words establish a preceding sequence; the decoder then predicts one word or token at a time, adds it to the sequence, and uses the expanded sequence to predict the next token. section 5.2.1

Prompt content can also constrain output format. For phishing triage, an email and an instruction requiring a strictly yes-or-no answer guide ChatGPT toward a usable verdict. Designing such instructions and constraints is prompt engineering. A correct-looking verdict still warrants checking whether the model used relevant email characteristics rather than bluffing. section 5.2.2

Prompts serve different roles across generative workflows:

  • Text generation: a few input words, including a start token, seed a GPT decoder's continuation. section 5.2.1
  • Phishing classification: email text plus an explicit response constraint asks ChatGPT to label an email as phishing or genuine. section 5.2.2
  • Document extraction: the trigger prompt <s> is fed to a DONUT decoder alongside an ID image so generation of the image text can begin. section 7.3.3

Starting structured ID extraction

A fine-tuned DONUT model receives a Slovakian ID image through its encoder and <s> through its decoder. The trigger prompt starts generation of a raw text sequence, which is post-processed into JSON fields such as name, nationality, dates, and ID number. At prediction time, the same task prompt is tokenized and passed as decoder input before calling generation. section 7.3.3 section 7.3.4

Figure 7.27 Schematic of finetuning the DONUT model on the labeled Slovakian ID dataset. Inputs to the DONUT model are the Slovakian ID image (to the encoder) as well as a prompt text (to the decoder). The prompt text triggers the decoder to start generating the text that is written inside the ID image. Raw generated text is in a DONUT-friendly format which is then converted to JSON format.

This diagram shows the split inputs: an ID image enters the encoder, while prompt text enters the decoder to trigger generated extraction text before JSON conversion. section 7.3.3

How Fight Fraud with Machine Learning covers it

How deep it goes
Explains autoregressive next-token generation and implements a decoder trigger prompt, without detailing prompt-optimization methods.
Examples
Illustrates constrained phishing and genuine-email verdicts plus Slovakian-ID extraction initiated by <s>.
What it assumes
Introduces prompts through input-word examples; assumes a signed-in ChatGPT session for out-of-box testing.
What you can do after
Apply it via ChatGPT for constrained phishing verdicts and via DONUT to initiate ID-text extraction.
How it connects
Connects prompts to prompt engineering, phishing detection, and DONUT-based ID extraction.

Also explained in

Compare how 64 books explain prompt →

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.