评估配方示例
Amazon Nova 提供了四种类型的评估配方,这些配方可在 SageMaker HyperPod 配方 GitHub 存储库中找到。
这些配方让您能够通过一套全面的纯文本基准测试来评估 Amazon Nova 模型的基本功能。它们以 xxx_general_text_benchmark_eval.yaml 格式提供。
这些配方让您能够使用自己的数据集进行基准测试,并使用不同类型的指标将模型输出与参考答案进行对比。它们以 xxx_bring_your_own_dataset_eval.yaml 格式提供。
以下是自带数据集的要求:
-
文件格式要求
-
必须有一个包含评估示例的
gen_qa.jsonl文件。 -
您的数据集必须上传到 SageMaker 训练作业可以访问的 S3 位置。
-
该文件必须遵循常规问答数据集所需的架构格式。
-
-
架构格式要求:JSONL 文件中的每一行都必须是包含以下字段的 JSON 对象:
-
query:(必填)包含需要答案的问题或说明的字符串 -
response:(必填)包含预期模型输出的字符串 -
system:(可选)包含系统提示的字符串,用于在处理查询之前设置 AI 模型的行为、角色或个性 -
metadata:(可选)字符串类型,与本条记录关联的元数据,用于标签分类。
-
以下是自带数据集示例条目
{ "system":"You are a english major with top marks in class who likes to give minimal word responses: ", "query":"What is the symbol that ends the sentence as a question", "response":"?" } { "system":"You are a pattern analysis specialist that provides succinct answers: ", "query":"What is the next number in this series? 1, 2, 4, 8, 16, ?", "response":"32" } { "system":"You have great attention to detail that follows instructions accurately: ", "query":"Repeat only the last two words of the following: I ate a hamburger today and it was kind of dry", "response":"of dry" }
要使用您的自定义数据集,请按以下必填字段修改您的评估配方,且不要更改其中任何内容:
evaluation: task: gen_qa strategy: gen_qa metric: all
适用以下限制:
-
每次评估只支持一个 JSONL 文件。
-
该文件必须严格遵循定义的架构。
-
上下文长度限制:对于数据集中的每个样本,上下文长度(包括系统 + 查询提示)应小于 3.5k。
Amazon Nova LLM-as-a-Judge 是一项模型评测特征,让客户可以使用自定义数据集,将一个模型的响应质量与基准模型的响应质量进行比较。它接受包含提示、基准响应和挑战响应的数据集,然后使用 Nova Judge 模型基于 Bradley-Terry 概率
配方以 xxx_llm_judge_eval.yaml 格式提供。
以下是 LLM-as-a-Judge 的要求:
-
文件格式要求
-
有一个包含评估示例的
llm_judge.jsonl文件。文件名称必须为llm_judge.jsonl。 -
您的数据集必须上传到 SageMaker AI SageMaker HyperPod RIG 可以访问的 S3 位置。
-
该文件必须遵循
llm_judge.jsonl数据集所需的架构格式。 -
输入数据集应确保所有记录的上下文长度小于 12k。
-
-
架构格式要求:JSONL 文件中的每一行都必须是包含以下字段的 JSON 对象:
-
prompt:(必填)包含生成响应提示的字符串。 -
response_A:包含基准响应的字符串。 -
response_B:包含与基准响应进行比较的替代响应的字符串。
-
这是一个 LLM-as-a-Judge 示例条目
{ "prompt": "What is the most effective way to combat climate change?", "response_A": "The most effective way to combat climate change is through a combination of transitioning to renewable energy sources and implementing strict carbon pricing policies. This creates economic incentives for businesses to reduce emissions while promoting clean energy adoption.", "response_B": "We should focus on renewable energy. Solar and wind power are good. People should drive electric cars. Companies need to pollute less." } { "prompt": "Explain how a computer's CPU works", "response_A": "CPU is like brain of computer. It does math and makes computer work fast. Has lots of tiny parts inside.", "response_B": "A CPU (Central Processing Unit) functions through a fetch-execute cycle, where instructions are retrieved from memory, decoded, and executed through its arithmetic logic unit (ALU). It coordinates with cache memory and registers to process data efficiently using binary operations." } { "prompt": "How does photosynthesis work?", "response_A": "Plants do photosynthesis to make food. They use sunlight and water. It happens in leaves.", "response_B": "Photosynthesis is a complex biochemical process where plants convert light energy into chemical energy. They utilize chlorophyll to absorb sunlight, combining CO2 and water to produce glucose and oxygen through a series of chemical reactions in chloroplasts." }
要使用您的自定义数据集,请按以下必填字段修改您的评估配方,且不要更改其中任何内容:
evaluation: task: llm_judge strategy: judge metric: all
适用以下限制:
-
每次评估只支持一个 JSONL 文件。
-
该文件必须严格遵循定义的架构。
-
Amazon Nova Judge 模型对于所有模型系列规格(即 Lite、Micro 和 Pro)都是一样的。
-
目前不支持自定义评估模型。
-
上下文长度限制:对于数据集中的每个样本,上下文长度(包括系统 + 查询提示)应小于 7k。
Nova LLM Judge 多模态(图像)版(简称 Nova MM_LLM Judge)是一项模型评测功能,支持使用自定义数据集,将目标模型的响应质量与基准模型的响应进行对比评估。该功能接受包含提示、基准响应和挑战响应的数据集,以及 Base64 编码字符串图像,然后使用 Nova Judge 模型基于 Bradley-Terryxxx_mm_llm_judge _eval.yaml。
Nova LLM 数据集要求
文件格式:
-
包含评估示例的单个
mm_llm_judge.jsonl文件。文件名称必须严格为llm_judge.jsonl。 -
您必须将数据集上传到 SageMaker 训练作业可以访问的 S3 位置。
-
该文件必须遵循
mm_llm_judge数据集所需的架构格式。 -
输入数据集应确保:排除 image 属性后,所有记录的上下文长度均小于 12k。
架构格式:.jsonl 文件中的每一行都必须是包含以下字段的 JSON 对象。
-
必填字段。
prompt:包含生成响应提示的字符串。images:对象数组,每个对象包含 data 属性(值为 Base64 编码的图像字符串)。response_A:包含基准响应的字符串。response_B:包含与基准响应进行比较的替代响应的字符串。
示例条目
为便于阅读,以下示例包含换行与缩进,但在实际数据集中,每条记录必须单独占一行。
{ "prompt": "what is in the image?", "images": [ { "data": "data:image/jpeg;Base64,/9j/2wBDAAQDAwQDAwQEAwQFBAQFBgo..." } ], "response_A": "a dog.", "response_B": "a cat.", } { "prompt": "how many animals in echo of the images?", "images": [ { "data": "data:image/jpeg;Base64,/9j/2wBDAAQDAwQDAwQEAwQFBAQFBgo..." }, { "data": "data:image/jpeg;Base64,/DKEafe3gihn..." } ], "response_A": "The first image contains one cat and the second image contains one dog", "response_B": "The first image has one aminal and the second has one animal", }
要使用您的自定义数据集,请按以下必填字段修改您的评估配方,且不要更改其中任何内容:
evaluation: task: mm_llm_judge strategy: judge metric: all
限制
-
每次评估只支持一个
.jsonl文件。 -
该文件必须严格遵循定义的架构。
-
Nova MM Judge 模型仅支持图像参考。
-
Nova MM Judge 模型对于 Amazon Nova Lite 规格是一样的。
-
目前不支持自定义评估模型。
-
不支持 Amazon S3 图像 URI。
-
输入数据集应确保:排除 image 属性后,所有记录的上下文长度均小于 12k。
Rubric Judge 是基于 Nova 2.0 Lite 构建的增强版 LLM-as-a-judge 评估模型。与仅提供偏好判定(A 优于 B、B 优于 A 或平局)的原始评判模型
关键功能:
-
动态评估维度生成:根据输入提示自动生成相关的评估维度
-
加权评分:为各评估维度分配重要性权重,体现其相对优先级
-
细粒度评测:对每个维度以二分类(是/否)或量表(1–5 分)形式给出详细评分
-
质量指标:计算连续型质量得分(0–1 区间),量化不同响应之间的差异程度
模型生成的评估维度示例:
price_validation: description: "The response includes validation to ensure price is a positive value." type: "scale" weight: 0.3
模型会依据所有生成的评估维度对两组响应进行评估,再利用各维度得分得出最终偏好判定。
配方配置
Rubric Judge 配方
在配方中通过设置 task: rubric_llm_judge 来启用 Rubric Judge:
run: name: nova-eval-job-name # [MODIFIABLE] Unique identifier for your evaluation job model_type: amazon.nova-2-lite-v1:0:256k # [FIXED] Rubric Judge model type model_name_or_path: "nova-lite-2/prod" # [FIXED] Path to model checkpoint or identifier replicas: 1 # [MODIFIABLE] Number of replicas for SageMaker Training job data_s3_path: "" # [FIXED] Leave empty for SageMaker Training job output_s3_path: "" # [FIXED] Leave empty for SageMaker Training job evaluation: task: rubric_llm_judge # [FIXED] Evaluation task - enables Rubric Judge strategy: judge # [FIXED] Evaluation strategy metric: all # [FIXED] Metric calculation method inference: max_new_tokens: 12000 # [MODIFIABLE] Maximum tokens to generate top_k: -1 # [MODIFIABLE] Top-k sampling parameter top_p: 1.0 # [MODIFIABLE] Nucleus sampling parameter temperature: 0 # [MODIFIABLE] Sampling temperature (0 = deterministic)
原始 LLM-as-a-judge 配方(供比较)
原始评判模型使用 task: llm_judge:
run: name: eval-job-name # [MODIFIABLE] Unique identifier for your evaluation job model_type: amazon.nova-micro-v1:0:128k # [FIXED] Model type model_name_or_path: "nova-micro/prod" # [FIXED] Path to model checkpoint or identifier replicas: 1 # [MODIFIABLE] Number of replicas for SageMaker Training job data_s3_path: "" # [FIXED] Leave empty for SageMaker Training job output_s3_path: "" # [FIXED] Leave empty for SageMaker Training job evaluation: task: llm_judge # [FIXED] Original judge task strategy: judge # [FIXED] Evaluation strategy metric: all # [FIXED] Metric calculation method inference: max_new_tokens: 12000 # [MODIFIABLE] Maximum tokens to generate top_k: -1 # [MODIFIABLE] Top-k sampling parameter top_p: 1.0 # [MODIFIABLE] Nucleus sampling parameter temperature: 0 # [MODIFIABLE] Sampling temperature (0 = deterministic)
输入数据集格式
输入数据集格式与原始评判模型
必填字段:
-
prompt:字符串类型,包含输入提示与指令 -
response_A:字符串类型,基准模型的输出 -
response_B:字符串类型,自定义模型的输出
示例数据集(JSONL 格式):
{"prompt": "What is the most effective way to combat climate change?", "response_A": "The most effective way to combat climate change is through a combination of transitioning to renewable energy sources and implementing strict carbon pricing policies. This creates economic incentives for businesses to reduce emissions while promoting clean energy adoption.", "response_B": "We should focus on renewable energy. Solar and wind power are good. People should drive electric cars. Companies need to pollute less."} {"prompt": "Explain how a computer's CPU works", "response_A": "CPU is like brain of computer. It does math and makes computer work fast. Has lots of tiny parts inside.", "response_B": "A CPU (Central Processing Unit) functions through a fetch-execute cycle, where instructions are retrieved from memory, decoded, and executed through its arithmetic logic unit (ALU). It coordinates with cache memory and registers to process data efficiently using binary operations."} {"prompt": "How does photosynthesis work?", "response_A": "Plants do photosynthesis to make food. They use sunlight and water. It happens in leaves.", "response_B": "Photosynthesis is a complex biochemical process where plants convert light energy into chemical energy. They utilize chlorophyll to absorb sunlight, combining CO2 and water to produce glucose and oxygen through a series of chemical reactions in chloroplasts."}
格式要求:
-
每条记录必须是单行 JSON 对象
-
各行记录以换行符分隔
-
严格遵循示例中所示的字段命名规则
评估输出
输出结构
与原始评判模型相比,Rubric Judge 可生成更完善的评估指标:
{ "config_general": { "lighteval_sha": "string", "num_fewshot_seeds": "int", "max_samples": "int | null", "job_id": "int", "start_time": "float", "end_time": "float", "total_evaluation_time_secondes": "string", "model_name": "string", "model_sha": "string", "model_dtype": "string | null", "model_size": "string" }, "results": { "custom|rubric_llm_judge_judge|0": { "a_scores": "float", "a_scores_stderr": "float", "b_scores": "float", "b_scores_stderr": "float", "ties": "float", "ties_stderr": "float", "inference_error": "float", "inference_error_stderr": "float", "score": "float", "score_stderr": "float", "weighted_score_A": "float", "weighted_score_A_stderr": "float", "weighted_score_B": "float", "weighted_score_B_stderr": "float", "score_margin": "float", "score_margin_stderr": "float", "winrate": "float", "lower_rate": "float", "upper_rate": "float" } }, "versions": { "custom|rubric_llm_judge_judge|0": "int" } }
Rubric Judge 新增指标
以下六项指标为 Rubric Judge 独有,可提供细粒度的质量评测:
指标 |
说明 |
|---|---|
weighted_score_A |
基于模型生成的所有评估维度,对 response_A 计算的归一化加权平均质量得分。得分按维度重要性加权,并归一化到 0–1 区间(分值越高,质量越好) |
weighted_score_A_stderr |
weighted_score_A 的均值标准误,用于表示统计不确定性 |
weighted_score_B |
基于模型生成的所有评估维度,对 response_B 计算的归一化加权平均质量得分。得分按维度重要性加权,并归一化到 0–1 区间(分值越高,质量越好) |
weighted_score_B_stderr |
weighted_score_B 的均值标准误,用于表示统计不确定性 |
score_margin |
加权分数差值(计算公式:weighted_score_A - weighted_score_B)。范围:-1.0 至 1.0。正值表示 response_A 更优;负值表示 response_B 更优;接近 0 表示两者质量相近 |
score_margin_stderr |
score_margin 的均值标准误,用于表示质量差异测量结果的不确定性 |
加权分数指标说明
用途:加权分数提供连续型质量评估,作为二分类偏好判定的补充,便于更深入地分析模型性能。
与原始评判模型的主要区别:
-
原始评判模型:仅输出离散偏好结果(A 优于 B、B 优于 A、A 与 B 持平)
-
Rubric Judge:基于自定义评估维度,同时输出偏好结果与连续型质量得分(0–1 区间)
score_margin 解读:
-
score_margin = -0.128:表示 response_B 得分比 response_A 高 12.8 个百分点 -
|score_margin| < 0.1:质量差异极小(判定接近) -
|score_margin| > 0.2:质量差异明显(判定置信度高)
使用案例:
-
模型优化:定位模型表现不足的具体方面
-
质量量化:不仅评估胜负关系,更衡量性能差距的大小
-
置信度评测:区分接近判定与明确的质量差异
重要
最终判定仍以评判模型的显式偏好标签为准,以保留整体推理能力,并通过正向/反向评估有效缓解位置偏差。加权分数仅作为可观测性工具,不能替代主判定结果。
计算方法
加权分数通过以下流程计算:
-
提取评估维度数据:解析评判模型的 YAML 输出,提取各维度得分与权重
-
得分归一化:
-
量表型维度(1–5 分):通过公式
(score - 1) / 4归一化到 0–1 区间 -
二分型维度(是/否):转换为 1.0/0.0
-
-
应用权重:将每条归一化得分乘以对应维度的权重
-
汇总得分:对每条响应的所有加权分数求和
-
计算差值:计算
score_margin = weighted_score_A - weighted_score_B
示例:如果若 response_A 加权总分为 0.65,response_B 为 0.78,则 score_margin = -0.13,表示在所有加权维度下,response_B 的质量高出 13 个百分点。
推理模型支持
推理模型支持功能可借助具备推理能力的 Nova 模型开展评估,这类模型会在生成最终响应前执行显式的内部推理。该功能通过 reasoning_effort 参数实现 API 级别的控制,可动态启用/禁用推理功能,有助于提升复杂分析类任务的响应质量。
支持的模型:
-
amazon.nova-2-lite-v1:0:256k
配方配置
在配方的 inference 模块中添加 reasoning_effort 参数,即可启用推理功能:
run: name: eval-job-name # [MODIFIABLE] Unique identifier for your evaluation job model_type: amazon.nova-2-lite-v1:0:256k # [FIXED] Must be a reasoning-supported model model_name_or_path: nova-lite-2/prod # [FIXED] Path to model checkpoint or identifier replicas: 1 # [MODIFIABLE] Number of replicas for SageMaker Training job data_s3_path: "" # [MODIFIABLE] Leave empty for SageMaker Training job; optional for job output_s3_path: "" # [MODIFIABLE] Output path for job (not compatible with SageMaker Training jobs) evaluation: task: mmlu # [MODIFIABLE] Evaluation task strategy: generate # [MODIFIABLE] Evaluation strategy metric: all # [MODIFIABLE] Metric calculation method inference: reasoning_effort: high # [MODIFIABLE] Enables reasoning mode; options: low/medium/high or null to disable max_new_tokens: 200 # [MODIFIABLE] Maximum tokens to generate top_k: 50 # [MODIFIABLE] Top-k sampling parameter top_p: 1.0 # [MODIFIABLE] Nucleus sampling parameter temperature: 0 # [MODIFIABLE] Sampling temperature (0 = deterministic)
reasing_effort 参数使用说明
reasoning_effort 参数用于控制具备推理能力模型的推理行为。
先决条件:
-
模型兼容性:仅当
model_type指定了具备推理能力的模型(当前为amazon.nova-2-lite-v1:0:256k)时,才需设置reasoning_effort -
错误处理:对不受支持的模型使用
reasoning_effort将会失败,并返回ConfigValidationError: "Reasoning mode is enabled but model '{model_type}' does not support reasoning. Please use a reasoning-capable model or disable reasoning mode."错误
可用选项:
Option |
行为 |
词元限制 |
使用场景 |
|---|---|---|---|
null(默认) |
禁用推理模式 |
不适用 |
无需推理开销的标准评估 |
low |
启用推理并施加约束 |
内部推理占用 4000 词元 |
需要简洁推理的场景;兼顾速度与成本优化 |
high |
启用推理且无约束 |
内部推理无词元上限 |
需要深度分析与分步推理的复杂问题 |
何时启用推理
满足以下场景时,建议使用推理模式(low、medium 或 high):
-
复杂问题求解任务(数学、逻辑谜题、编程)
-
需要中间推理过程的多步分析类问题
-
详细推导或分步思考可提升准确率的任务
-
优先保证响应质量而非速度的场景
满足以下场景时,建议使用非推理模式(不设置该参数):
-
简单问答或事实查询
-
创意写作类任务
-
对响应速度要求极高的场景
-
需要排除推理开销的性能基准测试
-
推理无法提升效果、需优化成本的场景
问题排查
错误:“Reasoning mode is enabled but model does not support reasoning”
原因:reasoning_effort 参数被设为非空值,但指定的 model_type 支持推理。
解决方法:
-
确认模型类型为
amazon.nova-2-lite-v1:0:256k -
若使用其他模型,或切换为具备推理能力的模型,或从配方中移除
reasoning_effort参数