
시작하기 전에
- 실습에서는 정해진 기간 동안 Google Cloud 프로젝트와 리소스를 만듭니다.
- 실습에는 시간 제한이 있으며 일시중지 기능이 없습니다. 실습을 종료하면 처음부터 다시 시작해야 합니다.
- 화면 왼쪽 상단에서 실습 시작을 클릭하여 시작합니다.
Enable Document AI API
/ 20
Create a processor
/ 20
Create a label
/ 20
Build processor version using foundation model
/ 20
Train the model
/ 20
Document AI is a document understanding solution that takes unstructured data (e.g. documents, emails, invoices, forms, etc.) and makes the data easier to understand, analyze, and consume. The API provides structure through content classification, entity extraction, advanced searching, and more. With Document AI Workbench, you can achieve higher document processing accuracy by creating fully customized models using your own training data.
You can create Custom Document Extractors (CDE) that are specifically suited to your documents, and trained and evaluated with your data. This processor identifies and extracts entities from your documents. You can then use this trained processor on additional documents. You typically would use a CDE on documents that are all of one type, such as your institution's enrollment forms.
In this lab, you will learn how to use Document AI Workbench to create and train a Custom Document Extractor that processes W-2 (US tax form) documents. Most of the document preparation work has been done so that you can focus on the other mechanics of creating a CDE.
In this lab, you will learn how to perform the following tasks:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Before you can begin using Document AI, you must enable the API.
You should see something like this:
You should see something like this:
Now, you're ready to use the Document AI API!
You must first create an Custom Document Extractor processor to use for this lab.
You must first create a Form Parser processor instance to use in the Document AI Platform for this tutorial.
Click Create Custom Processor.
Inside the Custom Extractor box, click Create Processor.
Give it the name lab-custom-extractor
and select the region US (United States) on the list.
Click Create to create your processor.
Click Check my progress to verify the objective.
You are now on the Processor overview page of the processor you just created.
You can specify the fields you want the processor to extract and begin labeling documents.
Click on the Get started tab. The Fields menu appears.
Click Create New Field.
Enter the name for the field. Select the Data type and the Occurrence. Click Create. Refer to Define processor schema for detailed instructions on creating and editing a schema.
Create each of the following labels for the processor schema.
Name | Data Type | Occurrence |
---|---|---|
control_number |
Number | Optional multiple |
employees_social_security_number |
Number | Required multiple |
employer_identification_number |
Number | Required multiple |
employers_name_address_and_zip_code |
Address | Required multiple |
federal_income_tax_withheld |
Money | Required multiple |
social_security_tax_withheld |
Money | Required multiple |
social_security_wages |
Money | Required multiple |
wages_tips_other_compensation |
Money | Required multiple |
You can also create and use other types of labels in your processor schema, such as checkboxes and tabular entities. For example, the W-2 forms contain a Statutory employee, Retirement plan, and Third party sick pay check boxes that you could also add to the schema.
Click Check my progress to verify the objective.
Next, you upload a sample W-2 PDF and label it.
Click Upload Sample Document.
In the sidebar, click Import documents from Google Cloud Storage.
For this example, enter this bucket name in Source path. This links directly to one document.
You are redirected to the labeling console.
The process of selecting text in a document, and applying labels is known as annotation.
To use the suggested labels, hold the pointer over each label in the side panel, and click on the check mark to confirm the label is correct. You can edit the values if they do not match the document text.
In this example, the values at the bottom of the document were not identified automatically, so you will need to label them manually.
Use the Bounding box tool by default, or the Select text tool for multi-line values, to select the content and apply the label.
wages_tips_other_compensation
was selected with the Bounding box tool, and that label is applied.The labeled W-2 document should look like this when complete:
If needed, you can click Create New Field to add a new field to the schema from this page.
Click Mark as Labeled when you have finished annotating the document.
You are redirected to the Get started tab.
After labeling a single document, you can create a processor version using the pretrained foundation model to extract entities.
Under Call foundation model, click Create New Version.
Enter a name for your processor version, such as w2-foundation-model
.
Click Create. It takes a few minutes to create.
You test and evaluate this version later in the lab.
Click Check my progress to verify the objective.
The foundation model can accurately extract fields for a variety of document types, but you can also provide additional training data to improve the accuracy of the model for specific document structures.
Document AI Workbench uses the label names you define and previous annotations to make it quicker and easier to label documents at scale with auto-labeling.
Go to the Build page.
Click Import Documents.
In the sidebar, click Import documents from Google Cloud Storage.
Enter this bucket name in Source path. This contains unlabeled W-2 PDF files.
From the Data split list, select Auto-split. This automatically splits the documents to have 80% in the training set and 20% in the test set.
In the Auto-labeling section, select the Import with auto-labeling checkbox.
Select the foundation model processor version you just created to label the documents.
Click Import and wait for the documents to import. You can leave this page and return later.
You must verify the auto-labeled documents before you can use them for training or testing. Click Start Labeling to view the auto-labeled documents.
To use the suggested labels, hold the pointer over each annotation, and click on the check mark to confirm the label is correct. You can edit the values if they do not match the document text.
Click Mark as Labeled when you have finished annotating the document.
Repeat for each auto-labeled document. For this tutorial, you can skip any documents that were not successfully auto-labeled.
In this lab, you are provided with prelabeled data. If working on your own project, you have to determine how to label your data. Refer to Labeling options for more details. In general, more training data produces higher accuracy.
Go to the Build page.
Click Import Documents.
In the sidebar, click Import documents from Google Cloud Storage.
Enter the following path in Source path. This bucket contains prelabeled documents in the Document JSON format.
From the Data split list, select Auto-split. This automatically splits the documents to have 80% in the training set, and 20% in the test set. Leave Import with auto-labeling unchecked.
Click Import. Import takes several minutes.
(Optional) From the Build page, you can access the Manage Dataset console to view and edit all documents and labels in the dataset.
Now that you have sufficient training and test data, you can train the processor. Because training might take several hours, make sure you have set up the processor with the appropriate data and labels before you begin training.
Under Train a custom model, click Create New Version.
If Create New Version cannot be clicked, click on View Full Requirements for information about the dataset requirements.
In the Version name field, enter a name for this processor version, such as w2-custom-model
.
(Optional) Click View Label Stats to find information about the document labels. That can help determine your coverage. Click Close to return to the training setup.
Under Model training method, select Model based.
Click Start training.
(Optional) Click on the Deploy & Use tab. On this page, you can view the available processor versions and the training status of the new version.
Click Check my progress to verify the objective.
Great! You have now started training your first Custom Document AI Processor. Since the training job will take around a few hours, the lab will end here. If you are interested in learning about how to deploy and test the model version, you can check out the following section in the documentation.
Congratulations, in this lab you've successfully used Document AI to create a Custom Document Extraction processor, import a dataset, and label example documents. You can now use this processor to parse documents in this format just as you would for any Specialized Processor. You can also use this processor to label new documents using auto-labeling as well as use the Document AI Workbench to manage your training data and training jobs.
Check out the following resources to learn more about Document AI and the Python Client Library:
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated March 17, 2025
Lab Last Tested March 17, 2025
Copyright 2025 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
현재 이 콘텐츠를 이용할 수 없습니다
이용할 수 있게 되면 이메일로 알려드리겠습니다.
감사합니다
이용할 수 있게 되면 이메일로 알려드리겠습니다.
한 번에 실습 1개만 가능
모든 기존 실습을 종료하고 이 실습을 시작할지 확인하세요.