Prompt Engineering Techniques With Real Examples
Give the model context, add two or three examples, ask it to think step by step, set a role in the system prompt, and ask it to rewrite your prompt.
The main idea
A prompt like "write me a poem" leaves the model guessing. In the video I use Anthropic's prompt engineering guide and show how to improve it. Treat the model like a brilliant but very new employee who needs explicit instructions.
First, add context: what the result is for, who the audience is and what success looks like. My poem became a short, modern intro for a comedy club. Second, add examples. Giving none is zero-shot. Giving three to five good ones is multi-shot, and the model copies their format and style. Third, for complex tasks, say "think step by step" to get chain of thought. XML tags can mark where an example starts and ends.
With an API, the system prompt can give the model a role, such as a seasoned data scientist. Meta-prompting means asking the model to rewrite your prompt, then pasting the better prompt into a new session. Last, tell the model not to hallucinate and to use only the facts you provide.
Key points
- Add context to the prompt: what the result is for, who the audience is and what success looks like.
- Zero-shot means no examples. Three to five good examples is multi-shot prompting.
- Saying "think step by step" triggers chain of thought, which helps on complex tasks.
- A system prompt can assign a role, such as a seasoned data scientist at a Fortune 500 company.
- Meta-prompting asks the model to write a better prompt for you, which you paste into a new session.
- Tell the model to use only the facts you provide so it does not make up metrics.