[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"cheat-sheet---en":3,"domain-info---en":3,"topic-info----en":3,"lesson-aws-certified-ai-practitioner-foundation-model-applications-prompt-engineering-anatomy-of-a-prompt-en":4,"next-aws-certified-ai-practitioner-foundation-model-applications-prompt-engineering-anatomy-of-a-prompt-en":297,"prev-aws-certified-ai-practitioner-foundation-model-applications-prompt-engineering-anatomy-of-a-prompt-en":309},null,{"locked":5,"reason":3,"meta":6,"item":17},false,{"title":7,"description":8,"isFree":9,"estimatedMinutes":10,"difficulty":11,"learningObjectives":12},"Anatomy of a Prompt","Why the same model gives one team a useful answer and another team junk: the parts of a prompt, what each one does, and how instruction, context, input, and output indicator fit together.",true,16,"beginner",[13,14,15,16],"Identify the four working parts of a prompt: instruction, context, input, and output indicator","Distinguish the instruction from the input it acts on","Explain what a prompt template is and why the variables use double braces","Define zero-shot and few-shot prompting and what a shot is",{"id":18,"title":7,"body":19,"description":8,"difficulty":11,"estimatedMinutes":10,"extension":233,"infographics":234,"isFree":9,"learningObjectives":245,"meta":246,"navigation":9,"path":247,"quiz":248,"seo":294,"stem":295,"__hash__":296},"courses/courses/aws-certified-ai-practitioner/en/domains/03-foundation-model-applications/02-prompt-engineering/01-anatomy-of-a-prompt.md",{"type":20,"value":21,"toc":223},"minimark",[22,26,29,34,37,48,51,80,85,88,92,95,98,109,112,116,119,124,129,133,136,151,154,160,163,169,172,176,183,189,199,203,220],[23,24,25],"p",{},"You give a model a request and get back something vague or badly formatted. A teammate asks for what looks like the same thing and gets exactly what they wanted. The model is identical. The difference is the prompt, and specifically whether it was built out of the right parts in the right places.",[23,27,28],{},"A prompt is not just \"the question you type.\" It is a small structured document, and once you can see its parts, you can fix a weak answer by fixing the part that was missing. This lesson takes a prompt apart so the rest of the topic has something concrete to build on.",[30,31,33],"h2",{"id":32},"a-prompt-is-made-of-parts","A prompt is made of parts",[23,35,36],{},"Start with a real one. Here is a prompt for a customer support tool that has to route incoming messages:",[38,39,44],"pre",{"className":40,"code":42,"language":43},[41],"language-text","You are a support assistant for a bank.\nClassify the message below as Billing, Technical, or Other.\nMessage: \"My card was charged twice for one purchase.\"\nReply with only the category name.\n","text",[45,46,42],"code",{"__ignoreMap":47},"",[23,49,50],{},"That single block is doing four separate jobs, and each line maps to one of them:",[52,53,54,62,68,74],"ul",{},[55,56,57,61],"li",{},[58,59,60],"strong",{},"Context"," sets the scene: \"You are a support assistant for a bank.\" It tells the model what world it is operating in and, here, what role to play.",[55,63,64,67],{},[58,65,66],{},"Instruction"," is the task: \"Classify the message below as Billing, Technical, or Other.\" This is the one part a prompt can never drop.",[55,69,70,73],{},[58,71,72],{},"Input"," is the data the instruction acts on: the message \"My card was charged twice for one purchase.\"",[55,75,76,79],{},[58,77,78],{},"Output indicator"," constrains the answer: \"Reply with only the category name.\" Without it, the model might reply \"This looks like a Billing issue because the customer mentions a duplicate charge,\" which is harder for your code to use.",[81,82],"infographic",{"alt":83,"slug":84},"One support-classification prompt split into four labeled bands: role and context, instruction, input, and output indicator, each shown next to the actual prompt text.","prompt-anatomy-breakdown",[23,86,87],{},"AWS describes a prompt as a combination of these components: the instruction you want performed, the context of the task, demonstration examples, and the input text the model should use. You rarely need all of them at once. A prompt should combine the parts the task actually requires, and no more.",[30,89,91],{"id":90},"instruction-versus-input-the-distinction-that-matters-most","Instruction versus input: the distinction that matters most",[23,93,94],{},"The single most common source of confusion is treating the instruction and the input as one lump. They are different, and keeping them separate is what makes a prompt reusable.",[23,96,97],{},"Take the review text \"The food was great but the service was slow.\" On its own it is just input. It becomes a task only when an instruction wraps it:",[52,99,100,103,106],{},[55,101,102],{},"\"Summarize this review in one sentence\" gives you a summary.",[55,104,105],{},"\"Classify the sentiment of this review as positive, negative, or neutral\" gives you a label.",[55,107,108],{},"\"Translate this review into Spanish\" gives you a translation.",[23,110,111],{},"Same input, three different instructions, three different jobs. This is why production prompts keep the instruction fixed and swap the input on every request. Your support tool never rewrites \"Classify the message\" per customer. It reuses that instruction and drops in a new message each time.",[30,113,115],{"id":114},"context-and-output-indicator-the-two-parts-people-forget","Context and output indicator: the two parts people forget",[23,117,118],{},"The instruction and input are obvious once named. The other two get skipped, and skipping them is where weak answers come from.",[23,120,121,123],{},[58,122,60],{}," is background the model needs but that is not the input itself. \"The following text is from a restaurant review\" tells the model how to read what comes next. A role like \"You are a senior tax accountant\" shifts the vocabulary and caution level of the answer. Context does not ask for anything; it frames the ask.",[23,125,126,128],{},[58,127,78],{}," describes the shape of the answer. AWS shows this cleanly with summarization: \"Summarize the above text\" returns a paragraph nearly as long as the original, while \"Summarize the above text in one phrase\" returns a tight one-liner. If your downstream code expects a single word, a JSON object, or three bullet points, the output indicator is where you say so. When the model returns the wrong format, this is almost always the missing part.",[30,130,132],{"id":131},"zero-shot-and-few-shot-teaching-by-example-inside-the-prompt","Zero-shot and few-shot: teaching by example inside the prompt",[23,134,135],{},"Sometimes an instruction alone is not enough to pin down what you want, especially the exact format or edge-case handling. You can show the model instead of only telling it, by including worked examples in the prompt.",[23,137,138,139,142,143,146,147,150],{},"An example pair, one input plus its correct output, is called a ",[58,140,141],{},"shot",". A prompt with no examples is ",[58,144,145],{},"zero-shot",": you rely on what the model already learned during training. A prompt that includes one or more examples is ",[58,148,149],{},"few-shot"," (or one-shot for exactly one), also called in-context learning, because the model picks up the pattern from the prompt itself.",[23,152,153],{},"Here is a zero-shot sentiment prompt:",[38,155,158],{"className":156,"code":157,"language":43},[41],"Tell me the sentiment of this headline as positive, negative, or neutral:\nNew airline route offers a great opportunity for passengers and investors.\n",[45,159,157],{"__ignoreMap":47},[23,161,162],{},"And the few-shot version, which shows the model the exact answer format first:",[38,164,167],{"className":165,"code":166,"language":43},[41],"Tell me the sentiment of each headline as positive, negative, or neutral.\n\nResearch firm fends off allegations of impropriety over new technology.\nAnswer: Negative\n\nOffshore wind farms thrive as opposition dwindles.\nAnswer: Positive\n\nManufacturing plant is the latest target in a state investigation.\nAnswer:\n",[45,168,166],{"__ignoreMap":47},[23,170,171],{},"The examples do two things: they lock the output to one word, and they show how to handle tricky phrasings. The key point for later lessons is that few-shot learning happens entirely inside the prompt. It does not change the model. Close the session and the model remembers none of it, which is exactly what separates prompting from fine-tuning.",[30,173,175],{"id":174},"prompt-templates-the-reusable-recipe","Prompt templates: the reusable recipe",[23,177,178,179,182],{},"Once a prompt works, you do not want to retype it and risk breaking the wording. A ",[58,180,181],{},"prompt template"," freezes the structure and marks the parts that change. AWS writes the changing slots with double braces:",[38,184,187],{"className":185,"code":186,"language":43},[41],"Tell me the sentiment of the following {{text type}} as {{label A}} or {{label B}}.\n\nText: {{example input 1}}\nAnswer: {{label A}}\n\nText: {{input}}\nAnswer:\n",[45,188,186],{"__ignoreMap":47},[23,190,191,192,195,196,198],{},"The braces are a signal to whoever fills the template, not text the model sees. Before sending, you replace ",[45,193,194],{},"{{input}}"," with the real customer message and strip the braces. This matters because the last lesson in this topic, prompt management, is built entirely on templates with named variables, and prompt attacks in a later lesson exploit exactly the seam where your fixed instruction meets the untrusted ",[45,197,194],{},".",[30,200,202],{"id":201},"exam-tips","Exam tips",[52,204,205,208,211,217],{},[55,206,207],{},"If a question hands you a prompt and asks you to name its parts, map each line: what to do (instruction), what to do it on (input), the framing (context), the required format (output indicator).",[55,209,210],{},"\"Instruction\" and \"input\" are the classic trap pairing. The instruction is the verb, the input is the noun it acts on. A question that swaps them is testing this exact confusion.",[55,212,213,214,216],{},"A ",[58,215,141],{}," is an example pair inside the prompt. Zero examples means zero-shot; one or more means few-shot. If an answer choice says few-shot changes the model or its weights, it is wrong. In-context learning lives only in the prompt.",[55,218,219],{},"An output indicator controls format and length. When a scenario complains that answers are too long or the wrong shape, the fix is an output indicator, not a new model.",[23,221,222],{},"The one thing to carry forward: a prompt is a structure, not a sentence. When an answer disappoints, ask which part was missing rather than rewriting the whole thing from scratch. Next you will see the named techniques, from zero-shot up to chain-of-thought, that decide how much of that structure a given task actually needs.",{"title":47,"searchDepth":224,"depth":224,"links":225},3,[226,228,229,230,231,232],{"id":32,"depth":227,"text":33},2,{"id":90,"depth":227,"text":91},{"id":114,"depth":227,"text":115},{"id":131,"depth":227,"text":132},{"id":174,"depth":227,"text":175},{"id":201,"depth":227,"text":202},"md",[235],{"slug":84,"concept":236,"style":237,"aspectRatio":238,"labels":239},"A diagram that takes one concrete support-classification prompt and splits it into four labeled, color-separated bands stacked top to bottom, in the order they appear in the prompt: role/context, instruction, input, output indicator. Each band shows the actual prompt text for that part next to its component name. The emphasis is that a single block of prompt text is really four distinct jobs. A closing takeaway strip states the instruction-versus-input distinction that the whole lesson turns on.","diagram","4:3",[240,241,242,243,244],"Role / context: 'You are a support assistant for a bank'","Instruction: 'Classify the message as Billing, Technical, or Other'","Input: 'My card was charged twice for one purchase'","Output indicator: 'Reply with only the category name'","Instruction is the task. Input is the data it runs on. They are not the same part.",[13,14,15,16],{},"/courses/aws-certified-ai-practitioner/en/domains/03-foundation-model-applications/02-prompt-engineering/01-anatomy-of-a-prompt",{"passingScore":249,"questions":250},70,[251,260,268,276,284],{"question":252,"type":253,"options":254,"correctAnswer":255,"explanation":259},"In the prompt 'Summarize the following review in one sentence: The food was great and the service was slow', which part is the instruction and which is the input?","single",[255,256,257,258],"'Summarize the following review in one sentence' is the instruction; the review text is the input","The review text is the instruction; 'Summarize' is the input","Both halves are the instruction; there is no input","'in one sentence' is the input; the rest is the instruction","The instruction tells the model what to do, and the input is the data the model performs that task on. Separating the two is the core skill: the same review text could be summarized, translated, or classified depending only on which instruction wraps it.",{"question":261,"type":253,"options":262,"correctAnswer":264,"explanation":267},"What is the purpose of an output indicator in a prompt?",[263,264,265,266],"It retrains the model on your data","It constrains the shape or format of the answer, such as length or a required structure","It sets the billing region for the request","It hides the prompt from other users","An output indicator tells the model what the answer should look like, for example 'in one sentence' or 'reply with only the category name'. Without it the model picks its own format, which is often longer or looser than you wanted.",{"question":269,"type":253,"options":270,"correctAnswer":273,"explanation":275},"A prompt includes two worked examples of input paired with the correct output before the real question. What is this technique called?",[271,272,273,274],"Zero-shot prompting","Fine-tuning","Few-shot prompting","Retrieval augmented generation","A shot is one example pair of input and desired output placed inside the prompt. Providing several is few-shot prompting, also called in-context learning, because the model learns the pattern from the prompt itself without any change to its weights.",{"question":277,"type":253,"options":278,"correctAnswer":280,"explanation":283},"In a prompt template like 'Classify the following {{text type}} as {{label A}} or {{label B}}', what do the double braces mark?",[279,280,281,282],"Comments that the model ignores","Placeholders for data you fill in at run time; the braces themselves are not sent to the model","Required Bedrock security tags","The correct answer the model must return","A template is a reusable recipe with fixed instruction wording and marked slots for the changing parts. You replace each {{slot}} with real data before sending, and the braces are a convention for humans, not text the model should see.",{"question":285,"type":286,"options":287,"correctAnswers":292,"explanation":293},"Which of the following are genuine components of a prompt as AWS describes them? (Choose 3.)","multiple",[288,289,290,291],"Instruction (the task to perform)","Context (background that frames the task)","Input (the data the model operates on)","Learning rate (how fast the model updates weights)",[288,289,290],"Instruction, context, and input are three of the parts a prompt can combine, along with examples and an output indicator. Learning rate is a training hyperparameter and has nothing to do with prompt structure, since prompting never changes the model's weights.",{"title":7,"description":8},"courses/aws-certified-ai-practitioner/en/domains/03-foundation-model-applications/02-prompt-engineering/01-anatomy-of-a-prompt","qOgrwoVIu2H4EZLBxRyH2Ty_riK-gY1Q45ZGGaNA64Q",{"locked":9,"reason":298,"meta":299,"item":3},"paywall",{"title":300,"description":301,"isFree":5,"estimatedMinutes":302,"difficulty":303,"learningObjectives":304},"Prompting Techniques","From zero-shot to chain-of-thought: the named prompting techniques, how much scaffolding each one adds, and which task each is built for.",17,"intermediate",[305,306,307,308],"Compare zero-shot, one-shot, and few-shot prompting by the amount of example guidance each provides","Explain what chain-of-thought prompting does and when it helps","Distinguish chain-of-thought from prompt chaining","Match a task to the lightest technique that reliably solves it",{"locked":9,"reason":298,"meta":310,"item":3},{"title":311,"description":312,"isFree":5,"estimatedMinutes":313,"difficulty":303,"learningObjectives":314},"AI Agents in Applications","When a single prompt cannot finish the job: how agents reason across multiple steps and take actions, how Amazon Bedrock Agents orchestrate that loop, and where an agent fits versus plain RAG.",18,[315,316,317,318,319],"Explain what an agent adds beyond a single prompt-and-response","Describe the reason, act, observe loop an agent runs","Explain how Amazon Bedrock Agents use action groups and knowledge bases","Distinguish an agent from RAG and from a plain model call","Decide when a task warrants an agent"]