Prompt Engineering
The lowest-cost, highest-leverage lever available for improving what a language model produces.
6.1.1Definition
Prompt engineering is the practice of constructing the instructions and context given to a language model to reliably produce the intended output. It sits entirely on the input side — no model weights change — which makes it the fastest and cheapest lever for improving AI output quality, ahead of fine-tuning or architectural changes.
6.1.2Why It Exists
Language models are extremely sensitive to how a request is framed — the same underlying task phrased two different ways can produce meaningfully different quality output. Prompt engineering exists because this sensitivity is a lever, not just a quirk: structured, specific instructions consistently outperform vague ones, and that gap is large enough to be a primary engineering concern rather than an afterthought.
6.1.3Core Techniques
- Role and context framing — telling the model who it is and what situation it's operating in, narrowing the space of plausible responses.
- Few-shot examples — showing the model two or three examples of the desired input/output pattern rather than describing the pattern abstractly.
- Explicit output format — specifying the exact structure expected (JSON schema, numbered list, specific length) rather than leaving format to inference.
- Chain-of-thought prompting — instructing the model to reason step by step before answering, which measurably improves accuracy on multi-step problems.
6.1.4Common Mistakes
- Vague, single-sentence instructions for a genuinely complex task, then treating inconsistent output as an unavoidable model limitation rather than an under-specified prompt.
- No examples for a pattern-matching task, where a single well-chosen example would have resolved ambiguity a paragraph of description could not.
- Iterating on a prompt without a fixed test set, making it impossible to tell whether a change actually improved output or just changed a few visible examples (6.8).
6.1.5Best Practices
- Be explicit about format, length, and tone rather than leaving them to the model's default assumptions.
- Use few-shot examples for any task with a specific, learnable pattern.
- Maintain a small, fixed evaluation set (6.8) to test prompt changes objectively rather than by feel.