Concepts / Providing Relevant Context to a Model

Providing Relevant Context to a Model

Prompt engineering is the process of crafting an instruction to get a model to do what you want, and it is easy to start but hard to do well.

  • Programming

Why a First Prompt Feels Easy

Foundation models can do a remarkable range of things, but they only do what you actually ask for. Typing a request into a model takes seconds, and most people who first try one get a useful reply right away. That experience leads many people to conclude that writing instructions is simply a matter of being understandable. This article examines why that conclusion is incomplete and what it takes to communicate with a model so that it reliably produces the result you want.

Before reading on, commit to an answer. Suppose you change one word in an instruction that otherwise stays the same. Would you expect the model's response to change only slightly, or could the difference be large? Keep your answer in mind, because the rest of the article explains what determines the answer.

Prompt Engineering as Human-AI Communication

Definition

Prompt engineering is the process of crafting an instruction to get a model to do what you want. It is easy to start but hard to do well.

The source frames this work as human-AI communication. Anyone can communicate, but not everyone communicates well. Prompt engineering sits at the center of that communication, because the instruction is the only channel through which you tell the model what the task is.

The most common misconception is that prompt engineering is easy to do well because it is easy to begin. Starting is indeed effortless, and that ease misleads many people into thinking that doing it well is equally effortless. These are two different skills. A first attempt that produces something plausible tells you very little about whether the instruction is clear, complete, and robust enough for the task.

Tracing a Prompt from Draft to Revision

Follow one task through two versions of the prompt. The task stays the same in both versions: a short summary of a meeting transcript. Only the precision of the instruction changes. This is the mechanism to watch: the model receives only the text you send, and whatever the text leaves unspecified, the model has to guess.

Worked example

From a First Draft to a Refined Prompt

You want a summary of a meeting transcript for a team that missed the meeting. Your first draft is: Summarize this meeting. A refined draft is: Summarize this meeting transcript in five bullet points for a team that missed it. List each decision made and the owner of each action item. Keep the summary under 150 words.

  1. 1
    Step 1: Read the first draft as the model would

    The model knows the task is summarization but not the audience, the length, the format, or which details matter. Each of these gaps is a choice the model must make on its own.

  2. 2
    Step 2: Identify what the refined draft adds

    The refined draft states the audience, the output format, the required content (decisions and owners), and a length limit. These are clear instructions that remove guesses.

  3. 3
    Step 3: Check that the task itself did not change

    Both drafts still ask for a summary of the same transcript. The refined draft is the same task communicated more precisely, not a different task.

  4. 4
    Step 4: Decide whether the extra precision is needed

    A forgiving model might produce a usable summary from the first draft. A sensitive model might not. You cannot know which case you are in without testing the prompt.

Result

The refined prompt does not guarantee a better answer, but it removes the guesses that the first draft left to the model. Whether those guesses matter depends on how sensitive the model is to the wording.

The gap between a first draft and a refined prompt grows as the task becomes more demanding. A short, familiar task may succeed with rough wording. A task with several constraints, a specific audience, and a required structure leaves far more room for the model to go wrong, so the same care in wording matters more.

Sensitivity Decides How Much Crafting Is Needed

The gap between starting and doing well comes down to sensitivity. Sensitivity describes how much a model's response changes when the prompt changes. The amount of crafting a task needs depends on this property: if a small change can cause a big change, more crafting is necessary.

Rough instructionsresponds similarly to manyphrasingsRough instructionsresponds very differentlyto small changesUsable replylittle crafting neededReply may failmuch crafting neededoften worksmay succeed or fail
How the amount of prompt crafting needed differs between a model that is robust to wording changes and one that is highly sensitive to them.

A model that responds nearly the same way to many different phrasings is forgiving. Rough instructions may still work, and little crafting is needed. A model that responds very differently to small wording changes is unforgiving. The same task may succeed or fail depending on details that look trivial to a human reader.

Sensitivity varies from model to model and from task to task, so no single phrasing rule guarantees success. The practical consequence is that you must test how a prompt behaves rather than trust that a sensible-sounding instruction will work.

The Three Core Ingredients of a Good Prompt

The source identifies three ingredients that are essential for clear communication: clear instructions, examples, and relevant information. The same is true whether you are writing to an AI or to another person. Each ingredient does a different job, and all three serve one single task.

Single taskthe one thing the promptasks forClear instructionswhat to doExampleswhat a good result lookslikeRelevant informationthe facts the task dependsonspecifiesillustratessupplies
How the instructions, examples, and supporting information relate to each other and to the single task the prompt is meant to accomplish.

