View a markdown version of this page

准备输入数据集 - Amazon Bedrock

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

准备输入数据集

文件格式

输入文件使用 JSONL 格式:每行一个 JSON 对象。每行代表一个要优化的提示模板及其相关字段。您为每个作业提供一个输入文件。

架构参考

在此提示数据集中,您还将选择评估方法来指导优化。有关选择评估方法的更多信息,请参见定义评估方法。

{ "version": "bedrock-2026-05-14", "templateId": "string", "promptTemplate": "string", "optimizationConfig": { "shortenPrompt": true }, "steeringCriteria": ["string"], "customEvaluationMetricLabel": "string", "customLLMJConfig": { "customLLMJPrompt": "string", "customLLMJModelId": "string" }, "evaluationMetricLambdaArn": "string", "evaluationSamples": [ { "inputVariables": [ {"variableName1": "string"} ], "referenceResponse": "string", "inputVariablesMultimodal": [ { "Arbitrary_Name": { "type": "string", "s3Uri": "string" } } ] } ] }

字段描述

#字段类型必需说明
1version字符串是固定值:"bedrock-2026-05-14".
2templateId字符串是此提示模板的唯一标识符。用于关联输入和输出。
3promptTemplate字符串是要优化的提示模板。使用变量占位符的{{variableName}}语法。您可以选择添加<advpo:optimize>和<advpo:exclude>标签来控制优化器重写哪些部分。有关更多信息,请参阅 选择性优化。
4optimizationConfigobject否用于优化设置的容器。
5optimizationConfig.shortenPrompt布尔值否启用缩短提示音。优化器可以缩短提示模板的长度,同时保持或提高评估分数。省略该字段或将其设置为会导致false缩短。有关更多信息,请参阅 缩短提示。
6steeringCriteria字符串列表否High-level 优化标准(例如,["PROFESSIONAL"])。
7customEvaluationMetricLabel字符串是(如果使用 customllmjConfig 或评估版MetricLambdaArn )评估指标的名称。
8customLLMJConfigobject否自定义 LLM-as-Judge 配置。
9customLLMJConfig.customLLMJPrompt字符串是(如果 customlmjConfig 存在)用于评估回复的评判提示。使用{{prompt}}、{{response}}、{{referenceResponse}}作为占位符。
10customLLMJConfig.customLLMJModelId字符串是(如果 customlmjConfig 存在)评判模型。支持的评判模型之一的基本模型 ID、跨区域推理配置文件 ID 或应用推理配置文件 ARN。有关列表,请参阅支持的区域、型号和配额。
11evaluationMetricLambdaArn字符串否用于自定义评估的 Lambda 函数的 ARN。
12evaluationSampleslist是包含输入变量和参考响应的评估样本。
13evaluationSamples[].inputVariables物体清单是(如果不使用inputVariablesMultimodal)Single-key 与{{variableName}}占位符匹配的对象。每个样本中至少有一个inputVariables或inputVariablesMultimodal必须存在。
14evaluationSamples[].referenceResponse字符串否可选的地面真相参考响应。为了获得最佳优化结果,建议使用。
15evaluationSamples[].inputVariablesMultimodal物体清单是(如果不使用inputVariables)多模态文件输入。每个样本中至少有一个inputVariables或inputVariablesMultimodal必须存在。
16evaluationSamples[].inputVariablesMultimodal[].Arbitrary_Nameobject是(如果存在多式联运)命名您的多模式变量。这是用户选择的任意名称。
17evaluationSamples[].inputVariablesMultimodal[].Arbitrary_Name.type字符串是(如果存在多式联运)“图片” 或 “PDF”。图片接受 JPG、JPEG、PNG、GIF 和 WebP。
18evaluationSamples[].inputVariablesMultimodal[].Arbitrary_Name.s3Uri字符串是(如果存在多式联运)多模式文件的 S3 URI 路径。

必填字段

  • version: 固定值 "bedrock-2026-05-14"

  • templateId: 此提示模板的唯一字符串标识符

  • promptTemplate: 优化的提示,{{variableName}}用于占位符

  • evaluationSamples: 由 1 到 100 个样本组成的数组

占位符变量

