文档目录

进阶:结构化写法

instructions(指令)字段、Choice(选择题)选项、Score(打分题)档位以及 Noul(是非题)的 criteria(判定标准)字段,都接受 JSON 结构。

非官方中文翻译 · 内容以 英文原文 ↗ 为准 · 同步于 2026-10-15

System One 模型经过训练,能够理解结构化内容。

哪些字段支持结构化

下面每一个字段都是一个 EntryType 类型。

字段 适用题型 支持的数据形态
instructions Choice、Score、Noul string、object、array、null
criteria 的值(选项描述) Choice string、object、array、null
criteria 的条目(档位描述) Score string、object、array、null
criteria.true 和 criteria.false Noul string、object、array、null

何时应当把问题结构化

  • 有助于表达清晰时。 当一个问题由多个部分组成时,把它写成 JSON 会更清晰,因为每个键本身就带有语义标签。
  • 问题需要附带数据时。 schema、分类树、数据库记录本身就已经是 JSON。这时可以直接传入整段 JSON,或者只传入相关子字段,而不必再把它们拼成一个字符串模板。

结构化 instructions

一个 field 对象描述被校验的字段,每道问题通过键名引用它。同一种结构既适用于校验某个值的 Noul(是非题),也适用于从候选项中挑一个的 Choice(选择题),以及把一个值放到某个区间上的两个 Score(打分题)。

json
{
  "model": "jev-latest",
  "state": {
    "source_text": "Invoice #4471 issued March 3, 2026 to Beaver Dam Logistics for $12,840.00, net 30."
  },
  "questions": {
    "invoice_number_is_correct": {
      "type": "noul",
      "instructions": {
        "field": {
          "name": "invoice_number",
          "type": "string",
          "description": "The identifier printed on the invoice."
        },
        "extracted_value": "4471",
        "question": "Does `extracted_value` match the `field` as it appears in `source_text`?"
      }
    },
    "customer_name": {
      "type": "choice",
      "instructions": {
        "field": {
          "name": "customer_name",
          "type": "string",
          "description": "The organization the invoice was issued to."
        },
        "question": "Which option is the value of `field` in `source_text`?"
      },
      "criteria": {
        "Beaver Logistics": null,
        "Dam Logistics": null,
        "Beaver Dam Logistics": null,
        "Beaver": null,
        "Dam": null
      }
    },
    "amount_due": {
      "type": "score",
      "instructions": {
        "field": {
          "name": "amount_due",
          "type": "number",
          "unit": "USD",
          "description": "The total the invoice asks to be paid."
        },
        "question": "How large is the `field` value in `source_text`?"
      },
      "criteria": [
        "Under $1,000",
        "$1,000 to $10,000",
        "$10,000 to $100,000",
        "$100,000 to $1,000,000",
        "Over $1,000,000"
      ]
    },
    "payment_terms": {
      "type": "score",
      "instructions": {
        "field": {
          "name": "payment_terms",
          "type": "integer",
          "unit": "days",
          "description": "Days allowed for payment, from terms such as \"net 30\"."
        },
        "question": "How many days does the `field` in `source_text` allow for payment?"
      },
      "criteria": [
        "Due on receipt",
        "Net 10",
        "Net 30",
        "Net 60",
        "Net 90"
      ]
    }
  }
}

代码里可以遍历候选记录,为每个字段构造一道问题,并合并到同一次请求里提交。SDE cascade 实战示例 里就做了类似的事情。

数组也可以。当指令本身就是要逐项检查或逐项对比的列表时,使用数组很合适:

json
"instructions": {
  "question": "Does the claimed sender identity conflict with the sending domain?",
  "compare": ["ticket.sender.display_name", "ticket.sender.email"],
  "focus": "Compare the named organization with the email domain."
}

结构化 Choice 选项

Choice 选项的描述也可以写成结构化对象。

用 JSON 量表澄清选项边界

json
{
  "model": "jev-latest",
  "state": "I ordered the standing desk two weeks ago and tracking still says label created. Was I even charged?",
  "questions": {
    "department": {
      "type": "choice",
      "instructions": {
        "question": "Which team should handle this message?",
        "focus": "Classify the customer's primary request, not every topic mentioned."
      },
      "criteria": {
        "billing": {
          "what": "Charges, invoices, refunds, or subscriptions",
          "not_for": "Order tracking or account access",
          "examples": [
            "I was charged twice",
            "Where is my refund?"
          ]
        },
        "orders": {
          "what": "Order status, delivery, cancellation, or returns",
          "not_for": "Charges or account access",
          "examples": [
            "Where is my package?",
            "Cancel my order"
          ]
        },
        "account": {
          "what": "Login, password, profile, or security",
          "not_for": "Charges or delivery",
          "examples": [
            "I can't log in",
            "Change my email"
          ]
        }
      }
    }
  }
}

