liveBook · Manning

Prompt engineering

As explained in AI-Powered Search

Prompt engineering is the deliberate design and manipulation of model inputs to influence the behavior or output of a language model.

Prompt engineering deliberately designs the input sent to a language model so added context influences its response. In search applications, prompts can guide result summarization, question answering, synthetic-data generation, and retrieval-augmented generation (RAG). Unlike fine-tuning, prompting changes the request at inference time rather than changing model weights. section 15.1.2 section 15.8

The mechanism is straightforward: include a role, task, or domain perspective alongside the query. Asking what a unicorn is produces a general explanation; adding a chatbot identity and biology expertise steers the response toward a biological framing. This flexibility makes prompting useful when each request needs different context, although fine-tuning may produce better results for stable, general characteristics. section 15.1.2

Listing 15.1 Query with no prompt engineering
Query: "What is a unicorn?"

Response:
A unicorn is a mythical creature that is typically depicted as a horse
with a single, spiraled horn projecting from its forehead. Unicorns have
been a part of human mythology and folklore for centuries and are often
associated with purity, grace, and magic. They are said to possess healing
powers and to be able to bring good luck to those who encounter them.
While unicorns are not real animals, they continue to be a popular symbol
in modern culture, appearing in literature, art, and popular media.

Compare an unmodified question with a context-rich prompt to see how role and expertise change the model’s answer. section 15.1.2

Prompt quality can also be optimized programmatically. DSPy represents a task with a signature such as question → answer, document → summary, or context, question → answer. Modules combine signatures, prompting techniques, a configured language model, and parameters; metrics score outputs; optimizers test prompt and parameter variations against those metrics. Tracking responses in a spreadsheet or evaluation tool helps compare prompt versions rather than relying on manual inspection alone. section 15.2.6 section 15.2.4

How AI-Powered Search covers it

How deep it goes
Explains context steering and DSPy-based optimization, then stops short of model-weight training internals.
Examples
Uses unicorn queries, role-and-expertise context, DSPy signatures, evaluation metrics, and tracked prompt responses.
What it assumes
Assumes familiarity with trained language models and distinguishes inference-time prompting from training and fine-tuning.
What you can do after
Evaluate and optimize prompts using task signatures, response metrics, tracked outputs, and automated prompt-variation testing.
How it connects
Connects prompting to fine-tuning, foundation models, retrieval-augmented generation, synthetic data, evaluation, and search-result summarization.

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