在提示模板中使用{{variableName}}语法(双大括号)作为占位符。中的键inputVariables必须与占位符名称完全匹配。每个密钥都必须位于列表中自己的对象中。每个模板最多 20 个文本占位符变量。不应使用占位符变量指向多模式文件的 S3 位置。占位符变量仅用于文本。如果您有多模式文件,它们将与文本提示一起通过有效载荷发送给模型。

评估样本

inputVariables以单键对象列表的形式提供:[{"variable1": "value1"}, {"variable2": "value2"}]. 不要在一个对象中放置多个密钥。(可选)提供referenceResponse基本事实答案以获得更好的优化结果。对于多模态输入,请使用带有Arbitrary_Name对象的inputVariablesMultimodal数组。多模式文件与文本提示一起通过有效载荷发送到模型。支持的类型有 IMAGE(JPG、JPEG、PNG、GIF、WebP)和 PDF,每个样本最多 100 个多模态文件。多模态输入(图像和 PDF)与提示一起通过有效载荷发送到模型,但不应在双大括号变量中引用。{{placeholder}}

评估策略

为每个模板选择一种评估方法,或者省略系统默认值的所有可选评估字段(包括准确性、答案完整性和主观写作风格评估)。我们建议您定义自己的评估方法以获得最佳结果。在同一个作业中,你可以跨模板使用不同的方法。有关详细信息,请参阅定义评估方法。

限制

有关配额的完整列表,请参阅支持的区域、型号和配额。准备输入文件的主要限制:

  • 每个作业最多 10 个模板

  • 每个模板最多 100 个评估样本

  • 每个作业最多 5 个模型

  • 每个模板最多 20 个文本变量

  • 每个样本最多 100 个多模式文件

  • 每个模板最多 5 个转向标准

常见错误

  • 同时提供 AN steeringCriteria DcustomLLMJConfig/evaluationMetricLambdaArn= ValidationException

  • 使用 LLMJ customEvaluationMetricLabel 时丢失或 = evaluationMetricLambdaArn ValidationException

  • 一个inputVariables对象中有多个按键 = 静默失败

  • 使用像这样的单大括号,{variable}而不是像这样的双大括号 {{variable}}

  • inputVariables密钥必须与中的{{variableName}}占位符匹配 promptTemplate

  • 正在寻找控制台切换开关或 API 参数来缩短提示音。 optimizationConfig仅在此输入文件中按模板设置。

  • 使用不在支持列表中的判断模型 = ValidationException。有关列表,请参阅支持的区域、型号和配额。

使用多模态输入

支持的文件类型:图像(JPG、JPEG、PNG、GIF、WebP)和 PDF。

提示

对于 GIF 和 WebP 文件,支持这些格式的模型通常只使用动画多帧文件的第一帧。要使用动画文件中的多个帧,请手动拆分帧并将其作为单独的多模式文件包含在评估样本中。

如何包含:使用包含type和的Arbitrary_Name对象的inputVariablesMultimodal数组s3Uri。

限制:每个评估样本最多 100 个多模式文件。您可以混合和匹配,这样每条评估样本记录最多可有 20 个文本变量和 100 个多模态文件。

混合文本和多模态:可以在同一个样本inputVariablesMultimodal中同时使用两者inputVariables(文本)。双大括号{{placeholders}}仅用于纯文本。您不能通过占位符引用多模式文件。不应使用占位符变量指向多模式文件的 S3 位置。如果您有多模式文件,它们将与文本提示一起通过有效载荷发送给模型。

数据集小贴士

  • 混合简单和困难的例子 ——与你在现实世界中看到的相匹配。 All-easy 数据不会推动改进;全硬数据没有什么可学习的。

  • 涵盖你关心的案例 ——系统的概括超出了它所看到的范围,但是具有代表性的数据分布可以帮助它更好地推广到现实世界的输入。

  • 提示优化后,使用保留的数据集对优化器未见过的数据进行测试,确认收益是真实的,而不仅仅是记住的。

示例

示例 1:单个模板、多个变量、单个评估样本、指导标准

{ "version": "bedrock-2026-05-14", "templateId": "customer-support-v1", "promptTemplate": "You are a customer support agent.\n\nProduct info:\n{{productInfo}}\n\nQuestion:\n{{customerQuestion}}\n\nProvide a helpful response.", "steeringCriteria": ["PROFESSIONAL"], "evaluationSamples": [{ "inputVariables": [{"productInfo": "Product: Sony WH-1000XM5. Battery: 30 hours."}, {"customerQuestion": "How long does the battery last?"}], "referenceResponse": "The battery lasts up to 30 hours on a single charge." }] }

