how to write a good llm prompt
- User
how to write a good llm prompt
Assistant
Here are key techniques for writing effective LLM prompts:
Be specific and detailed Instead of "Write about dogs," try "Write a 300-word explanation of how dogs evolved from wolves, focusing on the key genetic and behavioral changes that occurred during domestication."
Provide context and constraints Give the model relevant background information and clear boundaries. For example: "You are a nutrition expert. Explain the benefits of Mediterranean diet to someone with type 2 diabetes, using simple language and avoiding medical jargon."
Use examples (few-shot prompting) Show what you want by providing examples:
Convert these sentences to active voice: - The ball was thrown by John → John threw the ball - The cake was eaten by the children → The children ate the cake - The report was written by the team → [your turn]Break complex tasks into steps Instead of asking for a complete business plan at once, prompt for each section: "First, outline the key market opportunities. Then, describe the target customer segments. Next, detail the revenue model..."
Specify the output format Be explicit about structure: "Provide your response as a JSON object with the following fields: 'summary' (50 words max), 'key_points' (bullet list), and 'recommendation' (one sentence)."
Use role-playing when helpful "Act as an experienced Python developer reviewing code for a junior colleague. Point out potential bugs and suggest improvements while being encouraging."
Iterate and refine Start with a basic prompt, see what works and what doesn't, then adjust. Add clarifications, examples, or constraints based on the outputs you receive.
For more comprehensive guidance on prompting techniques, check out Anthropic's documentation at https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/overview.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.