Skip to main content
Workforce LibreTexts

2: The Art of the Prompt

  • Page ID
    67037
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\dsum}{\displaystyle\sum\limits} \)

    \( \newcommand{\dint}{\displaystyle\int\limits} \)

    \( \newcommand{\dlim}{\displaystyle\lim\limits} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \(\newcommand{\longvect}{\overrightarrow}\)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

      What is prompting?

      Prompts are the input instructions for AI tools to perform tasks. They can include text, data (such as tables) or images. The input of a prompt is converted into tokens by the AI tool. Tokens represent the prompt elements converted into a form that the tool understands. These are processed and converted back into words or other outputs. The tool prompt length is limited by the number of tokens allowed to be input. A prompt is better understood as a set of constraints than as an instruction. The model's knowledge was fixed during training and your prompt adds nothing to it; what the prompt does is force the model to draw from one particular region of what it already contains. A direct request with no examples narrows the enormous space of possible outputs down to the neighborhood you described. This is why small changes in wording produce large changes in output — you are not persuading the model, you are redrawing the boundary it works inside. Supplying one or more examples of the pattern you want narrows that boundary considerably further. This is commonly described as few-shot prompting, in contrast to zero-shot prompting where no examples are given. The examples do not teach the model a new skill; they identify which of its existing patterns to draw on and in what register. In practice, two or three well-chosen examples routinely outperform a paragraph describing what you want, because an example shows the target directly rather than asking the model to infer it from a description.

      Components of a good prompt

      Several frameworks exist for organizing a prompt, and they differ mainly in vocabulary. One compact version holds that a strong prompt has three parts: the task, meaning what you want the tool to do; the instructions, meaning how you want it done; and the context, meaning what you want the tool to know. Another common framework is the role–task–context–format framework.

      An infographic breaking down the key components of effective prompt engineering into four color-coded categories—Role (blue), Task (green), Context (orange), and Format (purple)—showing their definitions and providing an annotated example below.

      Generated by Google's Nano Banana 2 image generation model

      Prompting tips

      • Use instructional verbs: summarize, classify, write, and compose.
      • Expand on prompts iteratively — your first go doesn’t have to be perfect!
      • Write short but detailed prompts. Break down your tasks into a subtask list if needed.
      • Tell the AI what to do rather than tell it what not to do. Negative prompts can be useful in image generators.

      read icon Read Please Be Polite to ChatGPT on why being polite to your chatbot makes for better responses.

      Context is the component most often omitted and the one that most improves results. The reason follows directly from Chapter 1: the model predicts from the material in front of it. Deprived of context, it predicts the most generic document its training would suggest. Supplied with real context, it predicts something shaped like your actual situation. A short set of habits reliably improves output. Start simple and build through conversation rather than attempting one perfect prompt. Be specific. State what you want rather than what you want avoided, since naming the thing to avoid places those very words into play. Ask for several options rather than one. Fence off pasted material clearly so the tool can tell your instructions from your source text. Start a fresh conversation when a thread has accumulated dead ends, because the tool rereads the entire conversation each time and old mistakes continue to steer new answers. And when writing the prompt is itself the hard part, ask the tool to draft the prompt.

      Types of Prompts

      Simple Prompts

      A simple prompt or zero-shot prompt relies on the LLM training data to answer a question without any examples.

      • Provide a list of ten ideas for a report on solar energy issues.
      • Write a poem about Maranatha Baptist University.

      Few-shot Prompting

      Few-shot prompting provides examples of how a task is to be solved. It is used to guide the required output. An easy example is sentiment analysis.

      Input: Here are a few examples of movie reviews and what sentiment they have:

      • Review: "This movie was absolutely fantastic! I loved every minute of it."
      • Sentiment: Positive
      • Review: "The plot was confusing and the acting was terrible. What a waste of time."
      • Sentiment: Negative
      • Review: "It was okay. Not great, not terrible, just average."
      • Sentiment: Neutral

      Now, classify the sentiment of this review: "The special effects were amazing, but the story was predictable and the characters were flat." Output:

      • Review: "The special effects were amazing, but the story was predictable and the characters were flat."
      • Sentiment: Mixed.
      • Reasoning: The review contains both positive and negative aspects. While it praises the special effects, it criticizes the story and characters. This balance of contrasting opinions classifies it as a mixed sentiment.

      [Prompted August 9,  2026, OpenAI (2026), GPT 5.6 Luna response]

      Chain-of-thought prompting

      Chain-of-thought prompting is a technique in which the model is encouraged to provide reasoning for its answer in a series of logical steps to solve a problem. This type of prompting increases the transparency of the answer and encourages critical evaluation of the outputs. We will discuss more about how AI reasoning works in the next chapter.

      Input: Yes or no: Would a pear sink in water? Provide reasoning for your answer in logical steps before providing an answer. Output: 

      1. Density determines floating or sinking: An object floats in water if its density is less than that of water (approximately 1 g/cm³). If the object's density is greater, it sinks.
      2. Examining a pear's composition: A pear is composed of water, sugars, fibres, and air pockets within its cellular structure. The presence of air pockets lowers its overall density compared to water.
      3. Considering variations in pears: While most pears have a density less than water, factors like ripeness, water content, or damage can affect buoyancy. Overripe or denser pears might sink.

      Answer: No, a pear would not sink in water under normal conditions. It generally floats because its density is slightly less than water. [Prompted August 9,  2026, OpenAI (2026), GPT 5.6 Luna response]

      Why the Same Prompt Produces Different Answers

      Students frequently notice that an identical question asked twice produces two different answers, and reasonably conclude that the tool is unreliable. The behavior is real, but it is a design property rather than a malfunction, and understanding it converts an irritation into a control. Unlike a calculator, a generative model does not produce one correct answer. At every word it holds a ranked set of plausible continuations with associated probabilities, and it selects from that set. Asked to complete "the capital of France is," the word Paris carries an overwhelming probability, but the alternatives are not at zero. This is precisely the property that allows the same tool to be useful for both factual summary and creative drafting. Most tools expose settings that govern this behavior. Temperature determines how far the model may stray from its highest-probability choice: a low setting keeps output conservative and predictable, a high setting permits more surprising and varied language. Two related settings, commonly labeled top-k (selecting the number of top-ranking responses to consider) and top-p (selecting only the group of potential responses whose combined probabilities reach a set threshold for consideration), determine how wide a field of candidates the model considers before choosing at all. Taken together, these settings define where the model may explore, while temperature governs how boldly it explores within that space . The same mechanism explains the failure mode that Chapter 4 treats at length. A hallucination — a confident statement that happens to be false — is the model selecting a statistically plausible continuation that is not factually correct. No separate malfunction is required to produce one. The practical implication is that a single answer should be read as one sample rather than as a verdict: asking again, or rephrasing, is a legitimate and often necessary move.

      Beyond the Single Prompt: Standing Instructions and Supplied Documents

      Everything so far concerns one request typed into an empty box. Two further techniques extend the same logic and remove most of the repetition from everyday use. The first is the standing instruction, often called a system prompt: instructions and context written once, stored in a designated place, and silently attached to every subsequent conversation. It might record who you are, how you prefer output formatted, and what the assistant is for. Nothing unusual is happening here; the model is still predicting from what is in front of it, and a standing instruction simply guarantees that certain material is always in front of it. A standing instruction should hold only what is stable — per-task detail belongs in the individual prompt. The second is retrieval, sometimes called retrieval-augmented generation (RAG). You supply a set of documents that matter to you; when you ask a question, the system searches those documents and quietly attaches the most relevant passages to your prompt before the model answers. This is not a different kind of machine. It is the same prediction system with an automated librarian in front of it. Two benefits follow: your own documents can be more current than the model's training data, and grounding answers in real material reduces, though it does not eliminate, invented content. The corresponding limitation is that an assistant built this way is a specialist whose competence extends exactly as far as the documents provided and no further. Both techniques rest on a capacity worth naming, because it also explains a common frustration. When a tool appears to remember earlier parts of a long exchange, what actually happens is that the entire conversation is re-sent to the model with each new message, up to a limit called the context window. Nothing is being stored; the material is being reread each time. Early tools had small context windows and would effectively lose the beginning of a conversation before reaching its end. Modern tools have much larger ones, which is what makes supplying whole documents practical.

      Conclusion

      Prompting is less a technical skill than clear thinking made explicit. The components of a good prompt — a defined task, specific instructions, and adequate context — are the same components of a good brief given to a colleague, which is why practice with a tool that never tires quietly improves how you delegate to people. Two ideas from this chapter carry forward. The first is that variation in output is structural rather than accidental, so one weak answer is a sample and not a judgment on the tool or on you. The second is that context is the lever with the largest effect and the one most often left unused. Chapter 3 takes up what happens when a single well-formed request is still not enough: how to direct a model across a sustained exchange, and how asking it to work through a problem in visible steps changes what it can reliably do.


      2: The Art of the Prompt is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.

      • Was this article helpful?