Best Practice of Crafting Prompts
Table of Contents
1. Claude's Prompt Engineering Course
1.1. Tips
- Being Clear and Direct: Claude responds best to clear and direct instructions.
- Assigning Role Prompting: Continuing on the theme of Claude having no context aside from what you say, it's sometimes important to prompt Claude to inhabit a specific role (including all necessary context). This is also known as role prompting. The more detail to the role context, the better.
- Separating Data and Instructions (This is for prompt template)
- Formatting Output and Speaking for Claude
- Precognition: Thinking Step by Step
- Order is important for prompts.
- Choice is better for only a QA.
- Using Examples for Fewshot Prompting
- Considering Hallucinations
- If it is difficult, "give LLMs an out". Tell it it's okay to decline
- The question should be at the bottom.
- Using CoT, let LLMs strictly mine something from documents
1.2. The Order and Elements for a Complex Prompt
- ROLE information
- TONE information
- Detailed TASK description and rules
- Examples
- Detailed INPUT description
- Remind LLM the TASK shown in 3, and tell LLMs how to respond to user's questions
- Detailed OUTPUT formatting
Note that the order and elements can be flexible, such as:
- Point 3 can be merged by point 6
- You can add the CoT (thinking step by step before point 7)