liveBook · Manning

Prompt engineering

As explained in Deep Learning with Python, Third Edition

The practice of crafting prompts to elicit better performance from a large language model on a task.

Prompt engineering crafts prompts to improve a large language model’s performance, especially when small wording changes can alter the result dramatically. section 19.1.2

A small wording change can change the answer

In the Alice in Wonderland riddle, an LLM often answers correctly with familiar values but fails after changing the values of M and N. Adding “Please think step by step” can improve performance on reasoning tasks. section 19.1.2

Use prompt engineering as a practical set of checks:

  • Test alternate wording instead of assuming one successful prompt is reliable. section 19.1.2
  • Add explicit reasoning instructions when the task involves reasoning. section 19.1.2
  • Separate the requested knowledge from extra behavior, such as asking for Python sorting explained in a particular style. section 19.1.2
  • Treat prompts as task-specific queries rather than substitutes for special-purpose programming or retraining. section 1.8

The technique improves access to capabilities already represented in a foundation model, but its sensitivity to minor rewordings also exposes limits in apparent understanding. section 1.8 section 19.1.2

How Deep Learning with Python, Third Edition covers it

How deep it goes
Defines phrasing sensitivity, gives a riddle and instruction example, and stops short of a systematic prompt-design procedure.
Examples
Uses the Alice riddle, altered variable values, step-by-step instructions, and Python list sorting with a requested style.
What you can do after
Apply it via deliberate prompt variation and explicit instructions to improve task performance and test reliability.
How it connects
Connects prompting with large language models, foundation models, self-supervised learning, latent representations, and style transfer.

Also explained in

Compare how 38 books explain prompt engineering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.