Hands-On Practice: Prompting
Basic prompting techniques.
Designing effective prompts to instruct LLMs to generate a desired output is referred to as prompt engineering. This activity will guide you through the process of creating prompts for LLMs.
Prompting
General tips
OpenAI give a set of strategies for using their models. If you need examples, this might be a good place to start.
The strategies include:
- writing clear instructions
- providing reference texts
- splitting tasks into subtasks
- giving GPT ‘time to think’
- using external tools
Some general techniques are:
Numbered Steps:: For sequential tasks, use numbered steps. This helps the model understand the sequence of actions.
Use delimiters: To separate various parts of the prompt (e.g.
", `,,',|,#, …).Few-shot prompting: Provide a few examples for guidance.
Combining these techniques, a template prompt might look like this:
Remember to structure your prompt in a way that is clear and easy to understand. You can use markdown to format your prompt, and you instruct the mode to format its response using markdown.
Example
Different persona:
Ask the model to output a table:
Structured prompting techniques
In-Context Learning: Provide examples within the prompt
Explanation
In-Context Learning involves providing the language model with examples or context within the prompt itself. This technique helps guide the model’s responses by demonstrating the desired output format or type of information.
Techniques
Few-Shot Prompting: Provide a few examples of the desired output before asking for a new response.
Zero-Shot Prompting: Ask the model to perform a task without any examples, relying on its pre-trained knowledge.
Example
Thought Generation: Instruct the model to think step-by-step
Explanation
Thought generation techniques encourage the model to show its reasoning process, making the output more transparent and often more accurate.
Techniques
Chain-of-Thought (CoT) Prompting: Ask the model to break down its thinking into steps.
- Zero-Shot CoT: Request step-by-step reasoning without providing examples.
- Few-Shot CoT: Provide examples of step-by-step reasoning before asking for a new response.
Example Prompt (Chain-of-Thought):
Decomposition Techniques: Break down tasks into subtasks
Explanation
Decomposition techniques involve breaking down complex tasks into smaller, more manageable subtasks. This approach can lead to more accurate and comprehensive responses.
Techniques
- Least-to-Most Prompting: Start with the simplest subtask and gradually increase complexity. More info here: Least-to-Most Prompting
- Plan-and-Solve Prompting: Separate the task into a planning phase and an execution phase.
Example Prompt (Plan-and-Solve):
Exercise: Essay writing
The goal of this exercise is to develop prompting skills. Focusing on structuring and guiding the model to generate coherent and informative responses. Use the techniques that you have learned so far, including providing reference texts.
Further Resources
- Explore these prompt guides. Use ChatGPT to try out new ideas.
Reuse
Citation
@online{ellis2024,
author = {Ellis, Andrew},
title = {Hands-On {Practice:} {Prompting}},
date = {2024-06-27},
url = {https://virtuelleakademie.github.io/promptly-literate/pages/activity-global-management.html},
langid = {en}
}