使用评估工具

Claude Console 提供了一个评估工具,允许你在各种场景下测试提示词。


访问评估功能

开始使用评估工具的步骤:

  1. 打开 Claude Console 并导航到提示词编辑器。
  2. 编写提示词后,在屏幕顶部找到 "Evaluate" 标签页。

访问评估功能

Tip

确保你的提示词包含至少 1-2 个使用双大括号语法的动态变量:{{variable}}。这是创建评估测试集所必需的。

生成提示词

Console 提供了一个由 Claude Opus 4.1 驱动的内置提示词生成器

  1. 点击 'Generate Prompt'

    点击 "Generate Prompt" 辅助工具将打开一个模态框,允许你输入任务信息。

  2. 描述你的任务

    描述你想要的任务(例如,"对入站客户支持请求进行分类"),可以提供任意多或任意少的细节。你提供的上下文越多,Claude 就越能根据你的特定需求定制生成的提示词。

  3. 生成提示词

    点击底部的橙色 "Generate Prompt" 按钮,Claude 将为你生成高质量的提示词。然后你可以使用 Console 中的评估界面进一步优化这些提示词。

此功能使创建带有适当变量语法的提示词变得更加容易,以便进行评估。

提示词生成器

创建测试用例

当你访问评估界面时,有多种创建测试用例的选项:

  1. 点击左下角的 "+ Add Row" 按钮手动添加用例。
  2. 使用 "Generate Test Case" 功能让 Claude 自动生成测试用例。
  3. 从 CSV 文件导入测试用例。

使用 "Generate Test Case" 功能的步骤:

  1. 点击 'Generate Test Case'

    Claude 将为你生成测试用例,每次点击按钮生成一行。

  2. 编辑生成逻辑(可选)

    你还可以点击 "Generate Test Case" 按钮右侧的箭头下拉菜单,然后在弹出的 Variables 窗口顶部点击 "Show generation logic" 来编辑测试用例生成逻辑。你可能需要点击此窗口右上角的 "Generate" 来填充初始生成逻辑。

    编辑此内容可以让你自定义和微调 Claude 生成的测试用例,使其更加精确和具体。

以下是填充了多个测试用例的评估界面示例:

填充后的评估界面

Note

如果你更新了原始提示词文本,可以针对新提示词重新运行整个评估套件,以查看更改如何影响所有测试用例的性能。

有效评估的技巧

评估的提示词结构

为了充分利用评估工具,请以清晰的输入和输出格式构建提示词。例如:

In this task, you will generate a cute one sentence story that incorporates two elements: a color and a sound.
The color to include in the story is:
<color>
{{COLOR}}
</color>
The sound to include in the story is:
<sound>
{{SOUND}}
</sound>
Here are the steps to generate the story:
1. Think of an object, animal, or scene that is commonly associated with the color provided. For example, if the color is "blue", you might think of the sky, the ocean, or a bluebird.
2. Imagine a simple action, event or scene involving the colored object/animal/scene you identified and the sound provided. For instance, if the color is "blue" and the sound is "whistle", you might imagine a bluebird whistling a tune.
3. Describe the action, event or scene you imagined in a single, concise sentence. Focus on making the sentence cute, evocative and imaginative. For example: "A cheerful bluebird whistled a merry melody as it soared through the azure sky."
Please keep your story to one sentence only. Aim to make that sentence as charming and engaging as possible while naturally incorporating the given color and sound.
Write your completed one sentence story inside <story> tags.

这种结构使得变化输入({{COLOR}} 和 {{SOUND}})和一致地评估输出变得容易。

Tip

使用 Console 中的 "Generate a prompt" 辅助工具快速创建带有适当变量语法的提示词以进行评估。

理解和比较结果

评估工具提供了多项功能帮助你优化提示词:

  1. 并排比较:比较两个或多个提示词的输出,快速查看更改的影响。
  2. 质量评分:在 5 分制上对回复质量进行评分,以跟踪每个提示词的回复质量改进。
  3. 提示词版本控制:创建提示词的新版本并重新运行测试套件,以快速迭代和改进结果。

通过跨测试用例审查结果并比较不同的提示词版本,你可以发现模式并更高效地对提示词进行有针对性的调整。

立即开始评估你的提示词,使用 Claude 构建更强大的 AI 应用程序!