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.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Document AI, Cloud Storage APIs.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Document AI, Cloud Storage APIs.
要約プロセッサを作成する
Google Cloud コンソールを使用して、サマライザー プロセッサを作成します。詳細については、プロセッサの作成と管理をご覧ください。
Google Cloud コンソールの Document AI セクションで、[Workbench] ページに移動します。
[サマライザー] で、[
プロセッサを作成 ] を選択します。[プロセッサを作成] メニューで、プロセッサの名前を入力します(例:
quickstart-summarizer
)。最も近いリージョンを選択します。
[作成] を選択します。
これでプロセッサが作成されました。
プロセッサをテストする
作成したプロセッサの [プロセッサの概要] ページが表示されます。
[
カスタマイズして構築 ] タブを選択して、プロセッサをテストします。-
超伝導に関する Wikipedia ページを含む PDF ファイルです。
[
テスト ドキュメントをアップロード ] を選択し、ダウンロードしたドキュメントを選択します。[サマリー] ページが表示されます。OCR で検出されたテキストとドキュメントのアノテーションを表示できます。
[長さ] と [形式] をそれぞれ [中] と [箇条書き] に設定し、[書き換え] を選択して結果を確認します。[カスタマイズして構築] ページに戻ります。
プロセッサ バージョンをデプロイする
API でドキュメントを処理するときに特定の要約設定を使用する場合は、それらの設定に対応するプロセッサ バージョンを作成します。
[要約の設定] は、前のページで最後に使用した値に設定されます。[
新しいバージョンを作成 ] をクリックして、指定した [要約の設定] でプロセッサ バージョンを作成します。プロセッサ バージョンの名前(
quickstart-moderate-bulleted
など)を入力し、[バージョンを作成] を選択します。[
デプロイと使用 ] タブに移動して、デプロイのステータスを確認します。デプロイには数分かかります。デプロイされたバージョンを [
デフォルト バージョン ] として設定するか、API でドキュメントを処理するときにバージョン ID を指定できます。Document AI API を使用するには:
- 処理リクエストの送信のコードサンプルに沿って、オンラインおよびバッチ処理を使用します。
- オンライン処理とバッチ処理でサポートされるページ数については、割り当てと上限をご覧ください。
- レスポンスを処理するのコードサンプルに沿って、プロセッサから要約レスポンスを取得します。
- 処理リクエストの送信のコードサンプルに沿って、オンラインおよびバッチ処理を使用します。
Document AI を正しく使用して、ドキュメントからテキストを抽出し、要約できました。
クリーンアップ
このページで使用したリソースについて、 Google Cloud アカウントに課金されないようにするには、次の手順を行います。
不要な Google Cloud 料金が発生しないようにするには、Google Cloud コンソールを使用して、不要なプロセッサやプロジェクトを削除します。