liveBook · Manning

Sampling

As explained in Effective Conversational AI

Sampling is a language-generation decoding strategy that selects output tokens probabilistically from a model's predicted distribution.

A chatbot trained only around “I forgot my password” may miss other ways users describe the same problem. Sampling is a language-generation decoding strategy that produces varied, nondeterministic responses. Unlike greedy decoding, which returns the same result for the same prompt, it lets you run a prompt repeatedly and choose among different candidates. section 7.2.1 section 7.4

For intent-data brainstorming, try sampling with a higher temperature and ask for more alternatives. A password-related prompt can then suggest terms such as “PIN” and “access code,” alongside less useful phrases. Treat the output as ideas to inspect, not a list to accept wholesale. section 7.2.1

Listing 7.6 Generating verb phrase synonyms with increased creativity settings
You are a consumer contacting an online retailer via their chat service.

Generate a numbered list of synonyms a consumer might  #1
use for 'forgot' while they described a problem like   #1
"I forgot my password". #1
#1
List of 10 synonyms for 'forgot'  #1
1. Forgot 2. Did not remember 3. Didn’t know 4. Unknown  #2
5. Not applicable 6. Unable to access 7. Couldn’t recall  #2
8. Didn’t memorise 9. OMG Failed to remember  #2
10. Unable to login  #2

The generated alternatives include useful directions such as “Couldn’t recall” and awkward results such as “Not applicable,” showing why sampled candidates need review. section 7.2.1

Choosing a kinder error message

A voice assistant needs a better response when someone enters a Social Security number with the wrong number of digits. Sampling the rewrite prompt several times yields options ranging from “Please enter your 9-digit SSN” to apologetic versions. Choose one, or combine parts into a brief, helpful message. section 11.5.1

Use the extra variety where it helps: generating possible user replies for chatbot tests or drafting dialogue. Be more cautious with factual tasks. A more creative setting might change the structure of a conversation summary, but it also risks introducing hallucinations. section 10.3.1 section 12.3.1

How Effective Conversational AI covers it

How deep it goes
Contrasts nondeterministic sampling with repeatable greedy decoding and adjusts temperature, without explaining token-selection internals.
Examples
Uses password synonyms, repeated voice-error rewrites, and generated replies to chatbot test scenarios.
What you can do after
Apply it via LLM decoding settings to generate multiple candidates, then select or refine the helpful ones.
How it connects
Connects sampling to greedy decoding, temperature, prompt iteration, intent-data augmentation, and hallucination risk.

Also explained in

Compare how 23 books explain sampling →

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.