Five patterns, each with its check
The fake model returns fixed replies per task. The builders and checks are the production-shaped part.
Five prompt patterns you will use in almost every project, each built by a small function and each checked by code: classify, extract, summarise, rewrite and answer from context.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write classify_check(reply, labels) that returns True if the reply, ignoring spaces and capital letters, is one of the labels.
Write summary_check(reply, max_words) that returns True if the reply has at most max_words words and does not end with a question mark.
Explain it without notes
For each of the five patterns, name the failure it guards against and the check that catches it.
How do you make a model say "I don't know" reliably in an answer-from-context prompt?
Why keep prompt builders and checks as small separate functions?
Expected output
classify: pass
extract: pass
summarise: pass
rewrite: pass
answer, in context: pass
answer, not in context: pass
6 of 6 recipes pass