Browse operation contracts · Static machine index · OpenAPI release reference · Build manifest

Annotation span evaluation

Evaluate supplied labeled text spans with exact boundaries or thresholded intersection-over-union. Bounded deterministic maximum-cardinality one-to-one matching returns precision/recall/F1, matches and unmatched IDs. UTF-16 half-open offsets are validated; labels and text meaning are not judged.

data-assurance · Operation ID: span-evaluate

Choose this operation when

Outside this profile

Exact release references

Static JSON contract · Markdown reference · Fixed example response

Complete input schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "text": {
      "type": "string",
      "maxLength": 50000
    },
    "references": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "start": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "end": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "id",
          "label",
          "start",
          "end"
        ],
        "additionalProperties": false
      }
    },
    "predictions": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "start": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "end": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "id",
          "label",
          "start",
          "end"
        ],
        "additionalProperties": false
      }
    },
    "match": {
      "default": "exact",
      "type": "string",
      "enum": [
        "exact",
        "overlap"
      ]
    },
    "minimumIou": {
      "default": 0.5,
      "type": "number",
      "exclusiveMinimum": 0,
      "maximum": 1
    }
  },
  "required": [
    "text",
    "references",
    "predictions"
  ],
  "additionalProperties": false
}

Complete output-envelope schema

{
  "type": "object",
  "required": [
    "operation",
    "version",
    "result",
    "provenance"
  ],
  "properties": {
    "operation": {
      "const": "span-evaluate",
      "type": "string"
    },
    "version": {
      "const": "0.29.0",
      "type": "string"
    },
    "result": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "type": "object",
      "properties": {
        "profile": {
          "type": "string",
          "const": "annotation-span-evaluation-v1"
        },
        "offsetUnit": {
          "type": "string",
          "const": "utf16-code-unit"
        },
        "referenceCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "predictionCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "matchedCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "precision": {
          "type": "number"
        },
        "recall": {
          "type": "number"
        },
        "f1": {
          "type": "number"
        },
        "precisionDefined": {
          "type": "boolean"
        },
        "recallDefined": {
          "type": "boolean"
        },
        "meanMatchedIou": {
          "type": [
            "number",
            "null"
          ]
        },
        "matches": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "predictionId": {
                "type": "string"
              },
              "referenceId": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "iou": {
                "type": "number"
              },
              "exactBoundaries": {
                "type": "boolean"
              }
            },
            "required": [
              "predictionId",
              "referenceId",
              "label",
              "iou",
              "exactBoundaries"
            ],
            "additionalProperties": false
          }
        },
        "unmatchedPredictionIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "unmatchedReferenceIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "perLabel": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string"
              },
              "referenceCount": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "predictionCount": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "matchedCount": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "precision": {
                "type": "number"
              },
              "recall": {
                "type": "number"
              },
              "f1": {
                "type": "number"
              }
            },
            "required": [
              "label",
              "referenceCount",
              "predictionCount",
              "matchedCount",
              "precision",
              "recall",
              "f1"
            ],
            "additionalProperties": false
          }
        },
        "conventions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "profile",
        "offsetUnit",
        "referenceCount",
        "predictionCount",
        "matchedCount",
        "precision",
        "recall",
        "f1",
        "precisionDefined",
        "recallDefined",
        "meanMatchedIou",
        "matches",
        "unmatchedPredictionIds",
        "unmatchedReferenceIds",
        "perLabel",
        "conventions"
      ],
      "additionalProperties": false
    },
    "provenance": {
      "type": "object",
      "required": [
        "inputSha256",
        "outputSha256",
        "deterministic",
        "externalRequests"
      ],
      "properties": {
        "inputSha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "outputSha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "deterministic": {
          "const": true
        },
        "externalRequests": {
          "const": 0
        }
      }
    }
  },
  "additionalProperties": false
}

Fixed example

One accepted fixed example, not a custom-input trial. No operation runs when this static page is requested.

Example input

{
  "text": "Ada builds agents in London.",
  "references": [
    {
      "id": "r1",
      "label": "person",
      "start": 0,
      "end": 3
    },
    {
      "id": "r2",
      "label": "place",
      "start": 21,
      "end": 27
    }
  ],
  "predictions": [
    {
      "id": "p1",
      "label": "person",
      "start": 0,
      "end": 3
    },
    {
      "id": "p2",
      "label": "place",
      "start": 21,
      "end": 26
    }
  ],
  "match": "overlap",
  "minimumIou": 0.8
}

Example response

