PredictPreTrainModel

Updated at:

UIE extraction is a built-in capability used for general-purpose pre-labeling.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

documentautoml:PredictPreTrainModel

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

Content

string

No

The prediction content, in JSON string format. For UIE extraction, the format is {"query":"","schema":["",""]}, where query specifies the image URL and schema specifies the fields to extract.

{"query":"https://doc-automl-public.oss-cn-hangzhou.aliyuncs.com/demo/extractBill.png", "schema":["姓名", "住址"]}

ServiceVersion

string

No

The version of the pre-built capability service. The default value is V1.

V1

ServiceName

string

No

The name of the pre-built capability service. For UIE extraction, set this parameter to FormUIE.

FormUIE

BinaryToText

boolean

No

Set this parameter to false when the Content parameter contains an image URL. Set this parameter to true when the Body parameter contains Base64-encoded image data.

false

Body

string

No

The prediction content for a Base64-encoded image, in JSON string format. For UIE extraction, the format is {"query":"","schema":["",""]}, where query specifies the Base64-encoded image data and schema specifies the fields to extract.

{"query":"data:image/png;base64,xxxxx","schema":["姓名", "住址"]}

The BinaryToText parameter is optional.

Provide the image content using either the content parameter for an image URL or the body parameter for base64-encoded image data. When using the body parameter, you must also set BinaryToText to true.

Response elements

Element

Type

Description

Example

object

The response object.

RequestId

string

A unique identifier for the request.

29413C69-11EF-15CB-BE20-70D318E2F4E9

Code

integer

The request status. A value of 200 indicates that the request was successful.

200

Message

string

A message describing the request status. If the request fails, this parameter contains the error message.

success

Data

object

An object containing the extracted information.

{ "RequestId": "29413C69-11EF-15CB-BE20-70D318E2F4E9", "Message": "success", "Data": { "score": 1, "data": [ { "prob": 0.9138551354408264, "fieldWordRaw": "xx", "wordInfo": [ { "prob": 0.9138551354408264, "pos": [ { "x": 468, "y": 139 }, { "x": 476, "y": 139 }, { "x": 476, "y": 153 }, { "x": 468, "y": 153 } ], "word": "xx", "charInfo": [ { "prob": 0.99, "pos": [ { "x": 468, "y": 139 }, { "x": 471, "y": 139 }, { "x": 471, "y": 153 }, { "x": 468, "y": 153 } ], "word": "x" }, { "prob": 0.99, "pos": [ { "x": 473, "y": 139 }, { "x": 476, "y": 139 }, { "x": 476, "y": 153 }, { "x": 473, "y": 153 } ], "word": "x" } ] } ], "name": "姓名", "location": [ { "x": 468, "y": 139 }, { "x": 476, "y": 139 }, { "x": 476, "y": 153 }, { "x": 468, "y": 153 } ], "fieldWord": "xx" }, { "prob": 0.9594210982322693, "fieldWordRaw": "xxxxxxxxxxx", "wordInfo": [ { "prob": 0.9594210982322693, "pos": [ { "x": 168, "y": 164 }, { "x": 467, "y": 164 }, { "x": 467, "y": 239 }, { "x": 168, "y": 239 } ], "word": "xxxxxxxxxxx", "charInfo": [ { "prob": 0.99, "pos": [ { "x": 366, "y": 164 }, { "x": 383, "y": 164 }, { "x": 383, "y": 179 }, { "x": 366, "y": 179 } ], "word": "x" }, { "prob": 0.99, "pos": [ { "x": 384, "y": 164 }, { "x": 401, "y": 164 }, { "x": 401, "y": 179 }, { "x": 384, "y": 179 } ], "word": "x" }, { "prob": 0.99, "pos": [ { "x": 402, "y": 164 }, { "x": 414, "y": 164 }, { "x": 414, "y": 179 }, { "x": 402, "y": 179 } ], "word": "x" }, { "prob": 0.99, "pos": [ { "x": 418, "y": 164 }, { "x": 427, "y": 164 }, { "x": 427, "y": 179 }, { "x": 418, "y": 179 } ], "word": "x" }, { "prob": 0.99, "pos": [ { "x": 429, "y": 164 }, { "x": 438, "y": 164 }, { "x": 438, "y": 179 }, { "x": 429, "y": 179 } ], "word": "x" }, { "prob": 0.99, "pos": [ { "x": 439, "y": 164 }, { "x": 448, "y": 164 }, { "x": 448, "y": 179 }, { "x": 439, "y": 179 } ], "word": "x" }, { "prob": 0.99, "pos": [ { "x": 450, "y": 164 }, { "x": 467, "y": 164 }, { "x": 467, "y": 179 }, { "x": 450, "y": 179 } ], "word": "x" }, { "prob": 0.99, "pos": [ { "x": 168, "y": 224 }, { "x": 180, "y": 224 }, { "x": 180, "y": 239 }, { "x": 168, "y": 239 } ], "word": "x" }, { "prob": 0.99, "pos": [ { "x": 180, "y": 224 }, { "x": 192, "y": 224 }, { "x": 192, "y": 239 }, { "x": 180, "y": 239 } ], "word": "x" }, { "prob": 0.99, "pos": [ { "x": 195, "y": 224 }, { "x": 209, "y": 224 }, { "x": 209, "y": 239 }, { "x": 195, "y": 239 } ], "word": "1" }, { "prob": 0.99, "pos": [ { "x": 211, "y": 224 }, { "x": 223, "y": 224 }, { "x": 223, "y": 239 }, { "x": 211, "y": 239 } ], "word": "7" }, { "prob": 0.99, "pos": [ { "x": 224, "y": 224 }, { "x": 236, "y": 224 }, { "x": 236, "y": 239 }, { "x": 224, "y": 239 } ], "word": "2" }, { "prob": 0.99, "pos": [ { "x": 237, "y": 224 }, { "x": 249, "y": 224 }, { "x": 249, "y": 239 }, { "x": 237, "y": 239 } ], "word": "7" }, { "prob": 0.99, "pos": [ { "x": 253, "y": 224 }, { "x": 270, "y": 224 }, { "x": 270, "y": 239 }, { "x": 253, "y": 239 } ], "word": "x" } ] } ], "name": "住址", "location": [ { "x": 168, "y": 164 }, { "x": 467, "y": 164 }, { "x": 467, "y": 239 }, { "x": 168, "y": 239 } ], "fieldWord": "xxxxxxxx" } ], "specificType": "formuie-anti", "classType": "preDefinedServer", "predictFile": "https://xxxx" }, "Code": 200 }

