Components of a Prompt
A prompt is essentially made up of:
-
Instruction
: Specifies the task you want the AI to perform -
Context
: Provides background information and circumstances for the AI to refer to when performing the task based on the instruction -
Input Data
: The data the AI analyzes or refers to while performing the task -
Output Directives
: Specifies the format of the desired output as required by the prompt
These four key components divide a prompt.
Instruction
An instruction specifies the task you want the AI to perform.
Much like with humans, to obtain accurate results from AI, you must provide precise instructions rather than vague ones.
Below are examples of good and bad prompts for an image-generating AI.
Please draw a cabin.
The above instruction is too vague and lacks specific information.
There are no guidelines on the style, elements, or colors of the generated image, making the outcome unpredictable.
Please draw a small cabin in a quiet forest.
The cabin should be made of wood and surrounded by lush green trees.
Show a sunset sky in the background.
The sky should be tinted with orange and pink hues.
Providing such detailed
and visualized instructions
allows the AI to generate an image that matches the user's intentions accurately.
Context
The context provides background information and circumstances for the AI to refer to when performing the task based on the instruction.
# Instruction
Based on the sales data of each product given below,
analyze the sales trends of each product category over the past five years.
# Context
Due to increasing market competition, there is a need for in-depth sales analysis
of the company's product line.
In particular, the analysis aims to understand how sales volume changes with seasons
and to identify which products have been most popular.
Providing a context like the need to analyze sales trends
and identifying the most popular products based on seasonal changes
helps the AI to perform the requested task more accurately.
Input Data
Input data refers to the data the AI will analyze or refer to while performing the task.
In the above sales data analysis example, the sales data
shown below is the input data.
Year | Month | Product Category | Sales Volume |
---|---|---|---|
2019 | 1 | Appliances | 150 |
2019 | 1 | Furniture | 75 |
2019 | 1 | Electronics | 200 |
2019 | 2 | Appliances | 165 |
... | ... | ... | ... |
2023 | 12 | Appliances | 190 |
2023 | 12 | Furniture | 90 |
2023 | 12 | Electronics | 230 |
Output Directives
Specifies the format of the required output in the prompt.
For example, when requesting data analysis, the output directives might include instructions to present the results in the form of a table, graph, or text summary.
Below is an example of a prompt with an output directive
for a tabular format.
Based on the key terms mentioned in the news article below,
compile the frequency of each keyword in a table.
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.