RikAI2-Extract
RikAI2-Extract leverages advanced document understanding to accurately extract the desired information from unstructured data (i.e. the provided documents).
With a JSON structure, a user can provide a set of questions or directions about any document in one API call, and the model will return a JSON output with the answers.
When following a specific JSON input, the model can provide confidence scores for each extracted field and bounding box coordinates to highlight the location of the extracted information on the document. Refer to the "Returning Confidence Scores and Bounding Boxes" section below for further information.
How to Use
To read about using the Demo UI for prompting the model, refer to the RikAI2-Extract Demo UI page.
The webhook
parameter is a webhook URL to send status updates and JSON response to. Click here to read more about using webhook
and webhookSendFull
parameters.
Input Question as a JSON
Differing from RikAI2, the question
parameter must be a JSON string or a dictionary.
Tip: When inputting a JSON string, follow these practices:
- Maintain a consistent style for indentation and spacing.
- Provide descriptions in the form of directions or question for each key to clarify its purpose and expected value.
Here is an example of a JSON, where the keys are Name
, Form
, Address
, and Hospitalization
:
{
"Last name": "What is the patient's last name?", // question
"First name": "Reply only Yes/No if there is a first name listed", // direction
"Address": "Address in all lowercase letters", // direction
"Hospitalization": "Return Yes/No if the patient is hospitalized" // direction, refers to a checkbox on the file
}
Returning Confidence Scores and Bounding Boxes
Within settings
, RikAI2-Extract has a returnConfidence
parameter which will return a confidence score and bounding boxes when set to true
. Refer to the Rikai2-Extract documentation on how to pass the settings parameter to the model. For best results when using the returnConfidence
parameter, the question must also follow these guidelines:
-
Do not use lists anywhere.
-
The key-value pair structure should not exceed two levels.
-
Every innermost dictionary must contain both
data
andpage_number
.
Here is an example of how you can nest keys in a two level structure for the question input while including data
and page_number
:
{
"example key no nested keys": { // level 1
"data": "", // optional question or direction, defers to the key if empty string provided
"page_number": 0 // set to 0, model will replace with page number of found value
},
"example key with nested keys": { // level 1
"nested key 1": { // level 2
"data": "", // optional question or direction, defers to the key if empty string provided
"page_number": 0 // set to 0, model will replace with page number of found value
},
"nested key 2": { // level 2
"data": "", // optional question or direction, defers to the key if empty string provided
"page_number": 0 // set to 0, model will replace with page number of found value
}
}
}
Here is another example following these three guidelines along with descriptors for each key:
{
"Medication": {
"directions": {
"data": "What is the medication's directions for use?",
"page_number": 0
},
"medication_strength": {
"data": "What is the medication strength?",
"page_number": 0
},
"diagnosis": {
"data": "What is the diagnosis?",
"page_number": 0
}
},
"Name": {
"patient": {
"data": "Return the patient's first name in all capital letters.",
"page_number": 0
},
"physician": {
"data": "Return the physician's last name in all lowercase letters.",
"page_number": 0
}
}
}
Input and Output
Documents may be uploaded using an URL input or through a base64 encoded string. Uploading a local file is supported via multi-part forms, which are available for the Document input, JSON response endpoint.
We also have a bulk upload endpoint to upload 1 or more files to the model for asynchronous processing.
Output is a JSON based on the user's configurations.