Get startedGet started for free

Prompt engineering basics

1. Prompt engineering basics

Welcome back! In this next video, we will explore how the phrasing of our instructions can significantly impact the model’s performance.

2. What is a prompt?

The input or instruction we give to an AI model is called a “prompt”.

3. What is a prompt?

Given the very same model, the way we write prompts has a significant impact on the model’s output.

4. What is a prompt?

Let’s imagine a movie scene: It’s raining. The main character gets into the back seat of a taxi, suitcase in hand. The driver looks in the mirror and asks: “Where to?”. The man just stares out the window and replies: “Anywhere”. So the taxi drives, left, right, past neon signs and empty gas stations, until eventually it comes to a stop.

5. What is a prompt?

Now let's rewind the scene. Same environment. Same cab. But this time, the character says: “Take me to 23 Main Street. Avoid the highway”. The driver nods and heads straight to the destination. In this analogy, the driver is the AI model, and our prompt is the destination. A prompt is simply what we type to tell the AI what we want. If we’re vague, the AI might guess and produce a less helpful output. If we’re specific, the AI better understands our goal and generates a more accurate result.

6. Prompt quality

In general, there’s no strict definition of a bad prompt, but vague or overly general instructions often lead to lower-quality results. For example, prompts like “Fix this code” lack clarity and intent. In this case, the model has to guess the goal and may take actions we didn’t intend. This prompt becomes much more effective when we provide a clear goal and the desired boundaries. For example, we could rewrite the previous prompts like this: “Fix this Python function to handle division by zero errors. Keep the structure the same, and only change the except block”

7. Prompt quality

Another important aspect is the level of detail we include in our prompts. In general, the more specific our prompt can be, the better the model’s output. For example, the prompt “Generate a Python function to reverse a string” is not necessarily a bad prompt, but it may lack some detail. Since we might already know the constraints of the function we want, we can write the prompt with more detailed instructions. For example, we could say instead: “Generate a Python function that reverses a string, handles Unicode characters, and ignores trailing whitespace.” This second version gives the model clearer direction and reduces ambiguity.

8. Components of a prompt

At this point, you might be wondering: "What makes these prompts effective?" A strong prompt usually includes three parts: an instruction, relevant context, and any specific constraints. For example, if we revisit the first example of a good prompt that we discussed earlier: “Fix this Python function to handle division by zero errors. Keep the structure the same, and only change the except block”.

9. Components of a prompt

We can easily break it down into the three components: an instruction to "Fix this function"; some context, "Python code with a divide-by-zero error"; and a constraint to "Only modify the try-except block"

10. Let's practice!

Let’s pause here for a moment and try out what we have just learned!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.