Clear Instructions
Most disappointing LLM output comes from instructions that are clear in the writer's head but ambiguous on the page. The model cannot ask "what did you mean?" unless you allow it to — it simply picks the most plausible interpretation. This lesson collects habits that make instructions unambiguous.
1. Say exactly what you want
| Unclear | Clear |
|---|---|
| "Make this better." | "Rewrite this paragraph for a non-technical reader. Keep it under 80 words." |
| "Write about our product." | "Write 3 bullet points for the product page of a solar phone charger, each starting with a benefit." |
| "Don't be too long." | "Answer in at most 3 sentences." |
| "Fix the code." | "The function returns None for empty lists. Change it to return 0 and explain the change in one sentence." |
Quantities ("3 bullet points", "under 80 words") are easier to follow and to check than adjectives ("short", "detailed").
2. Explain the purpose
Saying why helps the model make sensible decisions in cases your rules don't cover. "Keep answers short because they are shown on a smartwatch screen" will also make it avoid tables and long URLs, without a separate rule for each.
3. Use delimiters for data
When a prompt contains material to work on — an email, a document, code — wrap it in clear markers such as XML-style tags. The model then knows where the data starts and ends, and you can refer to it by name.
def wrap(tag, text):
return f"<{tag}>\n{text.strip()}\n</{tag}>"
email = """
Hi team, the delivery for order 5521 arrived with a cracked lamp.
Can you send a replacement before Friday? Thanks, Mia
"""
policy = "Replacements for damaged items ship within 2 working days. No refund needed first."
prompt = "\n\n".join([
"Draft a reply to the customer email using only the shop policy.",
wrap("policy", policy),
wrap("email", email),
"Write the reply in under 80 words. Sign it as 'The Lumen Shop team'.",
])
print(prompt)Draft a reply to the customer email using only the shop policy.
<policy>
Replacements for damaged items ship within 2 working days. No refund needed first.
</policy>
<email>
Hi team, the delivery for order 5521 arrived with a cracked lamp.
Can you send a replacement before Friday? Thanks, Mia
</email>
Write the reply in under 80 words. Sign it as 'The Lumen Shop team'.
4. Use numbered steps for multi-part tasks
If a task has several stages, list them in order. Numbered steps are easier for the model to follow — and for you to debug.
steps = [
"Read the customer email.",
"Identify the order number and the problem.",
"Check the policy for what we can offer.",
"Write a friendly reply of at most 80 words.",
]
instructions = "Follow these steps:\n" + "\n".join(f"{i}. {s}" for i, s in enumerate(steps, 1))
print(instructions)Follow these steps:
1. Read the customer email.
2. Identify the order number and the problem.
3. Check the policy for what we can offer.
4. Write a friendly reply of at most 80 words.
5. Say what to do, not only what to avoid
"Don't use jargon" names the problem but not the target. "Use everyday words a 12-year-old would know" describes what success looks like. Positive instructions are usually followed more reliably than lists of prohibitions. When a prohibition really matters, pair it with the alternative: "Do not guess a delivery date; if the policy doesn't say, write that a colleague will confirm."
6. Allow "I don't know"
If the answer may not be in the provided material, say what to do then. Otherwise the model is pushed to produce something, which encourages invented answers.
def qa_prompt(question, context):
return (
"Answer the question using only the context.\n"
"If the context does not contain the answer, reply exactly: NOT_FOUND\n\n"
f"<context>\n{context}\n</context>\n\n"
f"Question: {question}"
)
def handle(reply):
# Your code can now react to the sentinel value reliably
return "Escalate to a human." if reply.strip() == "NOT_FOUND" else reply
print(qa_prompt("When does the shop open on Sunday?", "Mon-Fri 9:00-18:00, Sat 10:00-16:00."))
print("---")
print(handle("NOT_FOUND"))Answer the question using only the context.
If the context does not contain the answer, reply exactly: NOT_FOUND
<context>
Mon-Fri 9:00-18:00, Sat 10:00-16:00.
</context>
Question: When does the shop open on Sunday?
---
Escalate to a human.
A fixed sentinel such as NOT_FOUND is easy to detect in code, unlike a free-form apology.
A before/after example
Before: Tell me about this error.
After: You are helping a junior Python developer.
Explain the error below in plain language (max 4 sentences),
then show the corrected line of code.
<error>TypeError: can only concatenate str (not "int") to str</error>
<code>print("Total: " + total)</code>A typical model reply to the "after" prompt explains that Python cannot join text and a number with +, and suggests print("Total: " + str(total)) or an f-string — short, targeted and usable, because the prompt said who the reader is, how long to be and what to include.
Test yourself
Which instruction is the clearest?
- Make it shorter.
- Be concise-ish.
- Shorten the text to at most 50 words.
- Don't be long.
Why tell the model what to reply when the answer isn't in the context?
- It makes the model faster
- It gives the model a valid alternative to inventing an answer, and your code can detect it
- It is required by the API
- It increases the temperature
What is the benefit of explaining *why* a rule exists?
- None, models ignore reasons
- The model can generalise the intent to cases the rule doesn't mention
- It reduces token count
- It disables sampling