# Prompt Engineering Strategies
## Elements
- Explicit instructions: what we want the model to do
- Question: formulating the task as a question
- Context: Context within which the model performs the task
- Role
- Tone
- etc
## Example instructions
- You are a ... Write a short, persuasive text about the benefits of ...
- You are a ... Reflect on ...
- ... Provide advice on ...
## Zero-shot learning
Most simple prompt engineering technique
- Instructions: Describe the task
- Input
## Few-shot learning
Add more description to the prompt, so that the model can perform better (clearer context, goals, output restrictions, etc)
Cons:
- Uses a larger number of tokens
- Charged per token
- Conciseness is key
## Prompting by instruction
Give explicit, clear directives to the model to guide its output
Precision matters:
- Direct commands
- Output guidelines
- eg tone, format
Pros:
- Precise control
- Ideal for tasks with specific/expected outcomes
- Less setup required
Cons:
- Requires clear and unambiguous language
- May struggle with complex/nuanced tasks
- Interpretation might not align with intent
## Prompting by example
Provide examples and let the model figure out the goal and format
Pros:
- Can handle complex tasks, even if those require creativity
- Reduced ambiguity if the input examples are good enough
- Enables the model to learn from a variety of scenarios
Cons:
- Require high-quality examples for training
- Time-consuming
- Rigid model, too fixated on the given examples
## Chain-of-Thought prompting
- Prompt, context, series of reasoning steps
- Provides specific steps to follow
- Enables the model to perform multiple steps and reason for each specifically
- Discourages the model from generating quick answers
This approach looks as follows:
- Input > Prompt #1 > Output #1 > Prompt #2 > Output #2 > Prompt #3 > Final output
Example
- You are an AI assistant that helps customers book flights on the ... airline. F
- Follow these steps to answer the customer queries
- Step 1: First decide whether the user is asking a question about a specific airline or flight route
- Step 2: ...
- Step 3: If ... then ...
- ...
## Multi-Chain Prompting
Cfr [[Multi-Agent Workflow]].
## Knowledge Augmentation
Adding the following to prompts:
- Relevant keywords and phrases
- Structured data
- Additional context
- Access a vector database
- Including search results
- ...
Helps the model perform better
Can be combined with Chain-of-Thought and Multi-Chain prompting
## Prompt Lazy Loading
Cfr [[Prompt Lazy Loading AI Design Pattern (PLL)]]
## References
-