Phase 11: LLM Engineering

Prompt Engineering: Techniques & Patterns

Most people write prompts like they are texting a friend. Then they wonder why a 200-billion parameter model gives mediocre answers. Prompt engineering is not about tricks. It is about understanding that every token you send is an instruction, and the model follows instructions literally. Write better instructions, get better outputs. It is that simple and that hard. Related: Phase 11 · 05 (Context Engineering) for what else goes in the window; Phase 5 · 20 (Structured Outputs) for token-level format control. Apply the core prompt engineering patterns (role, context, constraints, output format) to transform vague requests into precise instructions. Construct system prompts with explicit behavioral rules that produce consistent, high-quality outputs. Diagnose prompt failures (hallucination, refusal, format violations) and fix them with targeted prompt modifications. Implement a prompt testing harness that evaluates prompt changes against a set of expected outputs. You open ChatGPT. You type: "Write me a marketing email." You get something generic, bloated, and unusable. You try again with more detail. Better, but still off. You spend 20 minutes rephrasing the same request. This is not a model problem. It is an instruction problem. Here is the same task, two ways: Vague prompt: Engineered prompt: The first prompt activates a generic distribution of marketing emails in the model's training data. The second activates a narrow, high-quality slice.…

Prompt Engineering: Techniques & Patterns: Most people write prompts like they are texting a friend. Then they wonder why a 200-billion parameter model gives…

This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.

Browse the complete course catalog or open this lesson on GitHub.