Creating a Custom Generative Model V2.0 (New)
The OCI Document Service features Key-Value Extraction powered by Large Multimodal Models (LMMs), offering enhanced accuracy and adaptability over conventional model-driven methods.
About
OCI Document service's key-value extraction uses multimodal reasoning to analyze both textual content and visual layouts, making it highly effective for handling documents with varied formats, templates, and structures. You can provide a schema outlining the required keys (fields) for extraction, enabling the service to adapt across different document types without the need for model retraining.
This large multimodal model (LMM)-powered approach shines in situations involving layout inconsistencies, irregular labeling, or scarce training data, circumstances where traditional template or model-based solutions often demand ongoing updates and upkeep.
Available Regions
You can create custom models for Generative large multimodal model (LMM)-based Key-Value extraction in the following OCI regions:
| Region Name | Location | Region Identifier | Region Key |
|---|---|---|---|
| Brazil East (Sao Paulo) | Sao Paulo |
sa-saopaulo-1
|
GRU
|
| Japan Central (Osaka) | Osaka |
ap-osaka-1
|
KIX
|
| UK South (London) | London |
uk-london-1
|
LHR
|
| US Midwest (Chicago) | Chicago |
us-chicago-1
|
ORD
|
Adding Permissions
Add permissions using IAM policies:
Creating a JSON File for Keys and Values
With generative extraction, you specify the information to be extracted by defining a schema. The schema acts as a set of instructions that describes the keys (fields) of interest and their expected values. Based on these instructions, the model identifies and extracts the values across documents with your specifics.
Here's an example JSON file for key-value extraction:
[
{
"key": "InvoiceId",
"dataType": "String",
"description": "A unique alphanumeric identifier assigned to the invoice. Usually labelled Invoice No., Inv #,
Bill Number and appears near the top of the invoice, often right after the text label."
},
{
"key": "InvoiceDate",
"description": "Date the invoice was issued. Common formats include DD-MM-YYYY or MM/DD/YYYY."
},
{
"key": "DueDate",
"description": ""
},
{
"key": "PurchaseOrder",
"description": ""
},
{
"key": "InvoiceTotal",
"description": "Total amount due. Exclude subtotals, taxes, and discounts.
Look for labels such as Grand Total, Amount Payable, or Balance Due near the bottom of the document."
},
{
"key": "TotalTax",
"description": ""
},
{
"key": "SubTotal",
"description": ""
},
{
"key": "AmountDue",
"description": ""
},
{
"key": "PreviousUnpaidBalance",
"description": ""
}
]Using System Keys and Custom Keys
Document Understanding provides a set of predefined system keys. These keys are tuned to work with various document types and layouts. You can reuse these keys as-is, or alter their description.
Start with system-provided keys
Begin by using the predefined system key definitions and evaluate their performance on a representative sample of your documents. For a list of system-provided keys, see Key-Value Extraction.
- If the results meet the requirements, reuse the system-provided keys.
- You don't need to add descriptions for these keys.
Customize key descriptions when necessary
If a system-provided key doesn't fit the requirements, define a custom description based on the documents.
-
Tailor descriptions to document-specific terminology, layouts, and formatting patterns.
-
Follow the Best Practices for Custom Descriptions for the descriptions.
Best Practices for Custom Descriptions
Here are some best practices with examples for writing key descriptions:
Be explicit and unambiguous
Clearly distinguish between fields that might appear similar, such as different numeric identifiers.
Example
"key": "Invoice number"
"description": "A unique alphanumeric identifier assigned to the invoice.
Usually labeled Invoice No., Inv #, Bill Number and appears near the top of the invoice,
often right after the text label." Describe context and label variations
Generative models rely heavily on surrounding text and labels. Include common label variants.
Example
"key": "Company GST Number" "description": "Company GST number,
often labeled as GSTIN, GST No., or Tax ID. Usually appears
in the header with other business identifiers."Specify expected value formats
If the field follows a known format, explicitly state it.
Example
"key": "Invoice Date" "description": "Date the invoice was issued.
Common formats include DD-MM-YYYY or MM/DD/YYYY."Clarify what to exclude
Explicitly identify similar fields that you don't want extracted.
Example
"key": "Total Amount" "description": "Total amount due.
Exclude subtotals, taxes, and discounts.
Look for labels such as Grand Total, Amount Payable, or Balance Due near the bottom of the document."Include synonyms and label variations
Provide different labels to improve robustness across document variants.
Example
"key": "Customer Phone Number" "description": "Customer phone number.
A 10-digit numeric value labeled as Phone, Tel, Contact, or Mobile, typically adjacent to the
customer name or address."Add reference location hints
If documents follow consistent layouts, include relative position cues.
Example
"key": "Supplier Address" "description": "Supplier address
located under the business name in the top-left area of the first page." Include examples when helpful
Concrete examples improve extraction accuracy.
Example
"key": "Invoice Date" "description": "Invoice date,
for example 24-12-2025 or Dec 24, 2025.
Usually follows labels such as Date or Invoice Date."Be concise and precise
Prefer one clear descriptive sentence supplemented with essential constraints or examples.
Define fallback behavior
When applicable, specify how to infer values if the primary label is missing.
Example:
If Invoice Total is missing, use Total Amount Due instead.
Encode section awareness explicitly
For multi-section documents (such as forms), specify section context and field ordering.
Example
"key": "First Name" "description": "Person’s given name.
Appears under the Personal Information or Applicant Details section header.
Usually the first field in the section and appears before Last Name.
Might contain multiple words (for example, MaryAnn)."Handle multi-word and multi-line values
Explicitly allow multi-token or multi-line extraction when applicable.
Example
"key": "Address" "description": "Full residential address.
May span multiple consecutive lines within the same section.
Extract all adjacent address lines as a single value."Use negative guidance to avoid false positives
Explicitly state where values should not be extracted from.
Example
"key": "Applicant Name" "description": "Applicant name.
Do not extract names appearing in signature blocks, declaration sections,
or references to officials or witnesses."Handling fields without explicit labels
For implicit fields, rely on semantic role and layout cues:
-
Position relative to section headers
-
Ordering among nearby fields
-
Proximity to related labels
Example Phrases
- Appears immediately after…
- Located next to…
- Follows the section header…
Creating a Custom Generative Model
To create a custom model for key-value extraction using Generative AI, follow these steps:
Select Data
Create a Key-Value (KV) custom generative model using Document Understanding.
Train Model
Review
- Review the information you provided in the previous steps. You can make any changes, by selecting Previous or Edit.
- When you're happy with the selections, select Create and train.
Test the Model
- After the custom model creates, in the model detail page, navigate to the Analyze section.
- Upload a document from a local file or Object Storage to test the custom model.
- Select Analyze.
- Review the keys and their extracted values.
- If you're not happy with the results, for example, to add a key or to update a description, update your JSON file and repeat the previous steps.