liveBook · Manning

Prompt engineering

As explained in Effective Conversational AI

Prompt engineering is the design of instructions, context, examples, and input data supplied to a language model to influence its output.

A chatbot helping customers who cannot log in may need to recognize more ways of saying “I forgot my password.” Asking a language model for synonyms can produce valid words that customers would rarely use in that situation. Prompt engineering improves the request by specifying the task, the customer’s situation, and the desired form of the answer. section 7.2.1

A prompt is the input supplied to a language model to guide its output. It can contain instructions, context, input data, and indicators of the desired output. Examples of the desired answer or format can also be included. For a conversational bot, a prompt can steer responses toward a useful conversational tone, but it does not guarantee that the model has understood the user or produced a correct answer. section 4.1.4

From a generic synonym request to a customer-focused one

“Give synonyms for ‘password’” yields words such as “secret,” “key,” and “code.” A more focused request describes a consumer contacting an online retailer about being unable to log in, asks for nouns they might use in “I forgot my password,” and requests a numbered list. Its results include “credentials” and “login information.” The added context makes the output more useful for exploring possible customer utterances; the results still need review. section 7.2.1

Listing 7.1 Generating noun synonyms without context
Generate a list of nouns.  #1
The nouns should be synonyms of 'password'. 

List of 5 nouns  #2
credentials, secret, key, code, accesscode  #3

The context-free prompt and its output show why a correct synonym may be a poor fit for a login conversation. section 7.2.1

Listing 7.2 Generating noun synonyms with context
You are a consumer contacting an online retailer via their   #1
chat service. 
Generate a numbered list of nouns a consumer might use while  #2
describing their inability to log in to your service in the   #2
phrase "I forgot my password".   #2
The nouns should be synonyms of 'password'.  #2

List of 5 nouns  #3
1. "account information" 2. "credentials" 3. "login information"  #4
4. "authentication" 5. "identifier"  #4

Compare the customer scenario, requested list format, and resulting terms with the context-free version. section 7.2.1

Treat prompt design as an improvement loop:

  • Break a broad task into smaller requests when that produces more useful results; specify which phrases or forms you need. section 7.2.1
  • Inspect generated terms for how people would actually speak, not just whether they resemble the requested word. Revise the context and try again. section 7.2.1
  • Use annotated conversation logs to find coverage gaps and answer problems. Document prompt customizations and their goals, then add new scenarios to the test set and compare later performance. section 4.5.2 section 4.5.3

Prompts are one tool among model selection, examples, generation settings, and retrieval-augmented generation (RAG). Advanced prompting may reduce unsupported answers, but when answers must reflect specific, verifiable documents, supplying those documents through RAG provides a stronger grounding strategy. Assess where generated responses appear in the dialogue and what each customization is meant to improve. section 4.1.4 section 6.4.1 section 4.3.2

How Effective Conversational AI covers it

How deep it goes
Defines prompt components and works through iterative synonym requests, without detailing model internals.
Examples
Contrasts generic and customer-contextualized prompts for synonyms of “password” and “forgot.”
What it assumes
Assumes familiarity with the chatbot’s domain and likely user problems, while introducing prompt design through simple requests.
What you can do after
Practice/perform iterative prompt revision and test changes against logged user requests and updated test sets.
How it connects
Connects prompting to few-shot prompting, parameter tuning, retrieval-augmented generation, annotated logs, and test sets.

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 Effective Conversational AI. The section links point to the parts of the book it draws on.