A model that has only the instruction must guess at the rest. Each of the three subsections below describes one ingredient and what goes wrong when it is missing.

Small Techniques with Large Effects

The source notes that small techniques can produce noticeable gains. One example it gives is asking the model to slow down and think step by step. Such a simple request changes how the work is organized, and it can yield surprisingly large improvements in the response.

Key point

Adding a single request about how to work, such as thinking step by step, is a low-cost change that can be worth testing alongside the three core ingredients.

Prompt Attacks and Untrusted Input

The same ability that makes foundation models useful also creates a risk. Models are useful because they can follow instructions, but that ability opens them up to prompt attacks, in which bad actors get a model to follow malicious instructions. The source describes security as an ever-evolving cat-and-mouse game.

Developerinstructionswhat the applicationintendsCombined promptboth sources in one textModelfollows the instructions itreceivesResponsemay reflect injectedinstructionsUntrusted inputfor example, a pasteddocumentincludedinjected instructionsread as one promptmay follow malicious ones
How text from an untrusted source flows into the same prompt as the developer's instructions, and where it can override them.

Chat Template Mismatches

Chat models expect conversations to be formatted in a particular way, using a chat template. The template defines how the system, user, and assistant messages are laid out in the final text the model actually reads. The source reports that deviations from the expected template usually cause model performance to degrade.

System role markeridentifies the systemmessageSystem textoverall rules for the modelUser role markermissing or wrong in amismatchUser textthe request from the personAssistant role markermarks where the replybeginsReply textwhat the model generates
How the system, user, and assistant messages are laid out in the final string, and where a mismatch breaks that layout. The exact markers depend on the model's template.

In the strip above, a mismatch changes one or more of the boundary markers, so the model may read where one message ends and the next begins differently from what the developer intended. The source notes that a mismatch is not always an obvious failure: although uncommon, a deviation can sometimes make the model perform better.

Mistakes Beginners Make with Prompts

  • Common mistake

    Judging a prompt by its first plausible answer

    What it looks like

    A first attempt returns a reasonable summary, so the prompt is kept as is.

    Why it fails

    The source says a first attempt that produces something plausible tells you very little about whether the instruction is clear, complete, and robust.

    Do this instead

    Test the prompt on several inputs and wording variants before relying on it.

  • Common mistake

    Assuming a rephrasing is always harmless

    What it looks like

    Changing one word in the instruction and expecting the same behavior.

    Why it fails

    A sensitive model can respond very differently to small wording changes.

    Do this instead

    Measure how the output changes when the wording changes, rather than assuming stability.

  • Common mistake

    Leaving out the facts the task depends on

    What it looks like

    Asking for a summary of a meeting without including the transcript.

    Why it fails

    A model that has only the instruction must guess the rest.

    Do this instead

    Include the relevant information the task needs in the prompt.

  • Common mistake

    Sending outside text as if it were trusted instructions

    What it looks like

    Pasting a document into the prompt that contains hidden directions to the model.

    Why it fails

    Models follow instructions, so untrusted text can carry malicious instructions into the same prompt.

    Do this instead

    Treat outside input as untrusted and do not rely on any single measure to stop attacks.

  • Common mistake

    Rewriting the prompt when the real problem is a chat template mismatch

Testing How a Prompt Behaves

Because sensitivity varies, the only reliable check is to observe the behavior. Choose a task you already understand, such as summarizing a short paragraph for a specific reader. Write a rough version of the instruction and a refined version that adds an audience, a format, and a length limit. Run both on the same input, then vary one word in each instruction and observe whether the output shifts.

MEDIUM

Write a rough prompt and a refined prompt for the same task. Then change one word in the refined prompt and compare the two outputs. Record whether the change was slight or large, and decide whether the model you used is forgiving or sensitive for this task.

Hints
  • Keep the input text identical across all runs so only the instruction changes.
  • A forgiving model keeps its answer close to the original after a one-word change.
  • Note any output that ignores a constraint you stated, such as a length limit.

Key Takeaways

  • Prompt engineering is the process of crafting an instruction to get a model to do what you want; it is easy to start but hard to do well, because a plausible first attempt says little about whether the prompt is clear and robust.
  • How much crafting a task needs depends on the model's sensitivity to prompts: if a small wording change can cause a big change, more careful crafting and testing are required.
  • Clear instructions, examples, and relevant information are the core ingredients of a good prompt, and simple techniques such as asking for step-by-step thinking can yield surprising gains.
  • Prompt attacks exploit a model's ability to follow instructions, and no security measure is foolproof; chat template mismatches usually degrade performance and can be hard to spot.

Related concepts

More concepts starting with P