ドキュメント

発展:構造

発展:構造

instructions、Choice の選択肢、Score のレベル、Noul の criteria は、すべて JSON 構造を受け付けます。

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 の形にするとキーがラベル付けされるので明確さに役立ちます。
  • 質問が補足データを必要とするとき。 スキーマ、分類体系、データベースの行はすでに JSON です。文字列テンプレートにシリアライズするのではなく、JSON をそのまま使うか、関連するサブフィールドを渡してください。

構造化された instructions

一つの field オブジェクトがチェック対象のフィールドを記述し、各質問がキーでそれを参照します。同じ形が、値を検証する Noul、候補から一つを選ぶ Choice、値をスケール上に位置付ける二つの Score を動かします。

request
{
  "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 カスケードクックブックはこれに似たことをしています。

配列も機能します。instructions がチェックまたは比較するもののリストであるときに使います:

"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 ルーブリック

request
{
  "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 を尋ね、コードで木をたどります。各ステップで選択肢は現在のノードの子で、各選択肢の値は子の木です。こうすると、モデルはある枝にコミットする前にその下に何があるかを見られます。これは、項目が枝の名前だけからは自明でない葉に属するときに重要です。

ここでは状態が商品リストで、最初の質問がトップレベルの部門を選びます。

request
{
  "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 を尋ね、葉に着くまで繰り返します。コードではこれはネストした dict のループになり、各質問の criteria は単に現在のノードです。階層分類クックブックに、同様の木のたどり方の例があり、確率が近いときに複数の候補経路を生かしておくビームサーチも含まれます。

構造化された Score のレベル

Score の criteria 配列の各エントリはオブジェクトにできます。

request
{
  "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 の説明によって、両側に定義と例を付けてそれを明確にできます。

request
{
  "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"
          ]
        }
      }
    }
  }
}