利用长上下文窗口 - Amazon Nova

利用长上下文窗口

Amazon Nova Premier 支持的上下文长度为 100 万个令牌,相当于 100 万个文本令牌、500 个图像或 90 分钟的视频。Amazon Nova Premier 擅长理解长文档的代码和回答问题。随着上下文大小增加,其性能可能会略有下降,因此为了获得最佳结果,请考虑以下准则:

  • 将长格式数据放在开头:将长文档和输入放在提示的开头附近。它们应该放在您的查询、指令和示例之前。

  • 将指令放在末尾:将指令放在提示的末尾。当首先提供上下文并在末尾提供指令时,模型表现最佳。

  • 构建文档内容开始和结束标记:使用开始和结束标记(例如 [Document Start][Document End])来表示长文档的开始和结束。

    示例模板如下:

    // Provide your long inputs at the top of your prompt [Document Start] {{ Your document}} [Document End] // Then specify your query and instructions {{ User query}} {{ Instructions}}
  • 使用引文标记为响应提供依据:对于长文档任务,建议指示 Amazon Nova 模型在继续执行任务之前使用来自文档相关部分的引文来为其响应提供依据。这种方法有助于模型关注最相关的信息,避免被无关内容分散注意力。当您要求模型为其响应提供依据时,可以引用的部分应该是数字。例如,Passage %[1]%、Passage %[2]% 等等,或者仅 <C1>、<C2> 等等。有关如何在提示中包含引文的详细信息,请参阅构建自己的 RAG

    以下是一个示例提示:

    """ You are an AI financial assistant. Your task is to find patterns and insights from multi-year financial documents Passage %[1]% {{ Your document}} Passage %[2]% {{ Your document}} Passage %[3]% {{ Your document}} Passage %[4]% {{ Your document}} ## Task: Analyze Amazon's financial reports across multiple years to identify significant performance trends, segment growth patterns, and strategic shifts. ## Context information: - You have access to Amazon's annual financial reports (10-K) for multiple fiscal years in PDF format - These reports contain comprehensive financial data including income statements, balance sheets, cash flow statements, and management discussions - The analysis should focus on year-over-year comparisons to identify meaningful trends - Amazon operates multiple business segments including North America retail, International retail, Amazon Web Services (AWS), advertising, and subscription services Based on the provided Context, extract key financial metrics from each year's reports phrases from the documents, citing them using %[1]%, %[2]%, %[3]%, and for the corresponding passage that supports the response. ## Response Schema: %[1]% (Extracted Financial Metrics) %[2]% (Extracted Financial Metrics) %[3]% (Extracted Financial Metrics) ... """

    在基于用户的任务提取关键信息后,您可以使用提取的财务指标来回答相关问题,如下所示:

    """ ## Task Analyze Amazon's financial reports across multiple years to identify significant performance trends, segment growth patterns, and strategic shifts. {{ extracted financial metrics }} ## Model Instructions: - Organize data chronologically to identify meaningful trends - DO compare segment performance across the five-year period - DO identify significant strategic shifts or investments mentioned in management discussions - DO NOT make speculative predictions beyond what is supported by the data - ALWAYS note any changes in accounting practices or reporting methodologies that might affect year-over-year comparisons ## Response style and format requirements: - Respond in markdown - Structure the analysis with clear headings and subheadings - Present key financial metrics in tabular format showing all five years side-by-side - Include percentage changes year-over-year for all major metrics - Create a section dedicated to visualizing the most significant trends (with descriptions of what would be shown in charts) - Limit the executive summary to 250 words maximum - Format segment analysis as separate sections with consistent metrics across all segments - MUST include a Key Insights bullet-pointed list at the end of each major section