カスタム レコメンデーションを使ってみる
ユーザーが閲覧中のコンテンツに類似したコンテンツを提案できる最新のカスタム レコメンデーション アプリを、独自のデータで手軽に構築できます。
このチュートリアルでは、構造化データ用のカスタム レコメンデーション アプリを作成する方法について説明します。ここでは、構造化データは Cloud Storage バケットから取り込まれ、NDJSON 形式になっています。
このチュートリアルに進む前に、始める前にの手順が完了していることを確認してください。
このタスクを 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 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 theserviceusage.services.enablepermission. Learn how to grant roles. -
Make sure that you have the following role or roles on the project: Discovery Engine Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
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.
- 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
-
In the Google Cloud console, go to the IAM page.
IAM に移動 - プロジェクトを選択します。
- [ アクセスを許可] をクリックします。
-
[新しいプリンシパル] フィールドに、ユーザー ID を入力します。 これは通常、Google アカウントのメールアドレスです。
- [ロールを選択] リストでロールを選択します。
- 追加のロールを付与するには、 [別のロールを追加] をクリックして各ロールを追加します。
- [保存] をクリックします。
-
-
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 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 theserviceusage.services.enablepermission. Learn how to grant roles. -
Make sure that you have the following role or roles on the project: Discovery Engine Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
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.
- 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
-
In the Google Cloud console, go to the IAM page.
IAM に移動 - プロジェクトを選択します。
- [ アクセスを許可] をクリックします。
-
[新しいプリンシパル] フィールドに、ユーザー ID を入力します。 これは通常、Google アカウントのメールアドレスです。
- [ロールを選択] リストでロールを選択します。
- 追加のロールを付与するには、 [別のロールを追加] をクリックして各ロールを追加します。
- [保存] をクリックします。
-
Google Cloud コンソールで、[AI Applications] ページに移動します。
省略可: [モデルの入力と回答の選択的サンプリングを Google に許可する] をクリックします。
[続行して API を有効化] をクリックします。
[
データストア ] ページに移動します。[
データストアを作成 ] をクリックします。[データソースを選択] ページで、[Cloud Storage] を選択します。
[Cloud Storage からデータをインポート] ページで、[構造化データ(JSONL)] を選択します。
[ファイル] をクリックします。
gs:// フィールドに次の値を入力します。
cloud-samples-data/gen-app-builder/search/kaggle_movies/movie_metadata.ndjson
この Cloud Storage バケットには、Kaggle から提供される NDJSON 形式の映画のファイルが格納されています。
[続行] をクリックします。
次のようにキー プロパティを割り当てます。
フィールド名 キーのプロパティ homepageurioverviewdescription[次へ]をクリックします
データストアの名前を入力してから、[作成] をクリックします。
データストアの名前をクリックします。
[データ] ページで [アクティビティ] タブに移動し、データの取り込みステータスを確認します。インポート プロセスが完了すると、[ステータス] 列に [インポートが完了しました] と表示されます。このデータセットの場合、インポートの完了までに通常 2~3 分かかります。[インポートが完了しました] と表示されない場合は、[更新] をクリックする必要があります。
[ドキュメント] タブをクリックして、インポートしたドキュメントを確認します。
[
アプリ ] ページに移動します。[
アプリを作成 ] をクリックします。[アプリの作成] ページの [レコメンデーション エンジン] で [作成] をクリックします。
[アプリ名] フィールドに、アプリの名前を入力します。アプリ名の下にアプリ ID が表示されます。
[続行] をクリックします。
データストアのリストで、前に作成したデータストアを選択します。
[作成] をクリックします。
ナビゲーション メニューで [
プレビュー ] をクリックし、アプリをテストします。「ここでレコメンデーション エンジンをプレビューできます。エンジンを準備しています。しばらくしてから再度ご確認ください」というメッセージが表示された場合は、しばらく待ってからページを定期的に更新してください。データのプレビューが表示されるまで数時間または翌日まで待つ必要がある場合があります。
[ドキュメント ID] フィールドをクリックします。ドキュメント ID のリストが表示されます。
レコメンデーションの対象となるドキュメントのドキュメント ID をクリックします。または、ドキュメント ID を [ドキュメント ID] フィールドに入力します。
[レコメンデーションを表示] をクリックします。おすすめのドキュメントのリストが表示されます。
ドキュメントをクリックすると、ドキュメントの詳細が表示されます。
[データ] ページに移動して、ドキュメントの ID をコピーします。
[統合] ページに移動します。このページには、REST API の
servingConfigs.recommendメソッドのサンプル コマンドが含まれます。先ほどコピーしたドキュメント ID を [ドキュメント ID] フィールドに貼り付けます。
[ユーザー Pseudo ID] 欄はそのままにします。
サンプル リクエストをコピーして、Cloud Shell で実行します。
結果は、選択したドキュメントに基づくおすすめドキュメントの ID です。
- Google Cloud の料金が余分に発生しないようにするために、不要なプロジェクトをGoogle Cloud console で削除します。
- Vertex AI Search の学習用に新しいプロジェクトを作成し、そのプロジェクトが不要になった場合は、プロジェクトを削除します。
- 既存の Google Cloud プロジェクトを使用した場合は、作成したリソースを削除して、アカウントに課金されないようにします。詳細については、アプリを削除するをご覧ください。
- Vertex AI Search を無効にするの手順に沿って操作します。
Vertex AI Search を有効にする
データストアを作成
この手順では、データストアの作成と、提供されたサンプルデータのアップロードについて説明します。
アプリを作成する
次に、レコメンデーション アプリを作成し、先ほど作成したデータストアをリンクします。
アプリをプレビューする
アプリをデプロイする
アプリをデプロイするためのレコメンデーション ウィジェットはありません。デプロイ前にアプリをテストするには、以下の手順を行います。
レコメンデーション アプリをウェブアプリに統合する方法については、アプリのレコメンデーションを取得するで、C#、Go、Java、Node.js、PHP、Ruby のコードサンプルをご覧ください。
クリーンアップ
このページで使用したリソースについて、 Google Cloud アカウントに課金されないようにするには、次の手順を実施します。