Prompting that actually works
Practical prompt structure — roles, examples, and constraints — that reliably gets useful output.
Prerequisites
- What is an LLM?
- How models see text: tokens & context
You will learn
- Structure a prompt with clear role, task, context, and format
- Use examples (few-shot) to steer output style and shape
- Diagnose and fix a vague prompt that returns weak results
Telugu lo nerchuko · Watch in Telugu
Most "the AI gave me garbage" problems are prompt problems. The model is doing exactly what it always does — predicting a plausible continuation of what you wrote. If what you wrote is vague, the most plausible continuation is also vague. Good prompting is mostly about removing ambiguity.
Overview
A reliable prompt usually has four parts: who the model should act as (role), what you want done (task), what it needs to know (context), and how the answer should look (format). You do not need all four every time, but naming them is the fastest way to find what is missing when output disappoints.
The second lever is examples. Showing the model one or two examples of the exact input-to-output mapping you want (few-shot prompting) steers it far more reliably than describing the style in words.
Key ideas
Structure beats cleverness
Compare these two prompts. The first is what beginners write; the second works.
Bad:
Write something about our restaurant.
Good:
You are a copywriter for a small South Indian restaurant.
Task: write a one-line description for a food delivery app.
Context: family-run, known for filter coffee and ghee dosa, in Hyderabad.
Format: under 15 words, warm tone, no exclamation marks.The second prompt removes the choices the model would otherwise make randomly: length, tone, what to mention, what to leave out.
Show, do not just tell (few-shot)
When you need a specific output shape, give examples. The model copies the pattern.
Classify each message as ORDER, COMPLAINT, or QUESTION.
Message: "Where is my parcel, it has been 5 days"
Label: COMPLAINT
Message: "Do you ship to Vijayawada?"
Label: QUESTION
Message: "I want 2 kg basmati rice"
Label:The model will return ORDER, and it learned the label vocabulary and format from your examples, not from a description.
Constrain the output
If you will parse the answer in code, tell the model the exact shape and tell it to return only that. "Respond with only valid JSON, no prose" prevents the chatty wrapper text that breaks parsers. You will formalise this with schemas in Week 2.
Let it think for hard tasks
For multi-step reasoning, asking the model to work through the steps before giving a final answer improves accuracy. A simple "think step by step, then give the answer" often helps. For tasks where you only want the final value, ask it to reason internally and then output just the result.
Quick recap
- Vague output usually means a vague prompt; the model fills gaps with plausible guesses.
- Cover role, task, context, and format; name them to find what is missing.
- Few-shot examples steer shape and style more reliably than descriptions.
- Constrain output explicitly when code will parse it ("only JSON, no prose").
- For hard problems, let the model reason step by step before answering.