使用场景
Decisions API 用于分类
分类就是为输入从有限标签中选择一个——这正是决策端点原生做的事。你不必从生成的文本里解析标签,而是预先定义好标签,拿回胜出项和每个选项的概率。
更新于
什么时候有限标签合适
只要下游代码需要一组已知答案中的一个,决策调用就合适:工单类别、审核结论、意图标签、文档类型。如果人工会从固定清单里挑,choice 问题就是直接的翻译。
如果你的标签是无界的——每个输入都可能是新类别——分类就不合适,你需要的是生成。最佳场景是你可以命名并描述的封闭集合。
- 工单类别:billing、bug、account、other
- 内容审核结论:spam、safe、needs review
- 意图标签:refund、cancel、change plan、question
单标签:一个 choice 问题
做单标签分类时,发送一个 choice 问题,其 criteria 把每个标签映射到一段简短描述。始终包含一个 other 或 unclear 选项——给模型一个诚实的出口,让边界输入不会被塞进错误的桶。
单标签 choice
// Single-label classification: one choice question per call.
const res = await fetch("https://decisions-api.net/api/v1/decisions", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "decisions-1",
state: "I was charged twice for my subscription this month.",
questions: {
category: {
type: "choice",
instructions: "Which category fits this support ticket best?",
criteria: {
billing: "Charges, invoices, refunds, or subscriptions.",
bug: "Something is broken or returns an error.",
account: "Login, password, or profile problems.",
other: "None of the above fit.",
},
},
},
}),
});
// Illustrative response: answers.category ->
// { choice: "billing", probabilities: {...}, confidence: 0.91 }多标签:一次调用多个 noul 问题
多标签分类——多个标签可以同时为真——对应于对同一 state 提出多个 noul 问题。每个 noul 问题是某个标签的“是”概率,一次调用最多可以放 6 个问题,仍只花 1 积分。
多标签 noul 批量
// Multi-label moderation: several noul questions over the same state.
// Each noul answer is a yes-probability between 0 and 1.
const res = await fetch("https://decisions-api.net/api/v1/decisions", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "decisions-1",
state: "Congratulations! Verify your account to claim your prize.",
questions: {
is_spam: { type: "noul", instructions: "Is this message spam or a scam?" },
pushes_action: {
type: "noul",
instructions: "Does it push the reader to click, pay, or verify something?",
},
needs_review: {
type: "noul",
instructions: "Should a human moderator review this message?",
},
},
}),
});
// Illustrative response: answers.is_spam -> { noul: 0.97 },
// answers.needs_review -> { noul: 0.88 }严重度与顺序:score
当标签有序时——低/中/高,或 P3 到 P0——用 score 问题代替 choice。criteria 是等级描述的数组,最低的在前;答案是等级序号加上每个等级的概率。
按置信度行动,而不只是按标签
让自动化安全的是概率分布。一个合理的起点:置信度 ≥ 0.8 时自动应用标签,低于此的全部送人工复核。用你自己的数据调阈值——正确取值取决于错误标签的代价。
常见问题
一个问题能有多少个标签?
choice 问题接受 2 到 8 个选项,score 问题接受 2 到 10 个有序等级。每次调用最多可发 6 个问题,所以一次调用可以同时沿多个轴分类。
多标签分类怎么做?
对同一 state 每个标签发一个 noul 问题——每次调用最多 6 个。每个答案是独立的“是”概率,所以一个输入可以被打上任意组合的标记。
一次分类调用多少钱?
本站每次成功调用 1 积分,无论你问 1 个还是 6 个问题。校验错误和上游失败不扣费。
现在分类点什么
新访客一次免费试用决策——把你自己的文本粘进试用台,读出概率。