示例 2:单个模板、多个变量、多个评估样本、指导标准

{ "version": "bedrock-2026-05-14", "promptTemplate": "You are a customer support agent for an electronics store.\n\nGiven the following product information:\n{{productInfo}}\n\nAnswer the customer's question:\n{{customerQuestion}}\n\nProvide a helpful, accurate, and concise response.", "templateId": "template-support-1", "steeringCriteria": ["PROFESSIONAL", "CONCISE"], "evaluationSamples": [ {"inputVariables": [{"productInfo": "Product: Sony WH-1000XM5 Headphones. Price: $349.99. Battery Life: 30 hours. Noise Cancellation: Yes, adaptive. Connectivity: Bluetooth 5.2, 3.5mm jack. Weight: 250g."}, {"customerQuestion": "How long does the battery last and can I use them wired?"}], "referenceResponse": "The Sony WH-1000XM5 headphones have a battery life of up to 30 hours on a single charge. And yes, they do come with a 3.5mm jack, so you can use them in wired mode as well."}, {"inputVariables": [{"productInfo": "Product: Sony WH-1000XM5 Headphones. Price: $349.99. Battery Life: 30 hours. Noise Cancellation: Yes, adaptive. Connectivity: Bluetooth 5.2, 3.5mm jack. Weight: 250g."}, {"customerQuestion": "Do these have noise cancellation?"}], "referenceResponse": "Yes, the Sony WH-1000XM5 headphones feature adaptive noise cancellation, which automatically adjusts the level of noise cancellation based on your environment."}, {"inputVariables": [{"productInfo": "Product: Apple MacBook Air M3. Price: $1,099. RAM: 8GB. Storage: 256GB SSD. Display: 13.6-inch Liquid Retina. Battery Life: Up to 18 hours."}, {"customerQuestion": "Is 8GB of RAM enough for video editing?"}], "referenceResponse": "The MacBook Air M3 comes with 8GB of unified memory. It can handle light video editing but you may want more RAM for heavy work."} ] }

示例 3:两个模板,每个提示一个变量,多个样本,指导标准

此示例显示了 JSONL 文件中的两行(一个作业中有两个提示模板)。

{"version": "bedrock-2026-05-14", "promptTemplate": "You are a helpful assistant. Answer the following: {{question}}", "templateId": "template-qa-1", "steeringCriteria": ["ACCURATE"], "evaluationSamples": [{"inputVariables": [{"question": "What is 2+2?"}], "referenceResponse": "4"}, {"inputVariables": [{"question": "What is the largest planet in our solar system?"}], "referenceResponse": "Jupiter is the largest planet in our solar system."}]} {"version": "bedrock-2026-05-14", "promptTemplate": "Translate the following to French: {{text}}", "templateId": "template-translate-1", "steeringCriteria": ["PRECISE"], "evaluationSamples": [{"inputVariables": [{"text": "Hello, how are you?"}], "referenceResponse": "Bonjour, comment allez-vous?"}, {"inputVariables": [{"text": "Thank you very much."}], "referenceResponse": "Merci beaucoup."}]}

示例 4:单个模板、多个变量、多个样本, LLM-as-a-judge

