Prompt engineering is the practice of designing prompts that steer a language model toward more useful, accurate, or customized outputs. It is usually the first improvement to try before changing the model itself. section 2.13 section 3.4
A worked example
A prompt asks: “Roger has 5 tennis balls. He buys 2 cans with 3 balls each. How many does he have?” It first demonstrates: “2 cans of 3 is 6; 5 + 6 = 11.” A similar apple problem follows. Including these intermediate steps helped the model solve the second problem correctly, while omitting them produced an incorrect answer. section 2.13
Common prompt-engineering moves include:
- Add a few demonstrations of the desired task, called few-shot prompting, to remove ambiguity about format or content. section 3.3
- Show intermediate reasoning steps when a task benefits from a demonstrated solution path; this is commonly called chain-of-thought prompting. section 2.13
- Supply additional context through retrieval-augmented generation (RAG), especially when the model can use a large context window. section 3.3
- Include reference images when customizing image generation, such as indicating a desired style in Midjourney. section 3.3
Prompt engineering improves an off-the-shelf model without changing its internal parameters. Richer prompts can make a general model more adaptable, but results depend on model capability and available context space. It is not a guarantee against hallucinations. section 3.3 section 3.4
Table 3.2 Off-the-shelf vs. fine-tuned AI
| Off-the-shelf AIBest when . . . |
Fine-tuned AIBest when . . . |
|---|---|
| • Prompt engineering techniques work well. • It is okay to use proprietary AI. • You can afford large models. • You prioritize ease of use. |
• You want highly customized outputs, and you’ve exhausted other options. • You need to use smaller models (for example, for self-hosting them). • You have ML expertise and access to computing resources. |
Compare prompt-based customization with fine-tuning when choosing between ease of use, customization, model size, proprietary systems, and self-hosting. section 3.4





































