Introduction
-
Long document information extraction is a self-learning model task based on deep learning. It allows you to define custom extraction fields and provides a guided visual interface for data annotation and model training. This process enables high-precision information extraction from unstructured documents with various layouts.
-
With high-quality images and annotations from over 100 training samples, a fine-tuned model can achieve an accuracy of over 85%.
Benefits
-
High precision: Powered by Alibaba Cloud's robust pre-trained models, a fine-tuned mixed-layout model can achieve an accuracy of over 85%.
-
Few-shot learning: You only need to annotate a small amount of data to optimize and iterate on your model, which has strong generalization capabilities.
-
Low barrier to entry: The service is available out-of-the-box, with a user-friendly interface for rule configuration.
-
High efficiency: The intelligent pre-annotation feature and support for collaborative annotation significantly reduce the required time.
Use cases
-
High-performance model: Ideal for documents with simple styles and formats, such as those containing only titles and paragraphs. It supports PDF and image formats and is suitable for use cases like certificates, official documents, files, letters, and announcements.
-
Mixed-layout model: Designed for documents with rich styles and formats, including titles, paragraphs, tables, and forms. It supports PDF and image formats and is suitable for use cases like contracts, bidding documents, insurance policies, and engineering forms.
-
This feature is also suitable for long documents where continuous model optimization is required and a substantial amount of data (more than 20 samples) is available for training to improve performance.
Related links
-
OCR Self-learning: console
-
Development guide for long document information extraction model tasks: online trial, API reference (asynchronous call API reference), SDK documentation
Procedure
Watch this video for a walkthrough of the long document information extraction process:
The following diagram shows the workflow for creating a long document information extraction model. You need more than 20 images for training to create a model.

Step 1: Prepare data
In Data Center > Datasets, you can upload and manage the data required for your model task. Click Add Dataset, enter a name for the dataset, and upload your business data.
For a custom long document information extraction model, you need at least 50 training documents to achieve good recognition and extraction results.
Step 2: Annotate data
Data annotation involves three main steps: task creation, annotation, and quality check.
Go to Data Center > Annotation Tasks and click Create Annotation Task. Enter a Task Name and select a dataset or upload data directly under Upload Data. Then, proceed to Field Settings.
For example, add two fields, Party A's Name and Party B's Name, and select general as the field type for both.
Pre-annotation: If you enable OCR pre-annotation, the text within any box you draw during annotation will be automatically recognized, improving your efficiency.
Field library: The field library lets you reuse predefined fields for your annotation tasks.
Field Name: This is the external name for the recognition field, which corresponds to the name in the API. Field names must be globally unique.
Field Type: This defines the field's properties. Choosing the right field type can improve end-to-end recognition performance. You can choose from common field types or add your own custom types. If no post-processing is needed, select the general field type.
Annotation
In Data Center > Annotation Tasks, select a created task and click Annotate to go to the Data Annotation interface. In the annotation tool, use the Bounding Box Selection tool to draw a bounding box around a field you want to recognize, select the corresponding field name, and carefully check the automatically recognized text. After annotating all fields in all images, click Submit Task.
The quality of your annotated data (both the text and its location) directly affects the model's training performance and evaluation metrics.
You can skip images that are incorrect or cannot be annotated.
Quality check
To start a quality check, go to Data Center > Annotation Tasks and select a completed annotation task. The quality checker reviews all annotations, modifying or rejecting them as needed, before submitting the task.
The top of the quality check interface displays statistics such as progress, error count, and accuracy. The left side is the document preview area. The Bounding Box Selection Fields panel on the right lists all annotated fields and their recognized results, allowing you to review, edit, or delete each one. The Annotation History area at the bottom includes a Mark as Error button.
Step 3: Train and evaluate the model
Go to the Model Center and click Create Model. On the model creation screen, select the annotated results for your training and test sets, and fill in the basic information. After the model is created, training starts automatically.
Pre-trained models: Long document information extraction currently offers two model types: high-performance model and mixed-layout model.
High-performance model: Ideal for documents with simple styles and formats, such as those containing only titles and paragraphs. It supports PDF and image formats.
Mixed-layout model: Designed for documents with complex styles and formats, such as those including titles, paragraphs, tables, and forms. It supports PDF and image formats.
Training set: The data source used to train the model. You can only select datasets that have been annotated and have passed a quality check. A dataset selected as a test set cannot also be a training set. We recommend using at least 20 valid documents for model training.
Test set: The data source used to evaluate the model. You can only select datasets that have been annotated and have passed a quality check. A dataset selected as a training set cannot also be a test set.
Automatically use 1/10 of the training set as a test set: When this option is enabled, you do not need to select a test set because the system automatically reserves 10% of the training set for testing. The system ignores any manually uploaded test set if this option is enabled.
On the Model Training configuration page, the document preview area is on the left, and the field configuration area is on the right. Here, you can set the field type for each field, such as general.
Model training costs and estimated duration vary based on the task type and data quantity. The exact figures are displayed on the interface.
Training Duration: The time required for training depends on multiple factors, including data volume, annotation quality, and machine resources. For example, training on 60,000 characters using a V100 GPU takes about 1 minute.
After model training is complete, you can view the training duration, start and end times, and progress. The Service Parameter Configuration area includes parameters such as expected inference hardware, inference time (ms), maximum training duration (h), and computing specifications.
Algorithm evaluation metrics: Metrics are provided for two dimensions: overall metrics and field-specific metrics.
Overall metrics
-
Precision: In the test set, precision measures the proportion of predicted fields that perfectly match the ground truth annotation in both content and location.

-
Recall: In the test set, recall is the ratio of correctly predicted fields to the total number of actual fields that should have been predicted.

-
F1-score: The harmonic mean of precision and recall, providing a single score that balances both metrics.

Field-specific metrics
-
Precision: For a specific field, this is the ratio of correctly predicted instances to the total number of predicted instances of that field.

-
Recall: For a specific field, this is the ratio of correctly predicted instances to the total number of actual instances of that field.

-
F1-score: The harmonic mean of precision and recall for a specific field.

Step 4: Deploy the model
After the model is trained, go to Model Center > Model Details and click the Deploy button at the bottom of the page to start model deployment. After a brief deployment period, you can visually test the model in the online trial or call the service via the API.
After you publish and deploy the model service, see the API overview for information about using the service. You can also go to the online trial interface to test the model's performance.
OCR Self-learning has been commercially available since August 23, 2023. Model training is billed by duration, and model inference is billed per call. For more information, see OCR Self-learning Billing.
Tool: Field library
Field library: A tool in the Field Settings step that lets you pre-create and reuse fields across multiple annotation tasks. This reduces repetitive work and minimizes errors.
Modifying a field library does not affect any annotation tasks or models that have already been created.

