Understanding Prompts
Improving the way that you prompt a foundation model is the fastest way to harness the power of generative artificial intelligence (generative AI). By interacting with a model through a series of questions, statements, or instructions, you can adjust model output behavior based on the specific context of the output that you want to achieve.
Using effective prompt strategies can offer you the following benefits:
- Enhance the model's capabilities and bolster its safety measures.
- Equip the model with domain-specific knowledge and external tools without modifying its parameters or undergoing fine-tuning.
- Interact with language models to fully comprehend their potential.
- Obtain higher-quality outputs by providing higher-quality inputs.
In this lesson and the subsequent ones, you will learn about various prompt engineering methodologies. You will learn how to frame questions with greater precision, provide examples of desired outputs, suggest intermediate steps, and more.
Elements of a prompt
A prompt's form depends on the task that you are giving to a model. As you explore prompt engineering examples, you will review prompts containing some or all of the following elements:
- Instructions: This is a task for the large language model to do. It provides a task description or instruction for how the model should perform.
- Context: This is external information to guide the model.
- Input data: This is the input for which you want a response.
- Output indicator: This is the output type or format.
The following is an example of a prompt that includes all these elements of a prompt. As you review this example, try to identify each element.
Example prompt
Prompt
Given a list of customer orders and available inventory, determine which orders can be fulfilled and which items have to be restocked.This task is essential for inventory management and order fulfillment processes in ecommerce or retail businesses.Orders:
- Order 1: Product A (5 units), Product B (3 units)
- Order 2: Product C (2 units), Product B (2 units)
Inventory:
- Product A: 8 units
- Product B: 4 units
- Product C: 1 unit
Fulfillment status:
- 1
The previous prompt includes all four elements of a prompt. You can break the prompt into the following elements:
- Instructions: Given a list of customer orders and available inventory, determine which orders can be fulfilled and which items have to be restocked.
- Context: This task is essential for inventory management and order fulfillment processes in ecommerce or retail businesses.
- Input data:Orders:Inventory:
- Order 1: Product A (5 units), Product B (3 units)Order 2: Product C (2 units), Product B (2 units)
- Product A: 8 unitsProduct B: 4 unitsProduct C: 1 unit
- Output indicator: Fulfillment status:
Negative prompting
Sometimes it's easier to guide a model toward a desired output by including what you don't want included in the output. Negative prompting is used to guide the model away from producing certain types of content or exhibiting specific behaviors. It involves providing the model with examples or instructions about what it should not generate or do.
For instance, in a text generation model, negative prompts could be used to prevent the model from producing hate speech, explicit content, or biased language. By specifying what the model should avoid, negative prompting helps steer the output towards more appropriate content.
Scenario
Now consider the prompt from the scenario in the previous lesson.
Scenario prompt
Prompt
Generate a market analysis report for a new product category.
- 1
This prompt lacks several crucial elements that should be included in a well-structured prompt. The prompt includes instructions for the model, which is essential to get an output of any kind. However, the missing elements of context, input data, and an output indicator make it difficult for the model to understand the specific requirements. The resulting output is unlikely to deliver a high-quality, tailored market analysis report that effectively addresses the underlying goals and objectives.
In the next lesson, you will learn how to modify prompts to guide foundation models (FMs) toward a more suitable output.