{ "version": "bedrock-2026-05-14", "promptTemplate": "You are a customer support agent for an electronics store.\n\nGiven the following product information:\n{{productInfo}}\n\nAnswer the customer's question:\n{{customerQuestion}}\n\nProvide a helpful, accurate, and concise response.", "templateId": "template-llmj-1", "customEvaluationMetricLabel": "responseaccuracy", "evaluationSamples": [ {"inputVariables": [{"productInfo": "Product: Sony WH-1000XM5 Headphones. Price: $349.99. Battery Life: 30 hours. Noise Cancellation: Yes, adaptive."}, {"customerQuestion": "How long does the battery last?"}], "referenceResponse": "The Sony WH-1000XM5 headphones have a battery life of up to 30 hours on a single charge."}, {"inputVariables": [{"productInfo": "Product: Apple MacBook Air M3. Price: $1,099. RAM: 8GB. Storage: 256GB SSD."}, {"customerQuestion": "Is 8GB of RAM enough for video editing?"}], "referenceResponse": "The MacBook Air M3 comes with 8GB of unified memory. It can handle light video editing but you may want more RAM for heavy work."} ], "customLLMJConfig": { "customLLMJPrompt": "Evaluate how accurate the response is to the customer question. Consider whether the response uses only the provided product information and does not hallucinate details. Here is the information you are supposed to evaluate: \n\nPrompt: {{prompt}}\nResponse: {{response}}\n\n \n\n ground truth answer: {{referenceResponse}}. Grading scale: Rate the response on a scale of 1-5. 1 means the answer is full of hallucinations and does not answer the question. 5 means the answer does not hallucinate at all and perfectly answers the question with no extra information. Interpolate the rest of the grading scale", "customLLMJModelId": "anthropic.claude-sonnet-4-5-20250929-v1:0" } }

示例 5:单个模板、多个变量、多个样本、无评估方法(系统默认)

由于未提供评估或指导,因此提示优化器将使用集准确性、完整性和写作风格于一体的内置泛型 LLM-as-a-judge 。

{ "version": "bedrock-2026-05-14", "promptTemplate": "You are a customer support agent for an electronics store.\n\nGiven the following product information:\n{{productInfo}}\n\nAnswer the customer's question:\n{{customerQuestion}}\n\nProvide a helpful, accurate, and concise response.", "templateId": "template-default-llmj-1", "evaluationSamples": [ {"inputVariables": [{"productInfo": "Product: Sony WH-1000XM5 Headphones. Price: $349.99. Battery Life: 30 hours. Noise Cancellation: Yes, adaptive."}, {"customerQuestion": "How long does the battery last?"}], "referenceResponse": "The Sony WH-1000XM5 headphones have a battery life of up to 30 hours on a single charge."}, {"inputVariables": [{"productInfo": "Product: Apple MacBook Air M3. Price: $1,099. RAM: 8GB. Storage: 256GB SSD."}, {"customerQuestion": "Is 8GB of RAM enough for video editing?"}], "referenceResponse": "The MacBook Air M3 comes with 8GB of unified memory. It can handle light video editing but you may want more RAM for heavy work."} ] }

示例 6:单个模板、单个变量、多个样本、Lambda 评估器

{ "version": "bedrock-2026-05-14", "promptTemplate": "You are a helpful assistant. Answer the following: {{question}}", "templateId": "template-byo-1", "customEvaluationMetricLabel": "accuracygraderlambda", "evaluationSamples": [ {"inputVariables": [{"question": "What is the capital of France?"}], "referenceResponse": "The capital of France is Paris."}, {"inputVariables": [{"question": "What is 2+2?"}], "referenceResponse": "4"} ], "evaluationMetricLambdaArn": "arn:aws:lambda:us-west-2:<YOUR_ACCOUNT_ID>:function:<YOUR_EVAL_FUNCTION>" }

示例 7:单一模板,无文本变量,仅限多式联运, LLM-as-judge

即使没有,这也是可以接受的输入,{{variables}}因为其中包含了多模态输入。

{ "version": "bedrock-2026-05-14", "templateId": "multimodal_only_01", "promptTemplate": "Does this image contain a dog? Respond yes or no", "customEvaluationMetricLabel": "binarydogjudge", "customLLMJConfig": { "customLLMJPrompt": "Determine if the model response matches the ground truth. Grading scale: 0 if the response does not match the ground truth, 1 if the response matches the ground truth. Here is the input: \n\n input: {{prompt}} \n\n model response: {{response}} \n\n ground truth: {{referenceResponse}}.", "customLLMJModelId": "anthropic.claude-sonnet-4-5-20250929-v1:0" }, "evaluationSamples": [ {"inputVariablesMultimodal": [{"dogimage": {"type": "IMAGE", "s3Uri": "s3://my-bucket/images/dog-photo.jpeg"}}], "referenceResponse": "Yes"}, {"inputVariablesMultimodal": [{"catimage": {"type": "IMAGE", "s3Uri": "s3://my-bucket/images/cat-photo.png"}}], "referenceResponse": "No"} ] }

示例 8:单个模板、多个变量 LLM-as-judge、混合文本和多模态

