カスタム レコメンデーションを使ってみる

ユーザーが閲覧中のコンテンツに類似したコンテンツを提案できる最新のカスタム レコメンデーション アプリを、独自のデータで手軽に構築できます。

このチュートリアルでは、構造化データ用のカスタム レコメンデーション アプリを作成する方法について説明します。ここでは、構造化データは Cloud Storage バケットから取り込まれ、NDJSON 形式になっています。

このチュートリアルに進む前に、始める前にの手順が完了していることを確認してください。


このタスクを Google Cloud コンソールで直接行う際の順を追ったガイダンスについては、「ガイドを表示」をクリックしてください。

ガイドを表示


始める前に

  1. 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.
  2. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Vertex AI Search (Discovery Engine), Cloud Storage APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  5. Make sure that you have the following role or roles on the project: Discovery Engine Admin

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      IAM に移動
    2. プロジェクトを選択します。
    3. [ アクセスを許可] をクリックします。
    4. [新しいプリンシパル] フィールドに、ユーザー ID を入力します。 これは通常、Google アカウントのメールアドレスです。

    5. [ロールを選択] リストでロールを選択します。
    6. 追加のロールを付与するには、 [別のロールを追加] をクリックして各ロールを追加します。
    7. [保存] をクリックします。
  6. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. Verify that billing is enabled for your Google Cloud project.

  8. Enable the Vertex AI Search (Discovery Engine), Cloud Storage APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  9. Make sure that you have the following role or roles on the project: Discovery Engine Admin

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      IAM に移動
    2. プロジェクトを選択します。
    3. [ アクセスを許可] をクリックします。
    4. [新しいプリンシパル] フィールドに、ユーザー ID を入力します。 これは通常、Google アカウントのメールアドレスです。

    5. [ロールを選択] リストでロールを選択します。
    6. 追加のロールを付与するには、 [別のロールを追加] をクリックして各ロールを追加します。
    7. [保存] をクリックします。
  10. Vertex AI Search を有効にする

    1. Google Cloud コンソールで、[AI Applications] ページに移動します。

      AI アプリケーション

    2. 省略可: [モデルの入力と回答の選択的サンプリングを Google に許可する] をクリックします。

    3. [続行して API を有効化] をクリックします。

    データストアを作成

    この手順では、データストアの作成と、提供されたサンプルデータのアップロードについて説明します。

    1. [データストア] ページに移動します。

    2. [データストアを作成] をクリックします。

    3. [データソースを選択] ページで、[Cloud Storage] を選択します。

    4. [Cloud Storage からデータをインポート] ページで、[構造化データ(JSONL)] を選択します。

    5. [ファイル] をクリックします。

    6. gs:// フィールドに次の値を入力します。

      cloud-samples-data/gen-app-builder/search/kaggle_movies/movie_metadata.ndjson
      

      この Cloud Storage バケットには、Kaggle から提供される NDJSON 形式の映画のファイルが格納されています。

    7. [続行] をクリックします。

    8. 次のようにキー プロパティを割り当てます。

      フィールド名 キーのプロパティ
      homepage uri
      overview description

      [次へ]をクリックします

    9. データストアの名前を入力してから、[作成] をクリックします。

    10. データストアの名前をクリックします。

    11. [データ] ページで [アクティビティ] タブに移動し、データの取り込みステータスを確認します。インポート プロセスが完了すると、[ステータス] 列に [インポートが完了しました] と表示されます。このデータセットの場合、インポートの完了までに通常 2~3 分かかります。[インポートが完了しました] と表示されない場合は、[更新] をクリックする必要があります。

    12. [ドキュメント] タブをクリックして、インポートしたドキュメントを確認します。

    アプリを作成する

    次に、レコメンデーション アプリを作成し、先ほど作成したデータストアをリンクします。

    1. [アプリ] ページに移動します。

    2. [アプリを作成] をクリックします。

    3. [アプリの作成] ページの [レコメンデーション エンジン] で [作成] をクリックします。

    4. [アプリ名] フィールドに、アプリの名前を入力します。アプリ名の下にアプリ ID が表示されます。

    5. [続行] をクリックします。

    6. データストアのリストで、前に作成したデータストアを選択します。

    7. [作成] をクリックします。

    アプリをプレビューする

    1. ナビゲーション メニューで [プレビュー] をクリックし、アプリをテストします。

    2. 「ここでレコメンデーション エンジンをプレビューできます。エンジンを準備しています。しばらくしてから再度ご確認ください」というメッセージが表示された場合は、しばらく待ってからページを定期的に更新してください。データのプレビューが表示されるまで数時間または翌日まで待つ必要がある場合があります。

    3. [ドキュメント ID] フィールドをクリックします。ドキュメント ID のリストが表示されます。

    4. レコメンデーションの対象となるドキュメントのドキュメント ID をクリックします。または、ドキュメント ID を [ドキュメント ID] フィールドに入力します。

    5. [レコメンデーションを表示] をクリックします。おすすめのドキュメントのリストが表示されます。

    6. ドキュメントをクリックすると、ドキュメントの詳細が表示されます。

    アプリをデプロイする

    アプリをデプロイするためのレコメンデーション ウィジェットはありません。デプロイ前にアプリをテストするには、以下の手順を行います。

    1. [データ] ページに移動して、ドキュメントの ID をコピーします。

    2. [統合] ページに移動します。このページには、REST API の servingConfigs.recommend メソッドのサンプル コマンドが含まれます。

    3. 先ほどコピーしたドキュメント ID を [ドキュメント ID] フィールドに貼り付けます。

    4. [ユーザー Pseudo ID] 欄はそのままにします。

    5. サンプル リクエストをコピーして、Cloud Shell で実行します。

      結果は、選択したドキュメントに基づくおすすめドキュメントの ID です。

    レコメンデーション アプリをウェブアプリに統合する方法については、アプリのレコメンデーションを取得するで、C#、Go、Java、Node.js、PHP、Ruby のコードサンプルをご覧ください。

    クリーンアップ

    このページで使用したリソースについて、 Google Cloud アカウントに課金されないようにするには、次の手順を実施します。

    1. Google Cloud の料金が余分に発生しないようにするために、不要なプロジェクトをGoogle Cloud console で削除します。
    2. Vertex AI Search の学習用に新しいプロジェクトを作成し、そのプロジェクトが不要になった場合は、プロジェクトを削除します。
    3. 既存の Google Cloud プロジェクトを使用した場合は、作成したリソースを削除して、アカウントに課金されないようにします。詳細については、アプリを削除するをご覧ください。
    4. Vertex AI Search を無効にするの手順に沿って操作します。

    次のステップ