AWS Security ChangesHomeSearch

AWS bedrock documentation change

Service: bedrock · 2025-04-11 · Documentation low

File: bedrock/latest/userguide/prompt-engineering-guidelines.md

Summary

Added detailed documentation about prompt components, examples of zero-shot/few-shot prompting, prompt templates, and API usage patterns for different models

Security assessment

Changes focus on general prompt engineering best practices and usage examples without mentioning security vulnerabilities, access controls, or data protection measures. Content is educational rather than security-focused.

Diff

diff --git a/bedrock/latest/userguide/prompt-engineering-guidelines.md b/bedrock/latest/userguide/prompt-engineering-guidelines.md
index a576c7206..3bd5ad730 100644
--- a//bedrock/latest/userguide/prompt-engineering-guidelines.md
+++ b//bedrock/latest/userguide/prompt-engineering-guidelines.md
@@ -4,0 +5,2 @@
+What is a prompt?
+
@@ -38 +40,102 @@ Amazon Bedrock includes models from a variety of providers. The following is a l
-###### Topics
+## What is a prompt?
+
+Prompts are a specific set of inputs provided by you, the user, that guide LLMs on Amazon Bedrock to generate an appropriate response or output for a given task or instruction.
+    
+    
+    **User Prompt:**
+    _Who invented the airplane?_
+    
+
+When queried by this prompt, Titan provides an output:
+    
+    
+    **Output:**
+    _The Wright brothers, Orville and Wilbur Wright are widely credited 
+    with inventing and manufacturing the world's first successful airplane._
+    
+
+(Source of prompt: AWS, model used: Amazon Titan Text)
+
+### Components of a prompt
+
+A single prompt includes several components, such as the task or instruction you want the LLMs to perform, the context of the task (for example, a description of the relevant domain), demonstration examples, and the input text that you want LLMs on Amazon Bedrock to use in its response. Depending on your use case, the availability of the data, and the task, your prompt should combine one or more of these components.
+
+Consider this example prompt asking Titan to summarize a review:
+    
+    
+    **User Prompt:**
+    _The following is text from a restaurant review:
+    
+    “I finally got to check out Alessandro’s Brilliant Pizza and it is now 
+    one of my favorite restaurants in Seattle. The dining room has a beautiful view 
+    over the Puget Sound but it was surprisingly not crowded. I ordered 
+    the fried castelvetrano olives, a spicy Neapolitan-style pizza 
+    and a gnocchi dish. The olives were absolutely decadent, and the pizza came 
+    with a smoked mozzarella, which was delicious. The gnocchi was fresh and wonderful. 
+    The waitstaff were attentive, and overall the experience was lovely. 
+    I hope to return soon." 
+    
+    Summarize the above restaurant review in one sentence._
+    
+
+(Source of prompt: AWS)
+
+Based on this prompt, Titan responds with a succinct one-line summary of the restaurant review. The review mentions key facts and conveys the main points, as desired.
+    
+    
+    **Output:**
+    _Alessandro's Brilliant Pizza is a fantastic restaurant in Seattle 
+    with a beautiful view over Puget Sound, decadent and delicious food, 
+    and excellent service._
+    
+
+(Model used: Amazon Titan Text)
+
+The instruction `Summarize the above restaurant review in one sentence` and the review text `I finally got to check out ...` were both necessary for this type of output. Without either one, the model would not have enough information to produce a sensible summary. The _instruction_ tells the LLM what to do, and the text is the _input_ on which the LLM operates. The _context_ (`The following is text from a restaurant review`) provides additional information and keywords that guide the model to use the input when formulating its output. 
+
+In the example below, the text `Context: Climate change threatens people with increased flooding ...` is the _input_ which the LLM can use to perform the _task_ of answering the question `Question: What organization calls climate change the greatest threat to global health in the 21st century?”`. 
+    
+    
+    **User prompt:**
+    _Context: Climate change threatens people with increased flooding, 
+    extreme heat, increased food and water scarcity, more disease, and economic loss. 
+    Human migration and conflict can also be a result. The World Health Organization (WHO) 
+    calls climate change the greatest threat to global health in the 21st century. 
+    Adapting to climate change through efforts like flood control measures 
+    or drought-resistant crops partially reduces climate change risks, 
+    although some limits to adaptation have already been reached. 
+    Poorer communities are responsible for a small share of global emissions, 
+    yet have the least ability to adapt and are most vulnerable to climate change. 
+    The expense, time required, and limits of adaptation mean its success hinge 
+    on limiting global warming.
+    
+    Question: What organization calls climate change the greatest threat 
+    to global health in the 21st century?_
+    
+
+(Source of prompt: https://en.wikipedia.org/wiki/Climate_change)
+
+AI21 Labs Jurassic responses with the correct name of the organization according to the context provided in the prompt.
+    
+    
+    **Output:**
+    _The World Health Organization (WHO) calls climate change 
+    the greatest threat to global health in the 21st century._
+    
+
+(Model used: AI21 Labs Jurassic-2 Ultra v1)
+
+### Few-shot prompting vs. zero-shot prompting
+
+It is sometimes useful to provide a few examples to help LLMs better calibrate their output to meet your expectations, also known as _few-shot prompting_ or _in-context learning_ , where a _shot_ corresponds to a paired example input and the desired output. To illustrate, first here is an example of a zero-shot sentiment classification prompt where no example input-output pair is provided in the prompt text:
+    
+    
+    **User prompt:**
+    _Tell me the sentiment of the following headline and categorize it 
+    as either positive, negative or neutral: 
+    New airline between Seattle and San Francisco offers a great opportunity 
+    for both passengers and investors._
+    
+
+(Source of prompt: AWS)
+    
@@ -40 +143,2 @@ Amazon Bedrock includes models from a variety of providers. The following is a l
-  * [What is a prompt?](./what-is-a-prompt.html)
+    **Output:**
+    _Positive_
@@ -42 +145,0 @@ Amazon Bedrock includes models from a variety of providers. The following is a l
-  * [What is prompt engineering?](./what-is-prompt-engineering.html)
@@ -44 +147 @@ Amazon Bedrock includes models from a variety of providers. The following is a l
-  * [Understanding intelligent prompt routing in Amazon Bedrock](./prompt-routing.html)
+(Model used: Amazon Titan Text)
@@ -46 +149 @@ Amazon Bedrock includes models from a variety of providers. The following is a l
-  * [Design a prompt](./design-a-prompt.html)
+Here is the few-shot version of a sentiment classification prompt:
@@ -48 +150,0 @@ Amazon Bedrock includes models from a variety of providers. The following is a l
-  * [Prompt templates and examples for Amazon Bedrock text models](./prompt-templates-and-examples.html)
@@ -49,0 +152,3 @@ Amazon Bedrock includes models from a variety of providers. The following is a l
+    **User prompt:**
+    _Tell me the sentiment of the following headline and categorize it 
+    as either positive, negative or neutral. Here are some examples:
@@ -50,0 +156,2 @@ Amazon Bedrock includes models from a variety of providers. The following is a l
+    Research firm fends off allegations of impropriety over new technology.
+    Answer: Negative
@@ -51,0 +159,96 @@ Amazon Bedrock includes models from a variety of providers. The following is a l
+    Offshore windfarms continue to thrive as vocal minority in opposition dwindles.
+    Answer: Positive
+    
+    Manufacturing plant is the latest target in investigation by state officials.
+    Answer:_
+    
+
+(Source of prompt: AWS)
+    
+    
+    **Output:**
+    _Negative_
+
+(Model used: Amazon Titan Text)
+
+The following example uses Anthropic Claude models. When using Anthropic Claude models, it’s a good practice to use <example></example> tags to include demonstration examples. We also recommend using different delimiters such as `H:` and `A:` in the examples to avoid confusion with the delimiters `Human:` and `Assistant:` for the whole prompt. Notice that for the last few-shot example, the final `A:` is left off in favor of `Assistant:`, prompting Anthropic Claude to generate the answer instead.
+    
+    
+    **User prompt:**
+    
+    
+    _Human: Please classify the given email as "Personal" or "Commercial" related emails.
+    Here are some examples. <example>
+    H: Hi Tom, it's been long time since we met last time. We plan to have a party at my house this weekend. Will you be able to come over?
+    A: Personal
+    </example>
+    
+    <example>
+    H: Hi Tom, we have a special offer for you. For a limited time, our customers can save up to 35% of their total expense when you make reservations within two days. Book now and save money!
+    A: Commercial
+    </example>
+    
+    H: Hi Tom, Have you heard that we have launched all-new set of products. Order now, you will save $100 for the new products. Please check our website.
+    
+    Assistant:_
+    
+    **Output:**
+    _Commercial_
+    
+
+(Source of prompt: AWS, model used: Anthropic Claude)
+
+### Prompt template
+
+A prompt template specifies the formatting of the prompt with exchangeable content in it. Prompt templates are “recipes” for using LLMs for different use cases such as classification, summarization, question answering, and more. A prompt template may include instructions, few-shot examples, and specific context and questions appropriate for a given use case. The following example is a template that you can use to perform few-shot sentiment classification using Amazon Bedrock text models:
+    
+    
+    **Prompt template:**
+    _"""Tell me the sentiment of the following{{Text Type, e.g., “restaurant review”}} and categorize it 
+    as either {{Sentiment A}} or {{Sentiment B}}. 
+    Here are some examples:
+    
+    Text: {{Example Input 1}} 
+    Answer: {{Sentiment A}}
+    
+    Text: {{Example Input 2}}
+    Answer: {{Sentiment B}}
+    
+    Text: {{Input}}
+    Answer:"""_
+    
+
+Users can copy and paste this template, filling in their own text and few-shot examples to complete prompts when using LLMs on Amazon Bedrock. More templates are provided in this section.
+
+###### Note
+
+The double curly braces `{{ and }}` mark the places to put in data-specific information in the template, and should not be included in the prompt text.