Google Cloud コンソールでドキュメント サマライザーを構築する
Document AI を使用してサマライザ プロセッサを作成し、ドキュメントのコンテンツを要約できます。出力は、長さと形式に基づいてカスタマイズできます。
生成されたエンティティの JSON 出力例を次に示します。
{
  "type": "summary",
  "mentionText": " Superconductivity is a phenomenon in which a material conducts
  electricity with no resistance. It was discovered in 1911 by Dutch physicist Heike
  Kamerlingh Onnes. In 1986, a new class of materials was discovered that can superconduct
  at much higher temperatures. These materials are called high-temperature superconductors.
  They have the potential to revolutionize the way we use electricity. However,
  high-temperature superconductors are still very expensive to produce. Scientists
  are working on ways to make them more affordable.",
  "normalizedValue": {
    "text": " Superconductivity is a phenomenon in which a material conducts
    electricity with no resistance. It was discovered in 1911 by Dutch physicist
    Heike Kamerlingh Onnes. In 1986, a new class of materials was discovered that
    can superconduct at much higher temperatures. These materials are called
    high-temperature superconductors. They have the potential to revolutionize
    the way we use electricity. However, high-temperature superconductors are
    still very expensive to produce. Scientists are working on ways to make
    them more affordable."
  }
}
手順
このクイックスタートでは、ドキュメントの要約プロセッサを作成し、処理するサンプル ドキュメントをアップロードして、要約の構造を調整するカスタム プロセッサ バージョンを作成します。
このタスクを Google Cloud コンソールで直接行う際の順を追ったガイダンスについては、「ガイドを表示」をクリックしてください。
始める前に
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
- 
    
    
      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
      (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
 
- 
  
    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 Service Usage Admin IAM role ( roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. 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
      (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
 
- 
  
    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 Service Usage Admin IAM role ( roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.
- Google Cloud コンソールの Document AI セクションで、[Workbench] ページに移動します。 
- [サマライザー] で、[ - プロセッサを作成 ] を選択します。  
- [プロセッサを作成] メニューで、プロセッサの名前を入力します(例: - quickstart-summarizer)。
- 最も近いリージョンを選択します。 
- [作成] を選択します。 
- [ - カスタマイズして構築 ] タブを選択して、プロセッサをテストします。  
- 
超伝導に関する Wikipedia ページを含む PDF ファイルです。 
- [ - テスト ドキュメントをアップロード ] を選択し、ダウンロードしたドキュメントを選択します。
- [サマリー] ページが表示されます。OCR で検出されたテキストとドキュメントのアノテーションを表示できます。   
- [長さ] と [形式] をそれぞれ [中] と [箇条書き] に設定し、[書き換え] を選択して結果を確認します。
- [カスタマイズして構築] ページに戻ります。 
- [要約の設定] は、前のページで最後に使用した値に設定されます。
- [ - 新しいバージョンを作成 ] をクリックして、指定した [要約の設定] でプロセッサ バージョンを作成します。
- プロセッサ バージョンの名前( - quickstart-moderate-bulletedなど)を入力し、[バージョンを作成] を選択します。
- [ - デプロイと使用 ] タブに移動して、デプロイのステータスを確認します。デプロイには数分かかります。
- デプロイされたバージョンを [ - デフォルト バージョン ] として設定するか、API でドキュメントを処理するときにバージョン ID を指定できます。
- Document AI API を使用するには: - 処理リクエストの送信のコードサンプルに沿って、オンラインおよびバッチ処理を使用します。- オンライン処理とバッチ処理でサポートされるページ数については、割り当てと上限をご覧ください。
 
- レスポンスを処理するにあるコードサンプルに沿って、プロセッサから要約レスポンスを取得します。
 
- 処理リクエストの送信のコードサンプルに沿って、オンラインおよびバッチ処理を使用します。
要約プロセッサを作成する
Google Cloud コンソールを使用して、要約プロセッサを作成します。詳細については、プロセッサの作成と管理をご覧ください。
これでプロセッサが作成されました。
プロセッサをテストする
作成したプロセッサの [プロセッサの概要] ページが表示されます。
         
 
  
プロセッサ バージョンをデプロイする
API でドキュメントを処理するときに特定の要約設定を使用する場合は、それらの設定に対応するプロセッサ バージョンを作成します。
Document AI を正しく使用して、ドキュメントからテキストを抽出し、要約できました。
クリーンアップ
このページで使用したリソースについて、 Google Cloud アカウントに課金されないようにするには、次の手順を実施します。
不要な Google Cloud 料金が発生しないようにするには、Google Cloud console を使用して、不要なプロセッサやプロジェクトを削除します。