What is a Prompt?
Prompt engineering is the practice of carefully crafting and optimizing prompts (input text or queries) to guide the responses of Artificial Intelligence (AI) models, such as GPT-3 and DALL-E. Learning how to effectively craft prompts is a crucial skill for anyone who wants to use AI to effectively solve problems.
You can think of prompts as a way to communicate with AI models. The better you are at communicating, the more likely the AI will deliver your desired results.
What is a prompt? #
At its most basic level, a prompt is a piece of text that is used to communicate with an AI model. The AI model then generates a response based on the prompt. For example, the following is a prompt:
The quick brown fox
Understanding Output Behavior #
How an AI model responds to a prompt depends on a variety of factors, including:
- How it was trained
- What it was trained on
- What parameters it was trained with
- What prompt was provided
We won’t go into detail about how an AI model is trained in this guide, but think of it this way: if you ask a physician about a toothache, they will likely respond differently than if you ask a dentist. Both are trained to diagnose and treat bodily ailments, but one has more specialized knowledge that can provide better assistance. With both experts, the more information you provide, the better their diagnosis will be. The same is true for AI models.
Example Outputs #
Let’s take a look at some example outputs from different AI models, using our basic prompt, the quick brown fox
. Notice how the outputs vary in length and content.
Basic Autocomplete (GPT-3 or earlier) #
The quick brown fox jumped over the lazy dog.
Historically, AI models were trained to predict the next word in a sequence of words. This is known as autocompletion. In this case, the AI model knows that the most common words to follow the quick brown fox
are jumped over the lazy dog
because that phrase can be found several times in its training data (across books, articles, etc.).
Newer models build on top of this predictive concept, but are able to handle more complex prompts to generate more targeted outputs.
Informational (GPT-3.5) #
The phrase "the quick brown fox" is often used as a pangram, which is a sentence or phrase that contains every letter of the alphabet at least once. It is commonly used for testing fonts, keyboard layouts, and typewriters to ensure that all letters are represented.
This output is more informative in nature because the AI model underwent more extensive training that included instructions (or tasks) and alignment to human preferences to ensure that model responses are favorable to humans. Moreover, the model generation process can be guided by setting so-called “generation parameters.” For example, its temperature (creativity) may be higher, allowing it to generate a response that is not as literal as the previous example. In the end, the model still uses the same predictive autocomplete technique, but it is able to generate a more complex response.
Illustrative (GPT-4) #
Since GPT-4 comes equipped with DALL-E, it is able to generate an illustrative response when appropriate. In our case, the prompt we provided was a basic visual prompt, so it generated an image of a fox jumping over a lazy dog. Notice however that we did not mention a dog (much less a lazy one) in our prompt. The AI model chose to add the dog itself, likely because the quick brown fox
is often used in the phrase the quick brown fox jumped over the lazy dog
. It used that same predictive autocomplete technique shown in our previous examples to generate a response that it thought would be most appropriate.
Beyond Basic Prompting #
Now that you have a basic understanding of prompts and how their outputs can vary based on the AI model, let’s take a look at some simple prompting structures in the next section.