这个示例让模型清楚每个选项覆盖以及不覆盖的内容,从而把选项之间的边界划得更清晰。

遍历分类树

要把样本分到一棵层级很深的分类树时,可以在每一层用一个 Choice,在代码里逐层向下走。每一步的选项就是当前节点的子节点,每个选项的值是该子节点的子树。这样在真正选定之前,模型就能先看到该分支下面都有什么。当样本落到一个叶子节点、而仅凭父分支的名字又难以判断时,这点尤其关键。

这里传入的 state(上下文状态)是一段商品描述,第一道问题负责选出顶级部门。

json
{
  "model": "jev-latest",
  "state": "32oz plastic bottle with a flip straw lid. Fits most bike cages.",
  "questions": {
    "department": {
      "type": "choice",
      "instructions": "Which top-level department does this product belong to?",
      "criteria": {
        "Sporting Goods": {
          "Cycling": [
            "Bike Bottles & Cages",
            "Bike Lights",
            "Helmets"
          ],
          "Fitness": [
            "Yoga Mats",
            "Resistance Bands"
          ],
          "Outdoor": [
            "Tents",
            "Sleeping Bags",
            "Hydration Packs"
          ]
        },
        "Home & Kitchen": {
          "Drinkware": [
            "Water Bottles",
            "Travel Mugs",
            "Tumblers"
          ],
          "Cookware": [
            "Pots & Pans",
            "Bakeware"
          ]
        },
        "Baby & Toddler": [
          "Sippy Cups",
          "Bottle Warmers",
          "Bibs"
        ]
      }
    }
  }
}

这个水瓶看起来既可能落在运动部门,也可能落在家居厨房部门。把子树一并展示,模型就能同时看到 Sporting Goods > Cycling > Bike Bottles & Cages 和 Home & Kitchen > Drinkware > Water Bottles 这两个类目的存在,并把描述中对“车架”的强调与日常水具做权衡。这个回答返回的 probabilities(概率)会告诉你两个分支的差距有多大,从而判断是否值得沿着两个分支同时继续向下探。

选定某个部门之后,下一道 Choice 的选项就换成该部门的子节点,选项的值是各自的子树,并不断重复直到走到叶子节点。代码上这可以是对一个嵌套字典的循环,每道问题的 criteria 就是当前节点。Hierarchical Classification 实战示例 给出了一个类似的遍历示例,其中包含一种 beam search(束搜索)策略,会在概率接近时同时保留若干条候选路径。

结构化 Score 档位

Score 的 criteria 数组中,每一项也可以是一个对象。

json
{
  "model": "jev-latest",
  "state": "Fixed the null check in the payment handler. Also refactored the retry loop while I was in there, and bumped the SDK version since the old one had that timeout bug.",
  "questions": {
    "pr_scope": {
      "type": "score",
      "instructions": {
        "question": "How focused is this pull request description on a single change?",
        "note": "Judge the number of independent changes, not the size of any one change."
      },
      "criteria": [
        {
          "summary": "One change, clearly stated",
          "signals": [
            "A single fix or feature",
            "Nothing described as \"also\" or \"while I was in there\""
          ]
        },
        {
          "summary": "One main change plus a small related tweak",
          "signals": [
            "A primary change and one minor adjacent edit",
            "The tweak supports the main change"
          ]
        },
        {
          "summary": "Several independent changes bundled together",
          "signals": [
            "Two or more unrelated fixes or features",
            "Changes that could each be their own PR"
          ]
        }
      ]
    }
  }
}

结构化的 Noul criteria(判定标准)

Noul criteria 是可选的。当是/非的边界比较模糊时,可以用结构化的 true 和 false 描述,分别给出定义和示例,把边界说清楚。

json
{
  "model": "jev-latest",
  "state": {
    "sender": {
      "display_name": "Beaver Dam Builders Ltd.",
      "email": "donotreply@payroll.example"
    },
    "message": "Your Q3 bonus is ready. Reply with your login password so we can verify your identity and release the funds."
  },
  "questions": {
    "requests_credentials": {
      "type": "noul",
      "instructions": {
        "question": "Does the `message` ask the recipient to disclose a sensitive credential?",
        "inspect": "message",
        "focus": "Look for a request to send the credential itself, not a request to change or reset it."
      },
      "criteria": {
        "true": {
          "what": "Asks the recipient to reply with, type, or send a password, PIN, one-time code, or other security sensitive answer",
          "examples": [
            "Reply with your password",
            "Send us the 6-digit code you just received"
          ]
        },
        "false": {
          "what": "No sensitive credential is requested",
          "examples": [
            "Reset your password from the settings page",
            "Your statement is ready"
          ]
        }
      }
    }
  }
}

本文档由 Mintlify 搭建和托管,这是一个开发者文档平台。