提示词优化器
向优化器提供一个提示词和少量带标注的示例。它会运行 DSPy 优化循环,返回改进后的提示词,并展示优化前后的结果以及支撑这一改动的评分。
一次真实运行
优化器实际返回的结果
这是从服务中捕获的一次真实运行,而非示意。值得注意的是初始提示词的失败方式:它并非选错队列,而是忽略了分派任务,像客服人员一样直接回复了工单。
- 任务:
- Route a support ticket to one of four queues. The rule is deliberately not guessable from the label names: sales means money has not moved yet, billing means it has, and incident means many users are affected rather than one.
| 工单 | 优化前 | 优化后 | 正确队列 |
|---|---|---|---|
| You billed my card after I cancelled. | I sincerely apologize for this billing error. I understand how frustrating it is to be charged after cancelling… | billing | billing |
| Every request from our region is timing out right now. | Thank you for reporting this critical issue. I understand that all requests from your region are currently tim… | incident | incident |
| Is there a nonprofit rate before we sign up? | Thank you for your interest in our services for your nonprofit organization! Yes, we do offer special pricing… | sales | sales |
| My saved filter disappeared after I renamed it. | Thank you for reporting this issue. I understand how frustrating it is to lose a saved filter, especially afte… | support | support |
初始提示词回复了客户,而不是进行分派。
优化后的提示词只返回队列名称。
Route the support ticket to one queue: billing, sales, incident, or support.
Ticket: {ticket}
Queue:Examples:
Example 1:
Ticket: I cannot change my avatar in settings.
Reasoning: This ticket describes a user experiencing an issue with a specific feature (changing avatar in settings). This is a localized problem affecting an individual user's ability to use a particular functionality. It's not a widespread outage or system-wide issue that would constitute an incident. Instead, it's a support request where the user needs help troubleshooting or resolving their specific problem with the avatar change feature.
Response: support
Example 2:
Ticket: Can we get a trial extension before we commit?
Reasoning: This ticket is asking about a trial extension before making a commitment/purchase. This is a sales-related inquiry about extending a trial period, not a technical support issue or a system incident. The customer is in the evaluation/decision-making phase and needs to discuss commercial terms with the sales team.
Response: sales
---
Let me think step by step to solve this task.
Ticket: {ticket}
Reasoning: Let me analyze this step by step.
Response:输入 12 条带标签工单,在优化器未见过的 8 条上评估。
优化后,8 条留出工单中有 8 条分派正确。
取自真实运行。优化器变更时会重新测量。 anthropic/claude-sonnet-4.5 · DSPy 3.2.1 · BootstrapFewShot