Homework
Three tasks to build mastery in chain-of-thought, few-shot, and system prompt design.
homework04.pdf in this lesson folder. Be ready to share one result during the next class.
📥 Reference Solution
⬇ lab_answer.pdfTask 1 — Two-Step Prompt Chain
What to do
Build a 2-step prompt chain. Step 1 extracts facts from a provided 500-word article. Step 2 answers questions using only those extracted facts — not from general knowledge.
Requirements
- Find or write a 500-word factual article (technology, science, or business)
- Step 1 prompt: extract all key facts as a numbered list
- Step 2 prompt: answer 5 questions using only the extracted facts; if a fact is not present, say "Not in the article"
- Write 5 questions — at least 2 should be answerable from the article and at least 1 should not be
- Verify that Step 2 correctly says "Not in the article" for the unanswerable question
facts = call_claude(f"Extract all key facts from this article as a numbered list:\n\n{article}")
answers = call_claude(
f"Answer each question using ONLY the facts listed below. "
f"If the answer is not in the facts, say 'Not in the article'.\n\n"
f"FACTS:\n{facts}\n\nQUESTIONS:\n{questions}"
)
Self-check: Does the Step 2 answer for the unanswerable question correctly say "Not in the article"? If not, your Step 2 prompt may be allowing general knowledge to leak in.
Task 2 — Few-Shot Classifier for Your Domain
What to do
Build a few-shot classifier for a domain relevant to your work or interests. The classifier must have at least 5 categories and use at least 3 labeled examples per category in the prompt.
Requirements
- At least 5 categories (e.g., bug severity levels, email types, article genres, support ticket types)
- At least 3 examples per category in the few-shot prompt (15+ examples total)
- Test on 10 samples — at least 5 must be correctly classified
- Document: category definitions, example selection rationale, accuracy result
Example domains
- Code review comments → categories: architecture/bug/style/performance/security
- News articles → categories: politics/technology/sports/business/science/culture
- Customer feedback → categories: bug/feature request/praise/complaint/question
Self-check: Did you include diverse examples (not all similar)? Does your classifier output exactly the category label with no extra text?
Task 3 — Customer Service Bot System Prompt
What to do
Design a complete system prompt for a customer service chatbot for a product of your choice. The system prompt must define a persona, 5 behavioral constraints, and a response format. Then test whether the bot refuses off-topic requests.
Requirements
- Persona: Name, role, company, tone (1–2 sentences)
- 5 behavioral constraints: Things the bot must always or never do. Examples:
- "Never reveal pricing before the user has described their use case."
- "Always offer to connect the user to a human agent if frustrated."
- "Never discuss competitors by name."
- Response format: Max length, structure, whether to use lists or prose
- 5 test messages: 3 on-topic (should be answered), 2 off-topic (should be declined politely)
Scoring your system prompt
| Test | Pass Criterion |
|---|---|
| On-topic Q1 | Answered correctly, within format constraints |
| On-topic Q2 | Answered correctly, within format constraints |
| On-topic Q3 | Answered correctly, within format constraints |
| Off-topic Q1 | Politely declined, offered on-topic alternative |
| Off-topic Q2 | Politely declined, offered on-topic alternative |
Aim for 5/5. Document any failures and what you changed to fix them.
Self-check: Did the bot stay in character across all 5 tests? Did it use the correct tone? Did the off-topic refusals avoid being rude?
Grading Criteria
| Task | Points | Key Criterion |
|---|---|---|
| Task 1 — Prompt chain | 30 | Step 2 correctly uses only extracted facts; unanswerable Q handled |
| Task 2 — Few-shot classifier | 40 | 5+ categories, 3+ examples each, 5+/10 accuracy on test set |
| Task 3 — System prompt | 30 | 5 behavioral constraints present; 4+/5 tests pass |