Study notesWeek 6: Prompting Well
AI and LLMs from zero

Prompting Well

Outcomes

What You Will Be Able To Do

Mindset

Think Of A Capable New Colleague

Setup

Roles And Messages

system:    standing rules and role
user:      the current request
assistant: the model's reply
Roles

A Role That Helps

Weak:   You are an assistant.
Better: You are a patient tutor who explains
        concepts to adult beginners using
        everyday examples. Answer only from
        the supplied text.
Anatomy

Four Parts Of A Strong Prompt

PartQuestion it answers
TaskWhat exactly should be done?
ContextWhat does the model need to know?
FormatWhat should the answer look like?
ConstraintsWhat to avoid or limit?
Clarity

Say What You Want

Examples

Show, Do Not Only Tell

Classify the review as positive or negative.

Review: The battery lasts all day.
Label: positive

Review: It broke after two days.
Label: negative

Review: Fast delivery but the screen is dim.
Label:
Technique

Reasoning Step By Step

A shop sells pens at 3 for 2 dollars.
How much do 12 pens cost?
Think through the steps, then give the
answer on a last line starting with ANSWER:
Layout

Structure Long Prompts

<role> ... </role>
<rules> ... </rules>
<example> ... </example>
<document>
  ...pasted text...
</document>
Question: ...
Reply in the format: ...
Format

Asking For Structured Output

Return only JSON with these keys:
{"title": string, "actions": [string],
 "deadline": string or null}
Method

Iterate Like An Engineer

Troubleshooting

Failure Patterns And Fixes

ProblemFix
Vague answerState task, audience, length
Wrong formatShow an example of the format
Invented factsSupply source text, allow 'I don't know'
Long prompt ignoredUse labeled sections, put the question last
Fix for invented facts

Grounding The Answer

Answer using only the text in <document>.
If the answer is not in the text, reply:
"Not stated in the document."
Quote the sentence you used.
Limits

Where Prompting Stops

Summary

Recap

Next week

Next Week: RAG And Tools

Wrap up

Questions And Exercise