Lesson 04 Advanced Prompting
Theme:

Homework

Three tasks to build mastery in chain-of-thought, few-shot, and system prompt design.

Submission: Add your work to homework04.pdf in this lesson folder. Be ready to share one result during the next class.

📥 Reference Solution

⬇ lab_answer.pdf

Task 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

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

Example domains

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

Scoring your system prompt

TestPass Criterion
On-topic Q1Answered correctly, within format constraints
On-topic Q2Answered correctly, within format constraints
On-topic Q3Answered correctly, within format constraints
Off-topic Q1Politely declined, offered on-topic alternative
Off-topic Q2Politely 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

TaskPointsKey Criterion
Task 1 — Prompt chain30Step 2 correctly uses only extracted facts; unanswerable Q handled
Task 2 — Few-shot classifier405+ categories, 3+ examples each, 5+/10 accuracy on test set
Task 3 — System prompt305 behavioral constraints present; 4+/5 tests pass