What is prompt engineering?
Before explaining what prompt engineering is, let’s start by defining a prompt.
A prompt is text input that guides the behavior of an LLM to generate an output. For example, whenever we interact with ChatGPT, asking a question or giving an instruction, that input text is a prompt. In the context of LLMs and LLM-powered applications, we can distinguish two types of prompts:
- The first type is a prompt that the user writes and sends to the LLM. For example, a prompt might be “Give me the recipe for Lasagna Bolognese,” or “Generate a workout plan to run a marathon.”

Figure 3.1: An example of a user’s prompt
You will hear this referred to simply as a prompt, a query, or user input.
- The second type is a prompt that instructs the model to behave in a certain way regardless of the user’s query. This refers to the set of instructions in natural language that the model is...