Prompt engineering
2026-07-14
Introduction to Prompt Engineering
- What is a prompt?
- A prompt is the input text or query that you provide to an AI model to generate a response. It can be a question, statement, or instruction.
- What is prompt engineering?
- The process of designing and optimizing prompts to provide you relevant and accurate responses for your specific needs.
Why is prompt engineering so important?
The only thing that stands in between you and an effective solution is the prompt you generate.
Prompt engineering is so important that there are entire jobs, courses, and websites dedicated to it. In fact, you can purchase prompt engineering services from companies.
Anatomy of a well-crafted prompt
Fortunately, for us science-minded folks, there is an SOP of sorts to help us craft effective prompts. A well-crafted prompt should include, at minimum, the following components:
- Task: What are you asking the AI model to do?
- Example: “Write a script that counts all A, T, C, and G characters in a FASTA file.”
- 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?
- Example: “Write a script that counts all A, T, C, and G characters in a FASTA file. The script should be written in Python 3 and use the Biopython library. The file may contain Ns, which should be ignored.”
- Output Format: What format do you want the AI model to respond and/or produce?
- Example: “Write a script that counts all A, T, C, and G characters in a FASTA file. The script should be written in Python 3 and use the Biopython library. The file may contain Ns, which should be ignored. The resulting counts should be printed to the console in the following format: A: T: C: G: ”
Language in prompting
While good prompting begins with our three building blocks, the language we use in prompting has a significant impact on the quality of the response we receive.
Direct: Just as we do for writing, we should be direct and concise in our prompting.
Specificity: Be specific when you describe what you want from the AI model. Avoid using vague language or unclear instructions. The more specific you are, the more likely the reponse will be relevant to what you need.
- Example: “Write a python script…”
- Example of what not to do: “Write a script that counts ATGC in a file.”
Detail: You want to provide enough details to the AI model to understand the scope of the task, but no so many details that it becomes overwhelmed and confused. More on this in the next slide.
To get the most out of your prompts…
- More is not always better: Too much information, details, or directions can overwhelm the AI model and can create problematic responses. If you have multiple directions, break them up into multiple prompts. Avoid giving the AI model too many details that are irrelevant to the task.
- Example: “…counts should be printed to the console in the following format: A: T: C: G: .”
- wait for AI response…
- NEW PROMPT: “This script worked. Now, can you modify it to count the number of > characters as well? Do not edit the existing code, only add the necessary modifications”
- Example of what not to do: “Write me a script that counts all A, T, C, and G characters in a FASTA file. This FASTA file is a bacterial genome that is 5 Mb in size and belongs to the genus Pseudomonas. It was isolated from a tomato plant in New York.”
To get the most out of your prompts… (cont)
- Examples: Providing examples of your output, problem, or both can significantly improve the quality of the response you recieve.
- Example: “…counts should be printed to the console in the following format: A: T: C: G: . For example, if the input file contains the following sequence: ATCGATCGNNNATCG, the output should be: A: 3 T: 3 C: 3 G: 3”
- Input data: Similar to examples, it is sometimes helpful to include actual data in the form of copying and pasting or attaching a file to your prompt. However, avoid uploading large files or datasets as this can consume time and resources (aka tokens).
- Example: “…counts should be printed to the console in the following format: A: T: C: G: . I’ve attached a small file here to help you understand what my input data will look like.”
Optional, but useful pieces for prompting
- Role/Persona: Do you want the AI model to take on the role of a particular type of person? Do you want your AI model to act as a molecular biologist? a bioinformatician? a student? a peer?
- Example: “You are a bioinformatician with 10 years of experience in fungal, whole-genome analysis. Write a script that counts all A, T, C, and G characters…”
- Audience: The AI model is creating a response for you. Do you want the response to be tailored to your level of expertise? Or to an expertise level that is higher or lower than your own?
- Example: “I am a graduate student with very little experience in bioinformatics. Write a script that counts all A, T, C, and G characters…”
Optional, but useful pieces for prompting (cont)
- Ask if you need help: Sometime its useful to add onto the end of your prompt, “Ask for clarification if needed.” AI models aren’t necessarily designed to ask for clarification right off the bat.
- Be iterative: If you struggle with what information to include and not include, start prompting with our three building blocks (task, context/constraints, output format) as a foundation. Build upon the response you recieve.
Let’s practice prompt engineering
Boot up your favorite AI model (in the terminal or online) and let’s get started!
Questions?