{
  "operation": "span-evaluate",
  "version": "0.29.0",
  "result": {
    "profile": "annotation-span-evaluation-v1",
    "offsetUnit": "utf16-code-unit",
    "referenceCount": 2,
    "predictionCount": 2,
    "matchedCount": 2,
    "precision": 1,
    "recall": 1,
    "f1": 1,
    "precisionDefined": true,
    "recallDefined": true,
    "meanMatchedIou": 0.9166666666666667,
    "matches": [
      {
        "predictionId": "p1",
        "referenceId": "r1",
        "label": "person",
        "iou": 1,
        "exactBoundaries": true
      },
      {
        "predictionId": "p2",
        "referenceId": "r2",
        "label": "place",
        "iou": 0.8333333333333334,
        "exactBoundaries": false
      }
    ],
    "unmatchedPredictionIds": [],
    "unmatchedReferenceIds": [],
    "perLabel": [
      {
        "label": "person",
        "referenceCount": 1,
        "predictionCount": 1,
        "matchedCount": 1,
        "precision": 1,
        "recall": 1,
        "f1": 1
      },
      {
        "label": "place",
        "referenceCount": 1,
        "predictionCount": 1,
        "matchedCount": 1,
        "precision": 1,
        "recall": 1,
        "f1": 1
      }
    ],
    "conventions": [
      "Spans are nonempty half-open UTF-16 code-unit ranges; surrogate pairs cannot be split. Labels match exactly. Repeated label/boundary spans on the same side are rejected.",
      "Matching maximizes one-to-one pair count. Deterministic ID order and local IoU preference break ties; total IoU is not globally maximized.",
      "Undefined precision/recall/F1 uses 0. This evaluates supplied annotations and boundaries, not the truth or meaning of their labels."
    ]
  },
  "provenance": {
    "inputSha256": "17fd96b5568ac2fb16fcbdb52e9741bfa919234807e289f37c7ea47b30710f28",
    "outputSha256": "69f28072bd7f33501f9d2566743476fd9024f8437868687e435fa8156ff5c4f1",
    "deterministic": true,
    "externalRequests": 0
  }
}

Bounds and precision

JavaScript IEEE-754 numbers; use strings for large integer IDs/exact decimals where the schema accepts strings. No lossless numeric parsing.

{
  "global": {
    "requestBytes": 131072,
    "responseBytes": 524288,
    "jsonDepth": 32,
    "jsonNodes": 20000,
    "requestsPerMinute": 60,
    "paidAttemptsPerMinute": 20,
    "idempotencyHours": 24
  },
  "operation": {
    "inputBytes": 100000,
    "outputBytes": 400000,
    "jsonNodes": 12000,
    "depth": 20,
    "evidence": 200,
    "keyWorkBytes": 3000000,
    "matchingSteps": 2000000,
    "textUtf16Units": 50000,
    "references": 100,
    "predictions": 100
  }
}

Complete schemas, descriptions and cross-field validation may impose additional limits.

Proposed price and protocol definitions

{
  "unit": "one successful operation call",
  "proposedNominalUsd": "0.01",
  "sixDecimalTokenBaseUnits": "10000",
  "subscription": false,
  "includesPayerWalletOrNetworkFees": false,
  "liveQuoteVerified": false,
  "condition": "Actual SDK challenge is authoritative only within the caller's explicit authorization; configured six-decimal token peg is an operator assertion, not a conversion guarantee."
}

Protocol definitions: x402, mpp. MPP uses Tempo charge. Paid MCP execution is unsupported. All runtime readiness is not evaluated in this build.

API path templates, not endpoints on this documentation host

{
  "x402": "/v1/x402/span-evaluate",
  "mpp": "/v1/mpp/span-evaluate"
}

Required headers

{
  "Content-Type": "application/json",
  "Idempotency-Key": "random 16–128 character operation identifier"
}

Actual SDK challenge amount, asset, network, recipient and wallet costs must pass independent authorization. Preserve identical key, body, protocol and credential on retries; on PAYMENT_UNCERTAIN stop and reconcile.

Execution profile and provider conditions

{
  "deterministic": true,
  "externalRequests": 0,
  "maxExternalRequests": 0,
  "resultSnapshotPersisted": false,
  "fixedExampleIsIllustrativeSnapshot": false,
  "requiresPayment": true,
  "supportsMcpExecution": false
}

Deterministic supplied-input operation with no external requests or stored request/result bodies. Payment infrastructure retains payment metadata and hashes.

Failure handling

Declared requirements

Before any paid call, refresh the live operation contract and POST the complete bounded budgeted plan to the separate API's /preflight. Unknown requirements block selection; compatible preflight is not permission to spend.

Related contracts