建立、使用及管理自訂文件分類器
您可以使用自訂分類器將文件分類。使用自己的文件和自訂類別,從頭開始建構。其生成式 AI 面向可進行少量樣本學習和微調。這些功能可以減少樣本數,並透過疊代型自動標籤功能修正錯誤,進而提高準確率。
自訂分類器涵蓋這三種一般用途。
- 預先訓練模型:使用預先訓練的生成式 AI 基礎模型,依據您提供的標籤快速將文件分類。
- 微調:使用您的資料和標籤訓練生成式 AI 基礎模型,提高準確率。
- 訓練自訂模型:使用您的資料和標籤,訓練非生成式 AI 自訂擷取器。
自訂分類器模型版本
預先發布版支援自訂分類器模型的可信度分數。為獲得最佳成效,請搭配微調模型使用。
| 模型版本 | 說明 | 發布版本 | 在美國/歐盟境內的機器學習處理作業 | 在美國/歐盟境內的微調作業 | 發布日期 |
|---|---|---|---|---|---|
pretrained-classifier-v1.5-2025-08-05 |
搭載 Gemini 2.5 Flash LLM,可用於正式環境,也包含進階 OCR 功能。這個預先訓練模型可直接使用,不必事先訓練,而且支援零樣本分類,並更有效支援通用類別。 | 穩定 | 是 | 美國、歐盟 (預先發布版) | 2025 年 8 月 5 日 |
pretrained-classifier-v1.6-2026-03-09 |
搭載 Gemini 3.1 Flash LLM 的候選版。 | 候選版 | 是 | 美國、歐盟 (預先發布版) | 2026 年 3 月 9 日 |
pretrained-classifier-v1.6-pro-2026-03-09 |
搭載 Gemini 3.1 Pro LLM 的候選版。 | 候選版 | 是 | 美國、歐盟 (預先發布版) | 2026 年 3 月 9 日 |
在 Google Cloud 控制台建立自訂分類器
您可以建立文件專屬的自訂分類器,並使用資料訓練及評估。這個處理器會根據使用者定義的類別集找出文件類別。完成訓練後,您可以使用該處理器分類其他文件。您通常會對不同類型的文件使用自訂分類器,識別完成後,將文件交由擷取處理器擷取實體。
如要瞭解建立及使用處理器的一般程序,請參閱「如何使用」一節。
您可以根據自己的工作流程自訂設定。
如要直接在 Google Cloud 控制台中,按照這項工作的逐步指南操作,請按一下「Guide me」(逐步引導):
事前準備
- 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Document AI, Cloud Storage APIs.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Document AI, Cloud Storage APIs.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.
必要的角色
如要取得建立自訂敏感內容類別的權限,請要求系統管理員授予您專案的下列 IAM 角色:
- Document AI 管理員 (
roles/documentai.admin) - 儲存空間管理員 (
roles/storage.admin)
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
建立處理器
操作步驟如下。
針對「custom document classifier」(自訂文件分類器),選取
「Create processor」(建立處理器) 。
在「Create processor」(建立處理器) 選單中,輸入處理器名稱,例如
my-custom-document-classifier。
請選取最近的區域。
選取 [Create] (建立)。系統會隨即顯示「Processor Details」(處理器詳細資料) 分頁。
設定資料集
為了訓練這個新處理器,您必須建立具有訓練和測試資料的資料集,以協助處理器識別您要分割和分類的文件。這個資料集需要新的位置。這可以是空白的 Cloud Storage bucket 或資料夾,也可以是內部代管位置。
顯示「Processor Details」(處理器詳細資料) 分頁後,您可以執行下列操作:
- 如要使用 Cloud Storage,請選取「Google-managed storage」(Google 代管的儲存空間)。
- 如要使用自己的儲存空間,以便使用客戶自行管理的加密金鑰 (CMEK),請選取「I'll specify my own storage location」(自行指定儲存空間位置),然後按照「建立資料集」中的程序操作。

將文件匯入資料集
接下來,請將文件匯入資料集。
在「Build」(建構) 分頁中,點選
「Import documents」(匯入文件) 。
選擇使用儲存空間 bucket 時,必須輸入 bucket 的「Source path」(來源路徑)。就這個訓練範例而言,請在
「Source path」(來源路徑) 中輸入這個 bucket 名稱。這樣就會直接連結至某份文件。