Console ↗

SDE cascade

Verify a first-pass extraction against the source. Send fields with weak support to a second pass.

Input and workflow

Verify each field individually. Feed only the unsupported field and its source span into your fallback extractor, then validate again.

Request

{
  "model": "ngila-judge",
  "state": {
    "source": "Order 241 ships on June 14.",
    "extracted": {
      "order": "241",
      "ship_date": "June 15"
    }
  },
  "questions": {
    "order_supported": {
      "type": "noul",
      "instructions": "Is the extracted order number supported by the source?"
    },
    "date_supported": {
      "type": "noul",
      "instructions": "Does the extracted shipping date match the source?"
    }
  }
}

Open request in Playground →

Run locally

Save ngila.py alongside your script and set NGILA_API_KEY. Save any linked input images in the same directory.

import json
from ngila import NgilaClient

state = {'source': 'Order 241 ships on June 14.',
 'extracted': {'order': '241', 'ship_date': 'June 15'}}
questions = {'order_supported': {'type': 'noul',
                     'instructions': 'Is the extracted order number supported '
                                     'by the source?'},
 'date_supported': {'type': 'noul',
                    'instructions': 'Does the extracted shipping date match '
                                    'the source?'}}

response = NgilaClient().system_one(state, questions)
a = response["answers"]
print(json.dumps(a, indent=2, ensure_ascii=False))

Use the answers

The following application fragment uses a = response["answers"]. Supply any thresholds, lookup tables, or previous results from your workflow before applying it.

retry_fields = [k.removesuffix("_supported") for k,v in a.items() if v["noul"] < threshold]

Browse cookbooks · System One request and response