How to Write an Effective Prompt for a Language Model
Writing effective prompts is key to getting accurate, relevant, and useful responses from a language model. Whether you’re using ChatGPT, Gemini, Claude, or another AI, a well-crafted prompt will help you get the results you want.
Follow these step-by-step instructions to write effective prompts:
1. Define Your Goal
Ask yourself: What do I want the AI to do?
Examples:
- Answer a specific question
- Summarize a document
- Generate creative text
- Rewrite or correct text
- Extract structured data
Tip: Write down your desired outcome in one sentence before you start.
2. Be Clear and Specific
State exactly what you want and avoid ambiguity.
- Instead of: "Tell me about dogs."
- Try: "List three unique characteristics of Golden Retrievers."
If you need a particular format or style, specify it.
- "Summarize this text in bullet points."
- "Reply as if you are a customer support agent."
3. Provide Context
The more context you provide, the better the AI can respond.
- Include background information, examples, or relevant details.
- If referencing a text, paste it directly or summarize it clearly.
Example:
"Given the following product description, write a 2-sentence ad targeting young adults..."
4. Set Constraints or Instructions
If you need the answer in a certain format, length, or style, say so.
- "Limit your answer to 100 words."
- "Use simple language suitable for a 10-year-old."
- "Respond in Markdown format."
5. Ask for Step-by-Step Output (if needed)
If you want a process explained or a multi-step response, ask for it explicitly.
- "Explain the steps involved in..."
- "Walk me through the process of..."
6. Test and Refine
Try your prompt and see if the output meets your needs.
- If not, clarify, add context, or break your request into smaller parts.
- Don’t be afraid to iterate!
7. Examples of Effective Prompts
| Task | Ineffective Prompt | Effective Prompt |
|---|---|---|
| Summarization | Summarize this. | Summarize the following article in three sentences for a high school audience. |
| Data extraction | What are the key facts? | Extract the names, dates, and locations mentioned in this text. |
| Creative writing | Write a poem. | Write a four-line poem about autumn in the style of Robert Frost. |
| Troubleshooting | Why isn't my code working? | Here’s my Python code (paste code). It raises an IndexError on line 14. Why? |
Quick Checklist
- Is my goal clear?
- Did I specify exactly what I want?
- Did I provide enough context?
- Did I set any necessary constraints?
- Did I test and refine my prompt?
Summary
An effective prompt is clear, specific, contextual, and instructive.
Always test and refine your prompts for best results.
The more you practice, the better your prompts—and the AI’s responses—will become!
Example of a strong prompt:
"Write a step-by-step how-to guide for baking sourdough bread at home, using simple language and bullet points."