Prompt Engineering Basics
Since an LLM is generating a response one token at a time based purely on the text you gave it, the exact wording of that text has an outsized effect on what you get back. Prompt engineering is just the practice of writing that input deliberately.
Be specific about what you want
A vague prompt like "write about dogs" leaves the model to guess your intent — tone, length, audience, format. Naming the format, length, audience, and goal directly removes that guesswork: "Write a 3-sentence, upbeat product description for a dog leash, aimed at first-time dog owners."
Give context and examples
Showing the model one or two examples of the exact output style you want — called few-shot prompting — is often far more reliable than describing the style in words. If you want a specific JSON shape, tone, or formatting convention, show it once and ask the model to continue the pattern.
System vs. user framing
Most chat-style APIs (covered in the next lesson) let you separate a system message, which sets persistent behavior for the whole conversation ("You are a concise technical writer"), from user messages, which are the actual requests. Putting stable instructions in the system message keeps them from getting lost or repeated in every single user message.
Iterating on a prompt
Treat a prompt like a first draft, not a final answer. If the output is close but not right, tell the model specifically what to change ("shorter," "less formal," "include a code example") rather than starting over from scratch — the existing conversation is context the model can build on.