Lesson · ⏱ 8 min read
✍️ Prompting: giving clear instructions to an LLM
EnglishHinglish
🏠 Real-life example
Tell a new intern 'make a report' and you'll get something random. Tell them 'make a one-page sales report for March, compare it with February, use a table, and highlight the top 3 cities' and you get exactly what you need. LLMs are brilliant interns: the clearer the brief, the better the work.
💡 In simple words
A good prompt gives the role and context, the exact task, constraints such as length, tone, language and format, and examples of good output. The system prompt sets lasting rules ('You are a helpful bank assistant. Never share account numbers.'). Few-shot prompting means showing 2–3 examples of input → desired output. Asking the model to think step by step before answering improves reasoning. Asking for structured output (JSON) makes answers usable by code. Treat prompts like code: test them on real examples and iterate.
🪜 Step by step
- State the role and the goal: "You are a support assistant for a bank. Answer customer questions about cards."
- Give the context the model needs: the policy text, the customer's plan, today's date.
- Spell out rules and limits: answer only from the policy, say "I don't know" otherwise, keep it under 100 words.
- Show one or two examples of a good answer, and define the output format (bullets, JSON with named fields).
- Test on 20 or more real inputs, look at failures, adjust one thing at a time, and keep versions of your prompt.
🔑 Key terms
- System prompt
- Standing instructions that shape every response.
- Few-shot
- Including a few worked examples in the prompt.
- Structured output
- Asking for a fixed format like JSON so code can read it.
👀 See it in action
System: You classify customer messages for a food app. Reply only with JSON.
User: Classify: "Order came cold and 40 mins late 😡"
Format: {"category": "delivery|food|payment|other", "sentiment": "pos|neg|neutral", "urgent": true|false}
Model: {"category": "delivery", "sentiment": "neg", "urgent": true}Role + task + exact format = reliable, machine-readable answers.
⚠️ Common mistakes to avoid
- Vague prompts like "make it better". Say what better means: shorter, friendlier, with a call to action.
- Judging a prompt on one or two tries. Prompts that look great on one example often fail on others.
- Putting secrets or private data in prompts sent to tools that aren't approved by your company.
✅ Quick check
Your app needs to read the LLM's answer in code. What should the prompt ask for?
- A friendly paragraph
- As much detail as possible
- A specific JSON format
Show answer
C. A specific JSON format: A fixed JSON shape can be parsed reliably. Free text can't.
🙋 Questions learners ask
Do long prompts work better?
Clear beats long. Include what's needed, remove what isn't. Long irrelevant context can confuse the model and costs more.
What is chain of thought?
Asking the model to reason step by step before answering. It helps on maths and multi step problems; many modern models do it internally.
📌 Remember
Role + context + task + format + examples. Then test and iterate.
📖 Words from this lesson (AI dictionary)
Learn this as part of a full course
Track your progress, take the quick checks and follow the lessons in the right order. This lesson is part of:
AI Foundations Path · AI Product Engineer · LLM / Agent Engineer · AI Forward Deployed Engineer · AI Product Manager
Continue in the course