Chapter 3. Prompt Engineering
Large language models are powerful, but also deeply sensitive to how you talk to them. The same model can produce a brilliant, well-structured analysis or a vague, unhelpful response depending on nothing more than how the input is framed. A small change in wording, a missing example, or an unclear instruction can be the difference between a system that works reliably and one that fails unpredictably.
What Is Prompt Engineering?
Prompt engineering is the practice of designing inputs so that a large language model produces the output you need. Rather than changing the model’s weights through training or fine-tuning, you change what the model sees: the instructions, the examples, and the constraints you provide.
There are two broad categories to prompting: hard prompting and soft prompting. Hard prompting means writing human-readable instructions in natural language, often with examples, formatting rules, and task descriptions. This is what most practitioners mean when they say “prompt engineering,” and it is the focus of this chapter.
Soft prompting, by contrast, uses learnable ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access