Prompt engineering
Day 2 - 9:00 AM - 9:30 AM
1 Prompting quick review
1.1 The three components
- Task: What are you asking the AI model to do?
- Context and Constraints: What information does the AI model need to know to complete the task? Are there any constraints or limitations that the AI model should be aware of?
- Output Format: What format do you want the AI model to respond and/or produce?
1.2 Language in prompting
- Direct: Direct and precise language.
- Specificity: Be specific in your details.
- Detail: Provide enough details to the AI model, but not too many that it becomes overwhelmed and confused. Remember, more is not always better.
1.3 Additional considerations
- Include examples and/or data
- Role/Persona
- Consider the audience
- Ask for clarification
2 Let’s start prompting!
I have pre-made the prompts below for you to use. However, please feel free to modify them or create your own prompts. The goal of this exercise is to observe how prompting can affect the response you recieve from an AI model. Go to the very bottom of this page for additional ideas for you to practice prompt engineering.
We will be submitting different versions of the same prompt over and over again throughout this exercise. Do not do this when actually using genAI. Instead, begin with a well-crafted prompt.
2.1 Warm-up prompt
We’re starting with something simple and non-bioinformatic based!
Write me a short summary about wildflowers and provide a list.What did you get out? Probably a decent answer. But AI definitely ‘guessed’ on what information you wanted. Let’s revist our three building blocks and redesign this prompt.
- Task - We want AI to write us a summary about wildflowers and to provide a list of wildflower names.
- Context/Constraits - For this exercise, let’s give the following constraints:
- 300 words or less
- include the ecological importantance of wildflowers
- describe the geographical significance of wildflowers (i.e. a wildflower in Ohio is not the same wildflower in Florida)
- we would like a list of wildflowers local to my area (input whatever area you would like)
- we want AI to use general, non-jargon language in its response
- Output format - We want our summary 1-2 paragraphs, and include a bulleted list of wildflowers local to my area at the end of the summary
Try engineering a prompt based on the building blocks above. Did you recieve exactly what you asked for? Did you get something different than before?
Click to see the prompt I created
Write me a summary about wildflowers that is 300 words or less. Explain the ecological significance of wildflowers. Describe why geographic areas define wildflowers and why this is important for consumers. Lastly, provide a list of wildflowers that I could find in Ohio. Do not use jargon. The summary should be 1-2 paragraphs, and the list of wildflowers should come at the end. Now, let’s bring in some of our other considerations. Alter your prompt to include the following:
- Audience: We would like this response to be for appropriate for 3rd and 4th graders.
- Role/persona: Let’s ask AI to pretend it is the head naturalist at our local nature center.
Click to see the edited prompt
Pretend you are the head naturalist at my local nature center. Write a summary about wildflowers that is 300 words or less, designed to be understood for 3rd and 4th graders. Explain the ecological significance of wildflowers. Describe why geographic areas define wildflowers and why this is important for consumers. Lastly, provide a list of wildflowers that I could find in Ohio. Do not use jargon. The summary should be 1-2 paragraphs, and the list of wildflowers should come at the end. Did you get something different? Let’s change our audience and persona:
- Audience: We would like this response to be for appropriate for middle-aged adults looking to start a wildflower garden.
- Role/persona: Let’s ask AI to pretend it is a professor from our local extension office.
Click to see the edited prompt
Pretend you are apart of my local extension office providing a quick pitch about wildflowers. Write a summary about wildflowers that is 300 words or less, designed for middle-aged adults interested in starting a wildflower garden. Explain the ecological significance of wildflowers. Describe why geographic areas define wildflowers and why this is important for consumers. Lastly, provide a list of wildflowers that I could find in Ohio. Do not use jargon. The summary should be 1-2 paragraphs, and the list of wildflowers should come at the end. 2.2 Generative code prompt
Let’s create a prompt that will generate code for us. I recommend using Github Copilot or Claude in your VS code to do this but use whatever you would like.
If you use your terminal, navigate back to where we were yesterday:
- Click
Open...with a folder icon in the Welcome document (or:File>Open Folder) - Type (or select) the path to your folder (
/fs/scratch/PAS3454/people/<user>).
Let’s get prompting:
- Task: Let’s have AI generate us a script that prints “I like bread. It is my favorite food.” to the terminal.
- Context/Constraints: Let’s give the following constraints:
- we want a bash script
- we would like AI to explain what the lines of code mean
- we would like AI to explain how to run the bash script in the terminal
- we are beginner coders!
- Output format: We want it to create a bash script and also provide us a set of instructions, outside of the script, on how to run the script.
Click to see the prompt I created
I would like a bash script that prints "I like bread. It is my favorite food." to the terminal. I am a beginner coder, so please include comments within the script telling me what the code means. Additionally, please print instructions, outside of the script, on how to run the script.3 Create a prompt relevant to you!
So far, we’ve been focusing on our data or examples. Create a prompt that is related to you and your scientific data. If you can’t think of any, see additional ideas below.
4 Additional ideas for you to practice prompt engineering
- Summarize a methods section for a certain audience (undergraduate students, graduate students, or the general public)
- Develop a quick script (bash python, etc.) to do XYZ
- Pretend you’re a reviewer. Critically review my introduction, abstract, methods, etc.
- Describe the central dogma to a certain audience (5th graders, high schoolers, my grandma)
- Compare and constrast python and C++