🌿 AI Prompt Engineering Guide
Fundamentals of Prompting
Core Principles
- Clarity – Reduces ambiguity and improves interpretation.
- Context – Adds background and improves relevance.
- Constraint – Focuses tone, length, or structure.
Prompt Size Limitations (when reference material was published)
- ChatGPT: GPT-4-turbo supports up to 128k tokens.
- Gemini: Token limits vary, often smaller.
- Best practice: Place the most important information first.
Prompt Patterns and Techniques
Five-Step Prompt Design Framework (T-C-R-E-I)
- A complete prompt framework based on Google’s model: Task, Context, References, Evaluate, Iterate.
- Why use it: Improves prompt clarity, completeness, and relevance.
- Example:
- Task: “Summarise this report.”
- Context: “Audience is the executive board.”
- References: “Match the tone of last quarter's briefing.”
- Evaluate: “Does it highlight risks and outcomes?”
- Iterate: “Add bullet points for each key insight.”
Persona Pattern
- Assigns the AI a specific role to adopt in generating the response.
- Why use it: Aligns tone, terminology, and assumptions with the user’s needs.
- Example: “Act as a senior legal advisor assessing risk in this contract.”
Audience Person Pattern
- Defines the target audience for the AI’s output.
- Why use it: Tailors complexity and tone for specific stakeholders.
- Example: “Explain this IT architecture to a non-technical CEO.”
Root Prompts
- Base prompts for common, repeatable tasks.
- Why use it: Saves time and ensures consistency.
- Example: “Create a summary of this article in five professional bullet points.”
Question Refinement Pattern
- Prompts the AI to revise or optimise an existing prompt.
- Why use it: Improves unclear or poorly scoped prompts.
- Example: “Improve this prompt: ‘Write something about our product’.”
Chain of Thought Prompting
- Instructs AI to explain its thinking step-by-step before answering.
- Why use it: Increases transparency and reduces reasoning errors.
- Example: “Explain each step of your logic before recommending a hiring decision.”
Tree of Thought Prompting
- Explores multiple reasoning paths or solution options in parallel.
- Why use it: Enables comparison between approaches.
- Example: “Suggest three pricing strategies and explain the pros and cons of each.”
ReACT Prompting (Reason + Action)
- Combines logical reasoning with specific actions like calculations or data lookup.
- Why use it: Improves realism and precision in decision-making tasks.
- Example: “Calculate ROI for these investments and then suggest which to pursue.”
Cognitive Verifier Pattern
- Asks the AI to assess the accuracy and coherence of its response.
- Why use it: Reduces errors and hallucinations.
- Example: “Review your answer for consistency with these three sources.”
Flipped Interaction Pattern
- Turns the AI into the questioner or evaluator of the user.
- Why use it: Builds user understanding through challenge or testing.
- Example: “Quiz me on stakeholder management techniques using case examples.”
Ask for Input Pattern
- Encourages AI to seek missing details before responding.
- Why use it: Prevents low-quality outputs caused by lack of information.
- Example: “What else do you need to create a detailed training plan?”
Template Pattern
- Provides a standard format for structuring inputs.
- Why use it: Reduces ambiguity and enforces consistency across prompts.
- Example:
- Prompt Template:
- Topic: [Insert Topic]
- Audience: [Insert Audience]
- Format: [Insert Format]
- Output Constraints: [e.g. Length, Tone]
Output Expansion Pattern
- Instructs the AI to expand on a previous brief output.
- Why use it: Adds detail, examples, or context.
- Example: “Expand the third bullet to include a real-world example.”
Menu Actions Pattern
- Offers the user a list of next steps or content types to generate.
- Why use it: Makes the interaction more adaptive and responsive.
- Example: “Would you like a summary, slide deck, or checklist?”
Game Play Pattern
- Simulates a scenario or interaction using defined rules or roles.
- Why use it: Enhances training, ideation, or rehearsal through immersion.
- Example: “You are a customer with a complaint—simulate a live support interaction.”
Fact Check List Pattern
- Guides the AI to validate all factual claims against known sources.
- Why use it: Reduces misinformation or invented content.
- Example: “Identify every factual claim and confirm it against the report provided.”
Tail Generation Pattern
- Asks the AI to produce variations of the same response in different formats or styles.
- Why use it: Supports audience segmentation, tone testing, or repurposing.
- Example: “Write this product update as an email, a LinkedIn post, and a Slack message.”
Semantic Filter Pattern
- Restricts the AI’s output to specific themes or meanings.
- Why use it: Improves focus and avoids off-topic content.
- Example: “Only include insights relevant to supply chain optimisation.”
Meta Prompting
- Uses AI to help create more effective prompts.
- Why use it: Helps users who are unsure how to phrase a request.
- Example: “Suggest a well-structured prompt to extract insights from meeting transcripts.”
Iteration Techniques: RaHeN Framework
- The RaHeN Framework helps improve underperforming prompts when the T-C-R-E-I structure is not enough.
- Why use it: Offers systematic strategies for refining AI responses.
- Revisit – Add or adjust task, persona, or context. Example: “Add a persona and context to improve the summary output.”
- Halve complexity – Break down overly long or dense instructions. Example: “Split the original prompt into two simple instructions.”
- Narrative reframing – Ask for a story or analogy to clarify the idea. Example: “Explain this as a story about a manager solving a problem.”
- Set constraints – Add format, style, or topic boundaries. Example: “Rewrite in under 200 words using only financial data.”
See also
🌱 Preventing AI Hallucinations
Sources:
https://youtu.be/p09yRj47kNM?si=Jki8bF2wAr3SNc3T
https://www.coursera.org/learn/prompt-engineering?specialization=prompt-engineering