Overview
Prompt engineering is the practice of designing and refining prompts—questions or instructions—to elicit specific responses from GenAI large language models (LLMs). It serves as the interface between human intent and machine output. In the fields of natural language processing (NLP) and artificial intelligence (AI), prompt engineering has become a crucial skill to master LLMs. Effective GenAI prompting is the key to unlocking high-quality, productive outcomes from AI.
A prompt can be a query, a command, a statement of feedback, or even a longer statement including context and instructions. Prompt engineering may involve phrasing a query, specifying a style, providing relevant context, or assigning a role to the AI. It can also include providing examples for the model to learn from, known as few-shot learning.
Different AI tools can produce different results. Even the same AI tool can and will produce different outputs from the same input. Practice is key to getting the results you want. A good AI prompt includes four components:
- Role: Prompts starting with "act as..." or "pretend to be..." will provide responses similar to that of the role that you provide. Setting a specific role for a given prompt increases the likelihood of more accurate information when done appropriately.
- Task: Ask the AI to complete a specific task with as much detail as you can provide. The task is a summary of what you want the prompt to do. There is a lot of creativity that comes into writing a great task. It can range from generating birthday gift ideas to doing game show questions with the content from your last lecture.
- Format: Make sure to tell the AI exactly what format you would like the output in. For example, paragraph form, table, bulleted list, etc. Writing clear requirements is all about giving as much information as possible to ensure your response doesn't use any incorrect assumptions. AI models make assumptions for any information they don't have in the prompt.
- Tone: Tell the AI the type of tone you would like the response to be in. This could be things like professional, conversational, academic, common language, enthusiastic, optimistic, authoritative..etc
To get the most out of ChatGPT's or similar tools' output, here are some best practices and techniques to consider:
- Be concise: Avoid colloquialisms and slang, use direct language, and avoid trying to complete multiple tasks at once
- Target word complexity; This will help the AI understand the level of sophistication of the output
- Provide context: Provide the AI with a persona (a description of a person it should act as), the audience, the situation
- Specify the output format: With a text AI - are you looking for quiz questions, a rubric, some bullet points from a transcript, a text description of an image, a summary of a document, a research question or paper title, a video script from your notes?
- Parameters: Is there any specific style or tone you're after? An artistic school or style of image? Background color? How long do you want the output to be in terms of words, minutes, pages, number of bullet points?
- Use role-playing: Prompt the model to act as a specific system or persona, such as a teacher, code editor, or interviewer. This tailored interaction can help achieve more targeted and accurate results. (Example of Use role playing)
- Be consistent: Maintain a consistent tone and flow in the conversation with the model. This ensures better legibility and coherence in the generated output.
- Try chain-of-thought prompting: It works by breaking down a complex problem into smaller steps and then prompting the LLM to provide intermediate reasoning for each step
Remember that while GenAI chatbots are powerful tools, they may still generate responses that are not always accurate or consistent (Hallucination). It's important to use your judgment and critically evaluate the responses to ensure the conversation maintains consistency and accuracy.
Note that ChatGPT has rolled out "custom GPTs" for paid subscribers. This functionality allows users to create persistent, contextualized personas that they can share with others.
By Tracy A. Mendolia-Moore, MA Ed, (CPP AI Symposium, November 2023).
The following is a detailed explanation of the process of using the PREP Framework to create better ChatGPT prompts. Here is a sample structure. (Please see full example here: Active Learning Lesson Plan.)
P = Prompt
- Design an active learning lesson plan for an intermediate accounting course.
R = Role
- You are an experienced accounting instructor preparing to teach a class of intermediate accounting students.
E = Explicit
- Your lesson plan should incorporate active learning strategies to engage students actively in the learning process.
- Include specific activities, resources, and assessments that promote active participation and deeper understanding.
- Ensure that your lesson plan aligns with the course objectives and covers a relevant topic from the intermediate accounting curriculum.
P = Parameters
- The lesson plan should span a 90-minute class session.
- Select one specific topic within intermediate accounting, such as revenue recognition or depreciation, to focus on.
- Incorporate at least two active learning activities, such as case studies, group discussions, or problem-solving exercises.
- Provide a clear timeline for each activity, specifying when it will be conducted during the class.
- Include formative assessments to gauge student understanding throughout the lesson plan.
- Ensure that the lesson plan promotes student engagement and participation throughout the session.
Here are the direct links to more examples:
- Prompt Engineering Guide
- AI Prompts for Teaching - collection of example prompts and activities by Cynthia J. Alby at Georgia College and State University
- Working with AI: Two paths to prompting by Ethan Mollick, November 1, 2023
- AI for Education Chatbot Prompt Library. Very comprehensive list of prompts.
- Prompt Engineering OpenAI
- Prompt Engineering Guide
- Best Prompts for ChatGPT (Ultimate List for 2024) written by Christopher Kkoski
- How to write effective ChatGPT prompts (ZDNET, January 24, 2024)