There are two ways to acquire a schema for universal information extraction:
- Automatic schema generation (recommended)
- Manual schema design.
Automatic schema generation
Manually defining a schema can be daunting and may require multiple trial-and-error attempts. The Schema Generation API helps you to create an initial schema from up to three sample files with ease.
The extracted schema is returned as a stringified JSON object within the message content. It adheres to the JSON Schema syntax and input schema restriction of the Information Extract API. User can provide their intention about the schema generation through the system message.
Try editing the extracted schema to better match your specific extraction needs before using it in the information extraction process.
Manual schema design
We recommend starting with automatic schema generation, but you can also manually define the schema or modify an automatically generated one.
Available datatypes
Schemas should follow the JSON Schema Syntax. The following types are supported for Schema:
| types | type description | example |
|---|---|---|
| string | strings of text | "hello" |
| number | any numeric type, including floating point number | 1.3, 3.141 |
| integer | integral numbers | 42, -5 |
| boolean | true or false | true |
| array | analogous to the list or tuple type | ["a", "b", "c"] |
| object | analogous to the dict type | {"key": "value"} |
- Note that the root object must be
objecttype. - Arrays: If you need to extract multiple values for the same key, you can use the
arraytype. In{"type": "array"}, the"items"keyword must be specified to define the values. - Objects: To define multiple properties under a key, you can use the object type. In
{"type": "object"}, the"properties"keyword must follow to define the structure. Additionally, the object type can be used as the items of an array to represent table structures. An example is shown below:
Schema design best practices
- Use clear key names and descriptions: Providing clear and descriptive key names and descriptions significantly improves the accuracy of data extraction.
- Avoid vauge or overly generic key names: Use specific terms where applicable, and include concise descriptions that explain the purpose and expected values of each key.
Schema design restrictions
Note that when you manually design a schema, there are some restrictions involved.
- In a
schema, total string length of all property names and definition names cannot exceed 10,000 characters. - Up to 100 object properties and 15,000 characters are allowed in synchronous API.
- Up to 5000 object properties and 120,000 characters are allowed in asynchronous API.
- First-level properties must be of type string, integer, number, or array (object type is not permitted).
- An array cannot contain items of arrays.
Universal extraction
No templates. No retraining. Upstage Universal IE API extracts structured data from any document typeβinstantly and accurately.
Location coordinates
Return the page coordinates of each extracted field with the location and location_granularity options, then parse and visualize them on the source document.