{ "version": "bedrock-2026-05-14", "templateId": "multimodal_with_text_01", "promptTemplate": "Given the context in attached documents and the user question, provide a short answer. User question: {{question}}", "customEvaluationMetricLabel": "documentinfograder", "customLLMJConfig": { "customLLMJPrompt": "Evaluate whether the response correctly answers the question using information from the provided document. Score 1-5 where 5 means fully correct and grounded in the source material, and 1 means the answer was completely hallucinated and inaccurate. Here's the information: \n Prompt: {{prompt}}, Model response: {{response}}, ground truth: {{referenceResponse}}", "customLLMJModelId": "anthropic.claude-sonnet-4-5-20250929-v1:0" }, "evaluationSamples": [ { "inputVariables": [{"question": "What is the total revenue for Q1?"}], "inputVariablesMultimodal": [ {"Q1report": {"type": "PDF", "s3Uri": "s3://my-bucket/docs/quarterly-report.pdf"}}, {"revenuechart": {"type": "IMAGE", "s3Uri": "s3://my-bucket/images/revenue-chart.png"}} ], "referenceResponse": "The total revenue for Q1 was $4.2M." } ] }

示例 9:单一模板,使用 advpo: optimation 进行选择性优化,指导标准

此示例使用<advpo:optimize>标签仅优化投诉回复指令。身份声明和策略约束将保留。

{ "version": "bedrock-2026-05-14", "templateId": "selective-optimize-v1", "promptTemplate": "You are a customer service agent for Acme Corp. Always be polite and professional.\n\n<advpo:optimize>When responding to a complaint, acknowledge the customer's frustration, summarize the issue, and propose exactly one concrete resolution. Use bullet points for clarity.</advpo:optimize>\n\nNever disclose internal pricing or employee information.", "steeringCriteria": ["PROFESSIONAL", "CONCISE"], "evaluationSamples": [ {"inputVariables": [{"customerComplaint": "I was charged twice for my order #12345"}], "referenceResponse": "I understand your frustration about being charged twice for order #12345. Let me look into this for you.\n\n- Issue: Duplicate charge on your account\n- Resolution: I will process a refund for the duplicate charge within 3-5 business days."}, {"inputVariables": [{"customerComplaint": "My package arrived damaged"}], "referenceResponse": "I'm sorry to hear your package arrived damaged.\n\n- Issue: Damaged item received\n- Resolution: I will send a replacement at no extra cost, arriving within 2 business days."} ] }

示例 10:单个模板,使用 advpo: exclude 进行选择性优化, LLM-as-a-judge

此示例使用<advpo:exclude>标签冻结身份和策略部分。其他一切都经过优化。

{ "version": "bedrock-2026-05-14", "templateId": "selective-exclude-v1", "promptTemplate": "<advpo:exclude>You are a technical support agent for CloudWidget. Always verify the customer's account before making changes.</advpo:exclude>\n\nWhen a customer reports an issue, ask clarifying questions about their environment, check the knowledge base for known solutions, and provide step-by-step instructions.\n\n<advpo:exclude>Never share internal ticket IDs or system architecture details with customers.</advpo:exclude>", "customEvaluationMetricLabel": "supportquality", "customLLMJConfig": { "customLLMJPrompt": "Evaluate the quality of the technical support response. Consider whether it asks relevant clarifying questions, provides clear step-by-step instructions, and maintains a helpful tone. Score 1-5 where 5 means excellent support interaction and 1 means unhelpful or unclear. Here is the information: \n\nPrompt: {{prompt}}\nResponse: {{response}}\nGround truth: {{referenceResponse}}", "customLLMJModelId": "anthropic.claude-sonnet-4-5-20250929-v1:0" }, "evaluationSamples": [ {"inputVariables": [{"customerIssue": "My dashboard is loading slowly since yesterday"}], "referenceResponse": "I'd like to help you resolve the slow dashboard loading. A few questions to narrow things down:\n\n1. Which browser are you using?\n2. Have you tried clearing your browser cache?\n3. Is the slowness on all pages or just the dashboard?\n\nIn the meantime, try these steps:\n1. Clear your browser cache and cookies\n2. Disable any browser extensions\n3. Try accessing the dashboard in an incognito window"} ] }