liveBook · Manning

Prompt engineering

As explained in Introduction to Generative AI, Second Edition

Prompt engineering is the deliberate design of inputs to guide a generative model's behavior or output.

A request to “summarize this” might get a vague answer. Asking for “a one-paragraph executive summary highlighting three key risks for a cybersecurity executive” gives a language model a clearer purpose, audience, and format. Prompt engineering is the deliberate crafting of inputs to guide a generative model’s response. Wording, relevant context, and selected information all matter; small changes can produce surprisingly different results. section 7.1

Prompting guides a model without retraining it. A prompt can state the task, supply background or reference material, give examples, and specify how the answer should be structured. Clear instructions may be enough for a straightforward request; harder tasks may benefit from being divided into steps. section 7.1 section 7.2

Common approaches address different needs:

  • Clarify an ambiguous request by naming the audience, purpose, and output format. section 7.1
  • Provide reference material when factual accuracy matters, and ask the model to acknowledge uncertainty rather than guess. These measures can help, but cannot guarantee a correct answer. section 7.1 section 5.7
  • Give a few examples of the desired response, or ask for steps when a task calls for multistep reasoning. Such reasoning prompts have helped earlier models, though newer models may need less scaffolding. section 7.1 section 7.4
  • Set tone and boundaries explicitly when the response must suit a particular role; divide a complex request into subtasks when a single instruction is insufficient. section 7.1
Table 7.1 Prompting strategies for common LLM challenges

Challenge

Prompting strategy

Example prompt

Ambiguity

Add context, clarify user intent, and specify output format

“Summarize the following memo in three bullet points for a technical project manager.”

Hallucination

Provide reference material; use step-by-step reasoning

“Based on the attached report, explain the drug’s mechanism of action step by step.”

Misalignment

Set tone, role, and boundaries explicitly

“You are a professional HR advisor. Provide neutral guidance and avoid offering legal advice.”

Complexity

Break the task into steps or chain prompts

“First, list all relevant deadlines from the document, then summarize their impact on project timelines.”

Compare sample prompts for ambiguity, hallucination, misalignment, and complexity; each pairs a problem with a practical way to structure the request. section 7.1

Treat prompt development as a cycle: draft a prompt, test its responses, evaluate them against examples of the intended task, and revise. Comparing versions across representative situations is more dependable than judging one impressive answer. Teams may track prompt versions and performance metrics for systematic testing. section 7.12 section 7.6

When one instruction is too blunt

Suppose a chatbot gives a long history when asked for the date of Mother’s Day. “Answer as concisely as possible” might fix that question but make its answer to “Where did Mother’s Day come from?” unhelpfully short. Testing both questions exposes the trade-off and gives the next revision a clearer goal. section 7.11

Prompting is accessible and often sufficient, but it is an imprecise control: a small wording change can have unintended effects. Post-training—additional training to change model behavior—can target narrower changes but requires data and technical work. Prompt design can still be part of that process. Nor is it a complete answer to concerns such as bias: mitigation also involves training data, evaluation, and output auditing. section 7.11 section 3.2

How Introduction to Generative AI, Second Edition covers it

How deep it goes
Develops practical strategies and a draft-test-evaluate-revise process, while acknowledging that prompt effects remain imperfectly understood.
Examples
Uses an executive-summary request, challenge-specific sample prompts, and a chatbot whose answers become too long or too short.
What it assumes
Introduces prompting through plain-language requests and explains its distinction from additional model training.
What you can do after
Practice/perform prompt design by testing revisions against representative requests and evaluating whether responses meet the intended goal.
How it connects
Connects few-shot prompting, chain-of-thought prompting, hallucination, evaluation, post-training, and bias mitigation.

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 Introduction to Generative AI, Second Edition. The section links point to the parts of the book it draws on.