Prompt Engineering
A prompt is a statement that expects a response. In conversational AI, you prompt the chatbot to help you accomplish a task; for example, to write an essay or generate a business report. Prompt engineering is a skill that allows for precise, yet creative, expression.
In this lesson:
1. What is prompt engineering?
2. How are prompts structured?
3. Getting the best results
What is prompt engineering?
You converse with the AI using statements called “prompts.” A prompt might have the form of a question, command, instruction, request, or suggestion. When you chat with the AI, you often have a goal in mind. You might wish to learn about a topic, get help with homework, plan a vacation, or brainstorm an idea.
Prompt engineering is essentially the practice of designing and refining prompts to get specific responses from AI models.
As tasks grow more complex, the instructions to the system must also increase. First, let’s look at some simple examples.
[User]: “What time is it?”
[Chat]: “It’s 5:43 PM.”
Based on the input, the system understands that the user wants to know the time.
[User]: “What time is it in Cleveland, Ohio?”
[Chat]: “It’s 8:43 PM in Cleveland, Ohio.”
The above prompt contains an additional piece of contextual information (Cleveland, OH) which the system uses to deliver a response.
How are prompts structured?
Prompts are often described as having up to four parts:
1. Instruction
2. Context
3. Input data
4. Output format
Instruction
The instruction is the command you give the system. The instruction is what you want the chatbot to do.
Examples:
[User]: “Tell me about…”
[User]: “Write an essay…”
Context
The contextual part of the prompt contains additional information that clarifies the task.
Examples:
[User]: “Write an essay about the life and times of F. Scott Fitzgerald.”
[User]: “What are the spices in Cajun seasoning?”
Context isn’t required, but in most cases you’ll provide context in order to narrow the scope of the AI’s response. You’ll get better specific results by providing background context.
As in normal conversations, the AI remembers details that you provide. Those details become part of the conversation’s context. Stay focused and stick to the topic.
Input Data
Within your prompt, you can provide specific data that you want the AI to use. You could input anything, including baseball scores, sales records, a recommendation, or your own content for proofreading.
Examples:
[User]: “Write a report about the life and times of F. Scott Fitzgerald. Include his early childhood, education, and career highlights.”
[User]: “Generate a sales report based on the attached figures.
[User]: “Show me a picture of the company mascot riding a winged Pegasus.”
Output format
Within your prompt, tell the system how you want the output formatted. Conversational AI will tailor its response to your request.
Examples:
[User]: “Translate this document into Japanese.
[User]: “Format the sales data in a spreadsheet showing cost of acquisition.”
[User]: “Write a social media post about…”
[User]: “Write a Python program to sort a list of numbers.”
The AI can respond in any style or tone, including languages, dialects, and even computer code. Advanced AIs generate images, music, and videos.
Getting the best results
Conversational AI is a skill and an art. Experimentation and practice will improve your results. As you use the system you get positive feedback from your success. This guide will help you avoid the trial and error method of learning.
If you have a specific goal or use case, first understand what you want to accomplish. Is this an analytical task that requires input data, or is it a creative task that requires an output style and tone? Understanding the task yourself helps you structure your prompts to get more precise and better results.
Open-ended and close-ended prompts
Are you looking for an answer or a solution? If you want an answer, use close-ended prompts. Close-ended prompts are good for extracting a single, simple answer.
Examples:
[User]: “What’s the tallest building in the world?”
[User]: “What is a ‘widget?'”
[User]: “What does XYZ mean?”
If you want a solution, use open-ended prompts. Open-ended prompts do not require a specific answer. They allow the chatbot to flex its awesome capabilities.
Examples:
[User]: “How did invention of the automobile affect the economy?”
[User]: “Write a story about…”
[User]: “How can I find new markets for my product?”
Active listening
The art of the conversation is in the listening. Listen, understand, and respond to the AI. If the chat is too verbose, ask the AI to be more concise. “Hey, this is too technical!” tells the chatbot to simplify its responses.
The AI may occasionally generate an incorrect response and not notice the mistake. You can ask the AI to explain how it reached a conclusion, which is often helpful for framing the topic.
You can provide an example of what you have in mind.
Example:
[User]: “That’s good, but can we make it more sentimental, like a Hallmark greeting card?”
What’s next?
In this lesson we looked at the structure of prompts, and how to achieve good results. In the next lesson we’ll reinforce the topic of prompt engineering with more examples.