Back to AI Course

AI Course

What is Prompt Engineering?

Prompt Engineering is the practice of crafting clear, well-structured inputs (prompts) to guide a generative AI model toward producing the most accurate, relevant, and useful output. Since generative models respond directly to how a request is worded, the quality of the prompt has a direct impact on the quality of the result.

Why prompting matters

  • Generative AI models don't "know" what you actually want — they generate the most statistically likely response based on the prompt provided.
  • A vague or ambiguous prompt often leads to generic, incomplete, or off-target output.
  • A clear, specific, well-structured prompt helps the model understand context, tone, format, and intent — producing output much closer to what's actually needed.

Core elements of an effective prompt

Anatomy of an effective prompt

  • Task — Clearly state what you want the model to do (e.g., "Summarize," "Write," "Translate," "Classify").
  • Context — Provide relevant background information the model needs to produce an accurate, appropriate response.
  • Format — Specify how the output should be structured (e.g., bullet points, a table, a formal email, a numbered list).
  • Tone/style — Indicate the desired tone (e.g., formal, casual, persuasive, concise).
  • Constraints — Include any limits, such as word count, audience, or things to avoid.
  • Examples — When helpful, show the model an example of the kind of output you're looking for.

Common prompting techniques

  • Zero-shot prompting — Asking the model to complete a task directly, without providing any examples.

    • Example: "Summarize this article in three sentences."
  • Few-shot prompting — Providing a few examples of the desired input/output pattern before asking the model to complete a new one.

    • Example: Showing two examples of a properly formatted product description, then asking the model to write a third for a new product in the same style.
  • Role prompting — Assigning the model a specific persona or role to shape its tone and perspective.

    • Example: "You are a senior software architect. Review this API design and suggest improvements."
  • Chain-of-thought prompting — Asking the model to reason step-by-step before arriving at a final answer, which often improves accuracy on complex or multi-step tasks.

    • Example: "Walk through your reasoning step by step before giving the final answer."
  • Iterative prompting — Refining a prompt based on the model's previous output, rather than expecting a perfect result on the first try.

    • Example: Asking for a first draft, then following up with, "Make this more concise and formal."

A simple framework for writing prompts

  1. Define the goal — What outcome do you actually need?
  2. Provide context — What background information does the model need to know?
  3. Specify the format — How should the response be structured?
  4. Set constraints — Any length, tone, or scope limits?
  5. Review the output — Does it meet the goal? If not, refine the prompt and try again.

Example: Weak prompt vs. Strong prompt

  • Weak prompt
    • "Write about our new product."
  • Strong prompt
    • "Write a 150-word product announcement for our new project management tool, aimed at existing customers. Use a friendly, professional tone, highlight the top 3 new features, and end with a call to action to try it out."

The strong prompt gives the model clear task, context, format, tone, and constraints — dramatically increasing the chances of getting a usable result on the first attempt.

Reviewing and refining output

  • Check for accuracy — Does the output contain any factual errors or "hallucinated" details?
  • Check for relevance — Does it actually address what was asked?
  • Check for tone and audience fit — Does it match the intended reader and context?
  • Iterate as needed — If the output doesn't meet the need, adjust the prompt with more specific instructions rather than starting from scratch.

Common pitfalls in prompting

  • Being too vague — Leaving too much open to interpretation, resulting in generic output.
  • Overloading a single prompt — Asking for too many unrelated things at once, which can dilute the quality of the response.
  • Assuming the model has context it doesn't — Not providing background information the model actually needs to produce a relevant answer.
  • Treating the first output as final — Not reviewing or iterating on the result before using it.

Why this matters in practice

Understanding prompt engineering helps in recognizing:

  • Why the same AI tool can produce dramatically different quality output depending on how a request is phrased.
  • How to structure requests — for drafting emails, generating code, or summarizing documents — to get more consistently useful results.
  • Why reviewing and iterating on AI output is a normal, expected part of working with generative AI tools, not a sign that something went wrong.
  • How small adjustments to a prompt (adding context, format, or tone) can significantly improve the relevance and quality of generated content.