The Data object returned by the template service prediction API contains the following fields:
score: The overall confidence score for the prediction, ranging from 0.0 to 1.0.
data: An array of detailed prediction results returned by the model.
prob: The confidence score for a specific extracted item, ranging from 0.0 to 1.0.
name: The name of the extracted field, which is the key in a key-value pair.
fieldWord: The value of the extracted field.
location: The location of the extracted item on the page, specified as an array of x and y coordinates that form a bounding box. A single coordinate is represented as { "x": 119, "y": 48 }.
wordInfo: Details of the extracted content, including the location of each character.
specificType: The algorithm type for the extraction. For example, formuie-anti indicates Universal Information Extraction (UIE).
classType: The service classification. For example, preDefinedServer indicates a pre-built capability.
predictFile: The prediction file URL, which expires in 60 minutes.









Examples

Success response

JSON format

{
  "RequestId": "29413C69-11EF-15CB-BE20-70D318E2F4E9",
  "Code": 200,
  "Message": "success",
  "Data": {
    "RequestId": "29413C69-11EF-15CB-BE20-70D318E2F4E9",
    "Message": "success",
    "Data": {
      "score": 1,
      "data": [
        {
          "prob": 0.9138551354408264,
          "fieldWordRaw": "xx",
          "wordInfo": [
            {
              "prob": 0.9138551354408264,
              "pos": [
                {
                  "x": 468,
                  "y": 139
                },
                {
                  "x": 476,
                  "y": 139
                },
                {
                  "x": 476,
                  "y": 153
                },
                {
                  "x": 468,
                  "y": 153
                }
              ],
              "word": "xx",
              "charInfo": [
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 468,
                      "y": 139
                    },
                    {
                      "x": 471,
                      "y": 139
                    },
                    {
                      "x": 471,
                      "y": 153
                    },
                    {
                      "x": 468,
                      "y": 153
                    }
                  ],
                  "word": "x"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 473,
                      "y": 139
                    },
                    {
                      "x": 476,
                      "y": 139
                    },
                    {
                      "x": 476,
                      "y": 153
                    },
                    {
                      "x": 473,
                      "y": 153
                    }
                  ],
                  "word": "x"
                }
              ]
            }
          ],
          "name": "姓名",
          "location": [
            {
              "x": 468,
              "y": 139
            },
            {
              "x": 476,
              "y": 139
            },
            {
              "x": 476,
              "y": 153
            },
            {
              "x": 468,
              "y": 153
            }
          ],
          "fieldWord": "xx"
        },
        {
          "prob": 0.9594210982322693,
          "fieldWordRaw": "xxxxxxxxxxx",
          "wordInfo": [
            {
              "prob": 0.9594210982322693,
              "pos": [
                {
                  "x": 168,
                  "y": 164
                },
                {
                  "x": 467,
                  "y": 164
                },
                {
                  "x": 467,
                  "y": 239
                },
                {
                  "x": 168,
                  "y": 239
                }
              ],
              "word": "xxxxxxxxxxx",
              "charInfo": [
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 366,
                      "y": 164
                    },
                    {
                      "x": 383,
                      "y": 164
                    },
                    {
                      "x": 383,
                      "y": 179
                    },
                    {
                      "x": 366,
                      "y": 179
                    }
                  ],
                  "word": "x"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 384,
                      "y": 164
                    },
                    {
                      "x": 401,
                      "y": 164
                    },
                    {
                      "x": 401,
                      "y": 179
                    },
                    {
                      "x": 384,
                      "y": 179
                    }
                  ],
                  "word": "x"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 402,
                      "y": 164
                    },
                    {
                      "x": 414,
                      "y": 164
                    },
                    {
                      "x": 414,
                      "y": 179
                    },
                    {
                      "x": 402,
                      "y": 179
                    }
                  ],
                  "word": "x"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 418,
                      "y": 164
                    },
                    {
                      "x": 427,
                      "y": 164
                    },
                    {
                      "x": 427,
                      "y": 179
                    },
                    {
                      "x": 418,
                      "y": 179
                    }
                  ],
                  "word": "x"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 429,
                      "y": 164
                    },
                    {
                      "x": 438,
                      "y": 164
                    },
                    {
                      "x": 438,
                      "y": 179
                    },
                    {
                      "x": 429,
                      "y": 179
                    }
                  ],
                  "word": "x"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 439,
                      "y": 164
                    },
                    {
                      "x": 448,
                      "y": 164
                    },
                    {
                      "x": 448,
                      "y": 179
                    },
                    {
                      "x": 439,
                      "y": 179
                    }
                  ],
                  "word": "x"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 450,
                      "y": 164
                    },
                    {
                      "x": 467,
                      "y": 164
                    },
                    {
                      "x": 467,
                      "y": 179
                    },
                    {
                      "x": 450,
                      "y": 179
                    }
                  ],
                  "word": "x"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 168,
                      "y": 224
                    },
                    {
                      "x": 180,
                      "y": 224
                    },
                    {
                      "x": 180,
                      "y": 239
                    },
                    {
                      "x": 168,
                      "y": 239
                    }
                  ],
                  "word": "x"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 180,
                      "y": 224
                    },
                    {
                      "x": 192,
                      "y": 224
                    },
                    {
                      "x": 192,
                      "y": 239
                    },
                    {
                      "x": 180,
                      "y": 239
                    }
                  ],
                  "word": "x"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 195,
                      "y": 224
                    },
                    {
                      "x": 209,
                      "y": 224
                    },
                    {
                      "x": 209,
                      "y": 239
                    },
                    {
                      "x": 195,
                      "y": 239
                    }
                  ],
                  "word": "1"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 211,
                      "y": 224
                    },
                    {
                      "x": 223,
                      "y": 224
                    },
                    {
                      "x": 223,
                      "y": 239
                    },
                    {
                      "x": 211,
                      "y": 239
                    }
                  ],
                  "word": "7"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 224,
                      "y": 224
                    },
                    {
                      "x": 236,
                      "y": 224
                    },
                    {
                      "x": 236,
                      "y": 239
                    },
                    {
                      "x": 224,
                      "y": 239
                    }
                  ],
                  "word": "2"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 237,
                      "y": 224
                    },
                    {
                      "x": 249,
                      "y": 224
                    },
                    {
                      "x": 249,
                      "y": 239
                    },
                    {
                      "x": 237,
                      "y": 239
                    }
                  ],
                  "word": "7"
                },
                {
                  "prob": 0.99,
                  "pos": [
                    {
                      "x": 253,
                      "y": 224
                    },
                    {
                      "x": 270,
                      "y": 224
                    },
                    {
                      "x": 270,
                      "y": 239
                    },
                    {
                      "x": 253,
                      "y": 239
                    }
                  ],
                  "word": "x"
                }
              ]
            }
          ],
          "name": "住址",
          "location": [
            {
              "x": 168,
              "y": 164
            },
            {
              "x": 467,
              "y": 164
            },
            {
              "x": 467,
              "y": 239
            },
            {
              "x": 168,
              "y": 239
            }
          ],
          "fieldWord": "xxxxxxxx"
        }
      ],
      "specificType": "formuie-anti",
      "classType": "preDefinedServer",
      "predictFile": "https://xxxx"
    },
    "Code": 200
  }
}

Error codes

HTTP status code

Error code

Error message

Description

200 21002 模板预测超时
200 21003 模版预测失败
200 10001 参数出错
200 16001 未找到可预测的模型
200 13018 未找到模型信息
200 16004 指定模型不存在
200 23002 获取资源HTTP异常
200 11002 账号没有开通服务
200 19999 未知异常
200 50008 文件过大
200 50007 文件格式不支持
200 10005 服务不存在

See Error CodesError Codes for a complete list.

Release notes

See Release NotesRelease Notes for a complete list.