How to Write a Good Prompt¶
Guidelines for Crafting Effective Prompts¶
- Be Clear and Specific:
- Clearly define the task or objective.
- Avoid ambiguous language.
Example: - Bad: "Write a function." - Good: "Write a Python function to calculate the factorial of a number using recursion."
- Provide Context:
- Include relevant details to help the user or system understand the task.
Example: - Bad: "Generate test cases." - Good: "Generate test cases for a login feature that includes username and password validation."
- Use Examples:
- Provide input-output examples to clarify expectations.
Example: - Input: "5" - Output: "120"
- Be Concise:
- Avoid unnecessary details while ensuring completeness.
Example: - Bad: "Write a function that does something with numbers." - Good: "Write a function to find the sum of an array of integers."
- Iterate and Refine:
- Test the prompt and refine it based on the results.
Template for Writing Prompts¶
Intent: [Clearly state the purpose of the prompt.]
Context: [Provide relevant details and background information.]
Task: [Describe the task to be performed.]
Example:
Input: [Provide an example input.]
Output: [Provide the expected output.]