AWS Amazon Nova
Amazon Nova
The Amazon Nova model family consists of two broad model categories, understanding models (Amazon Nova Micro, Lite, Pro, and Premier) and content generation models (Amazon Nova Canvas and Reel).
Review the following best practices for using Amazon Nova.
Creating precise prompts
Crafting specific user queries is crucial in prompt engineering.
Well-crafted queries direct Amazon Nova text understanding models to generate accurate and pertinent responses.
To craft such queries, it is essential to start by providing contextual information in the query.
The context provided helps situate the model better by aligning to clear target-user scenarios, thereby enhancing the relevance and coherence of the output.
Provide contextual, specific information
Amazon Nova models work best if the instructions are clear, well structured, short, and specific.
This prompt template guidance applies to both the user prompt and the system prompt.
Specify the output format and style
If you want Amazon Nova to generate responses that are tailored to your specific needs, you can specify the format and style of the output.
For example, if you want to generate responses only in JSON or constrain the response length to a maximum number of words, bullet points, or paragraphs.
This enables Amazon Nova to better understand your requirements and produce output that is more relevant and easier to parse.
Provide clear prompt sections
Beyond the initial context, a structured query format plays a significant role in optimizing interactions with the language model.
Separating distinct parts of the input with delimiters ensures clarity and enhances Amazon Nova models' ability to understand the query's structure.
Another effective way is to use numbered lists or bullet points, which can help to break down the task into manageable steps and provide a clear outline of the actions that need to be taken.
This structured approach aids in reducing ambiguity and improving the accuracy of the responses generated.
Using the system role
The System Role is where you provide instructions to the model that define how it will respond to end users of your application. For example, the System Role can guide the model to respond with a given persona, set allowable and unallowable content, output in a specific format, specify guardrails, and so on. Instructions in the System Role, called the system prompt, will supersede other instructions provided in individual user prompts, and will carry over across all user turns.
Advantages of system role prompting include the following:
- Personified tone and response style – The system role allows you to shape the model's response style to best suit your target audience. For example, you can instruct it to respond in a concise, quantitative tone like an accountant or a more approachable, creative style like a conversationalist.
- Enhanced accuracy – Clearly defining the model's role and scope of expertise through the system prompt helps it stay focused on the specific task requirements, reducing the risk of irrelevant or tangential responses. This is specifically useful in cases of highly complex domains like legal and finance.
- Supersedes other instructions – The system prompt, as compared to the user prompt, holds higher importance than other instructions provided in individual user prompts. These instructions also carry over across all user turns.
Chain-of-thought
You can improve the problem solving skills of Amazon Nova by breaking down complex issues into simpler, more manageable tasks or intermediate thoughts. Amazon Nova models work better in reasoning if they are given time to think through the problem and then arrive at the answer. This process of guiding the model to think step-by-step and make attempts at reasoning before arriving at an answer is called chain-of-thought (CoT) prompting.
The easiest way to prompt Amazon Nova models to think is by adding instructions like think step-by-step or stronger wording such as DO NOT provide answer without thinking step by step at the end of your query.
Chain-of-thought is recommended for several reasons:
- Improves accuracy – Giving the model a chance to first do the thinking before responding helps the model land at a better answer, as compared to asking model directly to think.
- Improves the debugging process – Sometimes chain-of-thought reasoning helps debug where and why model made some errors. This feedback is essential to understand how to iterate on prompt to improve the flaws in model’s reasoning.
Provide examples
By including a few examples of your task within the prompt, you can build a structured template for Amazon Nova to follow. This reduces ambiguity and enhances the accuracy and quality of the output. The technique of providing clear examples to make the model's responses more aligned with the desired outcome is called few-shot prompting.
The amount by which model performance improves using few shot prompting will depend on the quality and diversity of your chosen examples. The following items demonstrate the characteristics of good shots in the prompt:
- Select diverse examples: The examples chosen should represent the distribution of your expected input/output in terms of diversity (ranging from common use cases to edge cases) to adequately cover relevant use cases. It is important to avoid any biases in your examples, as bias in the inputs can cause outputs to be biased as well.
- Match complexity levels: The complexity of the examples provided should align with the target task or scenario. It is important to make sure the complexity grade is mapped between expected the input and the chosen example in the prompt.
- Ensure relevance: The examples selected should be directly relevant to the problem or objective at hand. This ensures consistency and uniformity in responses.
Provide supporting text
You should provide the model with trusted information relevant to the input query. This information, along with the input query, is generally part of retrieval augmented generation (RAG). In this process, you add relevant contextual information to the user prompt so that the model can use trustworthy content to generate a relevant and accurate response. When you instruct Amazon Nova to answer using reference text from a trusted source, you guide it to compose a response based on the provided material. This approach helps confirm that the response contains accurate and relevant information, improving the reliability and credibility of the generated content.
Bring focus to sections of the prompt
Amazon Nova models can pay close attention to specific parts in the prompt by formatting instructions in sections and then referring to those specific sections. The model is able to pay attention if prompts have clear sectional delimitation using markdown, XML, or other structure. For example, you can define the name of the section, use ##Section Name##, then refer to that section in your prompt with ##Section Name##.
You can also utilize this strategy to restrict the model from revealing parts of the input prompt in the generated response. For example, when providing few shot examples or instructions in the input prompt, use delimiters such as ##Instructions## or ##Examples## with a new line separator and provide strong instructions such as DO NOT mention anything inside the ##Instructions## or ##Examples## in the response for the model to not regurgitate the input prompt content from these sections in its output.
Require structured output
To ensure consistent and structured output formats, you can use structured outputs, including formats like XML, JSON, or Markdown. This approach allows downstream use cases to more effectively consume and process the outputs generated by the model. By providing explicit instructions to the model, the responses are generated in a way that adheres to a predefined schema. We recommend that you provide an output schema for the model to follow.
For example, if the downstream parser expects specific naming conventions for keys in a JSON object, you should specify this in an Output Schema field of the query. Additionally, if you prefer responses to be in JSON format without any preamble text, instruct the model accordingly. That is, explicitly state Please generate only the JSON output. DO NOT provide any preamble..
Utilize long context windows
Amazon Nova Premier has a supported context length of 1 million tokens, which translates to 1M tokens of text, 500 images, or 90 minutes of video. Amazon Nova Premier excels at code understanding and question answering on long documents. Its performance can decline slightly as the context size increases, so for best results consider the following guidelines:
- Put long-form data at the beginning: Place your long documents and inputs near the beginning of your prompt. They should be placed before your query, instructions, and examples.
- Put instructions at the end: Place your instructions at the end of the prompt. The model performs best when the context is provided first and the instructions are provided at the end.
-
Structure document content start and end markers: Use start and end markers, such as
[Document Start]and[Document End], to denote the start and end of a long document.