No history yet

Introduction to Prompt Engineering

Asking the Right Questions

Working with a large language model is like having a conversation with an incredibly knowledgeable but very literal assistant. It knows a vast amount of information, but it doesn't know what you're thinking. To get what you want, you need to learn how to ask. This skill is called prompt engineering.

Prompt engineering is the discipline of crafting, refining, and optimizing these prompts.

Think of it like ordering a coffee. If you just say "coffee," you might get a plain black coffee, a latte, or something else entirely. But if you say, "I'd like a medium iced latte with oat milk and one pump of vanilla syrup," you're much more likely to get exactly what you want. The more specific and clear your instructions, the better the result.

Prompt

noun

The input, question, or instruction you give to an AI model to generate a response.

A vague prompt leads to a vague answer. If you ask an AI to "Write about dogs," it has to guess what you're interested in. Are you curious about different breeds, dog training, the history of dog domestication, or famous dogs in movies? The model doesn't know, so it will give a very general response.

A better prompt is specific. For example: "Write a short paragraph about the three most popular dog breeds in the United States, and include one interesting fact about each."

This prompt tells the AI exactly what to do:

  • Topic: Popular dog breeds in the U.S.
  • Scope: The top three.
  • Format: A short paragraph.
  • Constraint: Must include one interesting fact per breed.

Being direct and clear removes the guesswork for the AI.

Lesson image

Refine and Repeat

You won't always get the perfect response on your first try. That's okay. Prompt engineering is an iterative process. It's a cycle of trying something, seeing what you get, and then adjusting your prompt to get closer to your goal.

Maybe the AI's first answer was too long, or the tone was too formal. You can simply add to your prompt or start a new one, saying something like, "Make that shorter and use a more casual tone." Each adjustment is a new prompt that refines the output.

This back-and-forth is central to getting high-quality results. Don't be afraid to experiment and give the AI feedback on its responses.

Context is Key

Providing context in your prompt is like giving your assistant the background information needed to do a good job. The more relevant information you provide, the more tailored the AI's response will be.

Imagine you ask, "Write an email to my team." The AI has no context. Who is your team? What is the email about? What is the tone?

Now, try this prompt with context: "You are a project manager. Write a friendly and encouraging email to your software development team. The email should remind them that the project deadline is this Friday but also praise them for their hard work so far."

This second prompt provides:

  • Role: You are a project manager.
  • Audience: The software development team.
  • Goal: Remind them of the deadline and praise them.
  • Tone: Friendly and encouraging.

With this context, the AI can generate a much more useful and appropriate email.

A good prompt often tells the AI who it should be, who it's talking to, and what the ultimate goal is.

Finally, it's helpful to understand the model's capabilities and limitations. These AI models are trained on a massive amount of text from the internet. They are excellent at summarizing information, generating creative text, and translating languages. However, they are not conscious, they don't have personal experiences, and their knowledge has a cutoff date. They can also make mistakes, sometimes called "hallucinations." Knowing what an AI is good at, and what it's not, helps you craft prompts that play to its strengths.

Ready to test your knowledge? Let's see what you've learned about crafting effective prompts.

Quiz Questions 1/6

What is the best analogy for interacting with a large language model?

Quiz Questions 2/6

You give an AI the prompt: "Write about cars." The response is very general. Why is this outcome expected?

Prompt engineering is a skill that improves with practice. By writing clear instructions, providing context, and refining your approach, you can unlock the full potential of AI.