跳转到主要内容

实验数据集

使用 Datasets 为实验存储可复用的测试用例。 每个数据集可以拥有一个或多个不可变版本。运行实验时,Fetch Hive 使用特定的数据集版本,以保证该次运行可重复。

如何创建数据集?

打开 Experiments,然后在次级导航中选择 Datasets 点击 Add Dataset 输入名称和可选描述。 上传 CSV 文件。你可以点击上传区域,或将 CSV 拖入其中。 检查列映射。Fetch Hive 会自动映射:
  • 普通列到输入值
  • expected_output 到期望输出
  • metadata.* 列到行元数据
点击 Add Dataset 创建数据集及其第一个版本。

如何查看数据集版本?

打开 Experiments,然后选择 Datasets 点击数据集行打开数据集详情页。 使用页头的版本选择器在版本间切换。版本以 v1v2v4 等标签形式显示。 页面 URL 包含所选版本:
/experiments/datasets/:datasetId/v/:versionId
打开数据集时若未指定版本,会自动选择最新版本。 运行总是存储其使用的精确数据集版本,因此即使存在更新版本,旧运行仍然可复现。

CSV 文件格式

第一行必须包含列标题。 CSV 导入器支持带引号的值、引号内的逗号、转义引号、引号内的多行值以及空单元。 上传限制:
限制
文件类型CSV
最大文件大小5 MB
最大行数10,000
对话框中显示的预览行数50

CSV 列

实验数据集有三种列:
  • 输入列
  • 一个可选的期望输出列
  • 可选的元数据列
只有输入列是运行候选项所必需的。期望输出和元数据是可选的。

输入列

输入列是 Fetch Hive 在该行中传入提示词或智能体的值。 对于提示词实验,它们没有固定的名称。questioncontextcustomer_message 仅作为示例,并非必需的列名。 使用与你要测试的候选项相匹配的列名。
候选项类型CSV 输入列应当匹配什么示例列
Dashboard Prompt提示词编辑器中的提示词变量questioncontextinput_urlinput_scrape
Deployed Prompt所选部署版本中捕获的提示词变量questioncontextinput_urlinput_scrape
Agent智能体的用户消息输入message
建议至少有一个输入列。没有输入列时,该次运行就没有特定于行的输入可发送给候选项。 对于提示词实验,CSV 输入列应与提示词变量匹配。如果你的提示词包含 {{question}}{{context}},你的 CSV 应包含 questioncontext 如果你的提示词包含 {{input_url}}{{input_scrape}},你的 CSV 应改为包含 input_urlinput_scrape 对于智能体实验,使用 message 作为主输入列。智能体从用户消息开始,所以 message 是最清晰的数据集结构。
message,expected_output,metadata.case_id,metadata.topic
"Find the pricing page for Acme and summarize the plans.","A concise pricing summary","agent-001","research"

期望输出列

当某一行有参考答案时,使用 expected_output
列名是否必填存储为说明
expected_outputexpected_output.value目前用于人工审阅,未来用于评估器打分。
评估器执行尚未启用。这意味着 expected_output 目前不会自动将结果标记为正确或错误。

元数据列

使用 metadata.* 列作为可选的行标签。 元数据列在今天不会触发内置行为。它们不会改变运行顺序、模型设置、locale、路由或候选项执行。Fetch Hive 将其与行一同存储,以便你识别用例、筛选结果、比较分组,或将结果与你自己的系统关联起来。
列模式是否必填存储为示例
metadata.case_idmetadata.case_id 变为 case_idgeo-001
metadata.topicmetadata.topic 变为 topicgeography
metadata.prioritymetadata.priority 变为 priorityhigh
metadata.sourcemetadata.source 变为 sourcesupport_faq
metadata.languagemetadata.language 变为 languageen
这些名称仅为示例。你可以使用任何有助于团队审阅结果的 metadata.* 名称。 对于新数据集,请勿使用 meta_ 前缀。请使用 metadata.*,使映射更清晰。

常见的 CSV 结构

包含 {{question}} 的提示词:
question,expected_output,metadata.case_id,metadata.topic
"What is the capital of France?","Paris","geo-001","geography"
包含 {{question}}{{context}} 的提示词:
question,context,expected_output,metadata.case_id,metadata.topic
"What is the refund window?","Customers can request a refund within 30 days.","30 days","policy-001","support"
包含 {{input_url}}{{input_scrape}} 的提示词:
input_url,input_scrape,expected_output,metadata.case_id,metadata.topic
"https://example.com/pricing","The pricing page lists Starter, Pro, and Enterprise plans.","Summarize the three available plans.","scrape-001","pricing"
智能体消息:
message,expected_output,metadata.case_id,metadata.topic
"Classify this customer message: The setup was quick and support was helpful.","positive","sentiment-001","classification"

示例 CSV

你可以从 Add Dataset 对话框下载示例 CSV。
question,context,expected_output,metadata.case_id,metadata.topic
"What is the capital of France?","Use only the provided context. France's capital city is Paris.","Paris","geo-001","geography"
"Who wrote Pride and Prejudice?","Jane Austen published Pride and Prejudice in 1813.","Jane Austen","lit-001","literature"
"What is 18 multiplied by 7?","Calculate the product exactly.","126","math-001","math"
"Which planet is known as the Red Planet?","Mars is often called the Red Planet because of iron oxide on its surface.","Mars","space-001","science"
"What HTTP status code means Not Found?","Common HTTP status codes include 200 OK, 404 Not Found, and 500 Internal Server Error.","404","web-001","web"
"Summarize the refund policy in one sentence.","Customers can request a refund within 30 days of purchase if they provide the original receipt.","Customers can request a refund within 30 days with the original receipt.","policy-001","support"
"Return the country code for Japan.","Use ISO 3166-1 alpha-2 country codes. Japan is JP.","JP","locale-001","localization"
"What color do you get by mixing blue and yellow?","In subtractive color mixing, blue and yellow make green.","Green","art-001","art"
"Extract the invoice total.","Invoice INV-1042 lists subtotal $90, tax $9, and total $99.","$99","invoice-001","finance"
"Classify the sentiment as positive, neutral, or negative.","The customer wrote: The setup was quick and the support team was helpful.","positive","sentiment-001","classification"

数据集版本

数据集版本是不可变的。 如果以后需要更改行,请创建新的数据集版本,而不是编辑已被某次运行使用的版本。这能让旧的实验运行保持可复现。

导入行

在数据集详情页使用 Import 向数据集追加行。 导入行不会编辑当前版本。Fetch Hive 会创建一个新的不可变版本,包含:
  • 来自最新数据集版本的所有行
  • 上传的 CSV 中的任何新行
重复行会被跳过。重复检测会比较行的输入值。行位置、期望输出和元数据不会让相同的输入行在导入时被视作唯一。 导入后,Fetch Hive 会显示:
  • 已导入的行数
  • 跳过的重复行数
  • 新的最新数据集版本
示例: 如果 v3 有 100 行,你导入了包含 20 行(其中 5 行重复)的 CSV,Fetch Hive 会创建包含 115 行的 v4 导入前创建的运行仍指向其原始数据集版本。新的运行可以使用最新版本。 另请参阅:构建实验查看结果