Introduction to Prompt Engineering

Overview

What we'll be covering

Learn what is a prompt and why its important in AI, especially when working with language models.
Take a deeper look at the emerging careers in prompt engineering.

What is a Prompt? 

Let's begin by covering the fundamentals. A language model takes a prompt as input to generate text. Most prompts are made of three components: the instruction, the context, and the examples. The instruction directs the prompt, the context sets the scene for the prompt, and the examples explain the expected action.  

Here is a prompt: "Write a persuasive essay on the usage of genetically modified organisms (GMOs) in agriculture. Provide examples to back up your claims. Imagine that it's the 1990s."  

Can you identify all three components?
In this case, the instruction is in the first sentence "Write a persuasive essay on the usage of genetically modified organisms (GMOs) in agriculture”. This clearly tells the model what to do.  The context is in the last sentence, where the model is told to imagine it’s the 1990s. This situates the essay in a different time, limiting the arguments and the speech it can use.  

Finally, the example is clearly in the middle sentence, where the model is explicitly told to use examples to back up the claims.  

Now, why are prompts so important?
Well, the quality of a prompt directly affects the output of a language model. A well-designed prompt can result in precise and relevant replies, whereas a badly designed prompt might provide unclear or false outputs. So, it's essential that you understand how to create smart prompts in so that you can obtain the desired results from language models.

Different Types of Prompts

Let's dive into some prompt engineering techniques that can help you craft powerful prompts for language models:

  • Clear and Explicit Instructions:  Providing clear instructions in your prompt can guide a model's behavior. An example being if you want a model to summarize text, you could specify "Please provide a concise summary of the following passage."
  • Desired Answer Format: Specifying the format of the desired answer can help the model generate output accordingly. For instance, if you want the model to answer in bullet points, you can mention "Please provide your response in bullet point format."
  • Context and Examples: Modifying the context or examples in your prompt can influence the model's understanding and responses. You can provide relevant context or examples to guide the model towards the desired outcome, “Imagine you are a female in your thirties. Please provide examples of gender inequality struggles.”
  • Output Control: You can control the output of the model by adjusting the temperature and max tokens settings. Higher temperature values make the output more random, while lower values make it more deterministic. Max tokens limit the length of the output.
  • System Messages: Using system messages, which are messages from a "system" role in the conversation, can help guide the conversation and set the behavior of the model. For example, you can use a system message like "You are an expert assistant in the field of science" to set the context for the model.

Where to write prompts?

You will use prompts in platforms like ChatGPT where you will be presented with interface where the prompt will be how you will generate a response. We'll go into more detail on how to do this in the project next.

So let's go to the next section to get started on the project task.

Prompt Engineering Careers


With the rise of AI and large language models, so has the need for those with the ability to get the most out of them. This has resulted in a new set of jobs termed as prompt engineers who communicate with AI and these models through creation of efficient code to accomplish specific tasks and outputs.

The salaries for prompt engineers as of 2023 range from $90 - 180K base salary per year.

But there is some risk as not everyone thinks this is a sustainable job field, as the need for the skills prompt engineers will grow as AI grows in the workplace and everyday life.  Expectations are that as AI improves and developers address the gaps, AI itself could theoretically automate input generation.

Alternatively it becomes an expectation of all employees to be familiar with prompt engineering skills as much as we do with the internet. And as such it's important for all of us to learn the basics through projects like this one.

Let's Start Using Prompts

BackNext