使用 AI.GENERATE_EMBEDDING 函式生成文字嵌入

AI.GENERATE_EMBEDDING 函式可將 BigQuery 資料表中的文字轉換為數值向量 (嵌入),擷取語意。您可以使用這些嵌入,直接在 SQL 中執行語意搜尋、推薦、分類和分群工作流程,不必匯出資料。

在本教學課程中,您將使用託管的 Gemini Enterprise Agent Platform 文字嵌入模型,建立 BigQuery ML 遠端模型、嵌入公開新聞報導,並依語意相似度為電影評論範例排名。如要在查詢中嵌入個別值,而不建立遠端模型,請改用純量 AI.EMBED 函式。如要使用自行部署的開放原始碼模型生成嵌入,請參閱「使用開放式模型生成文字嵌入」。

目標

  • 建立 BigQuery 資料集和 Cloud 資源連結。
  • 將權限授予連線的服務帳戶。
  • 在 gemini-embedding-001 嵌入模型上建立 BigQuery ML 遠端模型。
  • 使用 AI.GENERATE_EMBEDDING 函式,從公開資料集生成文件嵌入。
  • 使用 VECTOR_SEARCH 函式,依語意相似度為文字排序。

費用

在本文件中,您會使用下列 Cloud de Confiance by S3NS計費元件:

  • BigQuery ML: You incur costs for the data that you process in BigQuery.
  • Agent Platform: You incur costs for calls to the Agent Platform model that's represented by the remote model.

詳情請參閱 BigQuery 定價和 Agent Platform 定價。

事前準備

  1. In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  2. 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.

  3. Verify that billing is enabled for your Cloud de Confiance project.

  4. Enable the BigQuery, BigQuery Connection, and Agent Platform API APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. 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.

    Enable the APIs

必要的角色

如要取得完成本教學課程所需的權限,請要求管理員授予您下列 IAM 角色:

如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

這些預先定義的角色具備完成本教學課程所需的權限。如要查看確切的必要權限,請展開「Required permissions」(必要權限) 部分:

所需權限

您必須具備下列權限,才能完成本教學課程:

  • 建立資料集:bigquery.datasets.create
  • 建立、委派及使用連線:bigquery.connections.*
  • 設定服務帳戶權限:
    • resourcemanager.projects.getIamPolicy
    • resourcemanager.projects.setIamPolicy
  • 建立模型並執行推論:
    • bigquery.jobs.create
    • bigquery.models.create
    • bigquery.models.getData
    • bigquery.models.updateData
    • bigquery.models.updateMetadata
  • 查詢資料表資料:bigquery.tables.getData

您或許還可透過自訂角色或其他預先定義的角色取得這些權限。

建立資料集

如要建立 BigQuery 資料集,請選取下列其中一個選項:

控制台

  1. 前往 Cloud de Confiance 控制台的「BigQuery」頁面。

    前往「BigQuery」

  2. 點選左側窗格中的 「Explorer」。

    醒目顯示的「Explorer」窗格按鈕。

    如果沒有看到左側窗格,請按一下 「Expand left pane」(展開左側窗格),開啟窗格。

  3. 在「Explorer」中展開專案,然後點選「資料集」。

  4. 在「Datasets」(資料集) 頁面,按一下「Create dataset」(建立資料集)。

  5. 在「建立資料集」窗格中,執行下列操作:

    • 在「Dataset ID」(資料集 ID) 中輸入 bqml_tutorial。

    • 在「資料位置」部分,選取「US」。

    其餘設定均保留預設值。

  6. 點選「建立資料集」。

bq

如要建立新的資料集,請使用 bq mk --dataset 指令。

  1. 建立名為 bqml_tutorial 的資料集,並將資料位置設為 US:

    bq mk --dataset \
      --location=US \
      --description "BigQuery ML tutorial dataset." \
      bqml_tutorial
  2. 確認資料集已建立:

    bq ls

API

使用定義的資料集資源呼叫 datasets.insert 方法:

{
  "datasetReference": {
     "datasetId": "bqml_tutorial"
  }
}

建立連線

在建立資料集的 US 多區域中,建立 Cloud 資源連結,然後取得連結的服務帳戶。如果您已設定預設連線,或具備 BigQuery 管理員 (roles/bigquery.admin) 角色,則可略過建立連線的步驟,直接在 CREATE MODEL 陳述式中指定 DEFAULT。

選取下列選項之一:

控制台

  1. 前往「BigQuery」頁面。

    前往「BigQuery」

  2. 點選左側窗格中的 「Explorer」。

    醒目顯示的「Explorer」窗格按鈕。

    如果沒有看到左側窗格,請按一下 「Expand left pane」(展開左側窗格),開啟窗格。

  3. 在「Explorer」窗格中展開專案名稱,然後點選「Connections」(連線)。

  4. 在「Connections」(連線) 頁面,按一下「Create connection」(建立連線)。

  5. 在「連線類型」部分,選擇「Vertex AI 遠端模型、遠端函式、BigLake 和 Spanner (Cloud 資源)」。

  6. 在「連線 ID」欄位中,輸入連線名稱。

  7. 在「位置類型」部分,選取連線位置。連線應與其他資源 (例如資料集) 位於相同位置。

  8. 點選「建立連線」。

  9. 點選「前往連線」。

  10. 在「連線資訊」窗格中,複製服務帳戶 ID,以便在後續步驟中使用。

SQL

使用 CREATE CONNECTION 陳述式:

  1. 前往 Cloud de Confiance 控制台的「BigQuery」頁面。

    前往「BigQuery」

  2. 在查詢編輯器中輸入下列陳述式:

    CREATE CONNECTION [IF NOT EXISTS] `CONNECTION_NAME`
    OPTIONS (
      connection_type = "CLOUD_RESOURCE",
      friendly_name = "FRIENDLY_NAME",
      description = "DESCRIPTION"
      );

    替換下列內容:

    • CONNECTION_NAME:連線名稱,格式為 PROJECT_ID.LOCATION.CONNECTION_ID、LOCATION.CONNECTION_ID 或 CONNECTION_ID。如果省略專案或位置,系統會根據執行陳述式的專案和位置推斷。
    • FRIENDLY_NAME (選用):連線的描述性名稱。
    • DESCRIPTION (選用):連線說明。

  3. 按一下「 執行」。

如要進一步瞭解如何執行查詢,請參閱「執行互動式查詢」。

bq

  1. 在指令列環境中建立連線:

    bq mk --connection --location=REGION --project_id=PROJECT_ID \
        --connection_type=CLOUD_RESOURCE CONNECTION_ID

    --project_id 參數會覆寫預設專案。

    更改下列內容:

    • REGION:連線區域
    • PROJECT_ID:您的 Cloud de Confiance 專案 ID
    • CONNECTION_ID:連線 ID

    建立連線資源時,BigQuery 會建立專屬的系統服務帳戶,並與連線建立關聯。

    疑難排解:如果收到下列連線錯誤訊息,請更新 Google Cloud SDK:

    Flags parsing error: flag --connection_type=CLOUD_RESOURCE: value should be one of...
    
  2. 擷取並複製服務帳戶 ID,以便在後續步驟中使用:

    bq show --connection PROJECT_ID.REGION.CONNECTION_ID

    輸出結果會與下列內容相似:

    name                          properties
    1234.REGION.CONNECTION_ID     {"serviceAccountId": "connection-1234-9u56h9@gcp-sa-bigquery-condel.s3ns-system.iam.gserviceaccount.com"}
    

Python

在試用這個範例之前,請先按照「使用用戶端程式庫的 Vertex AI 快速入門導覽課程」中的 Python 設定操作說明進行操作。詳情請參閱 Vertex AI Python API 參考文件。

如要向 Vertex AI 進行驗證,請設定應用程式預設憑證。詳情請參閱「設定用戶端程式庫的驗證機制」。

執行程式碼範例前,請將 GOOGLE_CLOUD_UNIVERSE_DOMAIN 環境變數設為 s3nsapis.fr。

import google.api_core.exceptions
from google.cloud import bigquery_connection_v1

client = bigquery_connection_v1.ConnectionServiceClient()


def create_connection(
    project_id: str,
    location: str,
    connection_id: str,
):
    """Creates a BigQuery connection to a Cloud Resource.

    Cloud Resource connection creates a service account which can then be
    granted access to other Google Cloud resources for federated queries.

    Args:
        project_id: The Google Cloud project ID.
        location: The location of the connection (for example, "us-central1").
        connection_id: The ID of the connection to create.
    """

    parent = client.common_location_path(project_id, location)

    connection = bigquery_connection_v1.Connection(
        friendly_name="Example Connection",
        description="A sample connection for a Cloud Resource.",
        cloud_resource=bigquery_connection_v1.CloudResourceProperties(),
    )

    try:
        created_connection = client.create_connection(
            parent=parent, connection_id=connection_id, connection=connection
        )
        print(f"Successfully created connection: {created_connection.name}")
        print(f"Friendly name: {created_connection.friendly_name}")
        print(
            f"Service Account: {created_connection.cloud_resource.service_account_id}"
        )

    except google.api_core.exceptions.AlreadyExists:
        print(f"Connection with ID '{connection_id}' already exists.")
        print("Please use a different connection ID.")
    except Exception as e:
        print(f"An unexpected error occurred while creating the connection: {e}")

Node.js

在試用這個範例之前,請先按照「使用用戶端程式庫的 Vertex AI 快速入門導覽課程」中的 Node.js 設定操作說明進行操作。詳情請參閱 Vertex AI Node.js API 參考文件。

如要向 Vertex AI 進行驗證,請設定應用程式預設憑證。詳情請參閱「設定用戶端程式庫的驗證機制」。

執行程式碼範例前,請將 GOOGLE_CLOUD_UNIVERSE_DOMAIN 環境變數設為 s3nsapis.fr。

const {ConnectionServiceClient} =
  require('@google-cloud/bigquery-connection').v1;
const {status} = require('@grpc/grpc-js');

const client = new ConnectionServiceClient();

/**
 * Creates a new BigQuery connection to a Cloud Resource.
 *
 * A Cloud Resource connection creates a service account that can be granted access
 * to other Google Cloud resources.
 *
 * @param {string} projectId The Google Cloud project ID. for example, 'example-project-id'
 * @param {string} location The location of the project to create the connection in. for example, 'us-central1'
 * @param {string} connectionId The ID of the connection to create. for example, 'example-connection-id'
 */
async function createConnection(projectId, location, connectionId) {
  const parent = client.locationPath(projectId, location);

  const connection = {
    friendlyName: 'Example Connection',
    description: 'A sample connection for a Cloud Resource',
    // The service account for this cloudResource will be created by the API.
    // Its ID will be available in the response.
    cloudResource: {},
  };

  const request = {
    parent,
    connectionId,
    connection,
  };

  try {
    const [response] = await client.createConnection(request);

    console.log(`Successfully created connection: ${response.name}`);
    console.log(`Friendly name: ${response.friendlyName}`);

    console.log(`Service Account: ${response.cloudResource.serviceAccountId}`);
  } catch (err) {
    if (err.code === status.ALREADY_EXISTS) {
      console.log(`Connection '${connectionId}' already exists.`);
    } else {
      console.error(`Error creating connection: ${err.message}`);
    }
  }
}

Java

在試用這個範例之前,請先按照「使用用戶端程式庫的 Vertex AI 快速入門導覽課程」中的 Java 設定操作說明進行操作。詳情請參閱 Vertex AI Java API 參考文件。

如要向 Vertex AI 進行驗證,請設定應用程式預設憑證。詳情請參閱「設定用戶端程式庫的驗證機制」。

執行程式碼範例前,請將 GOOGLE_CLOUD_UNIVERSE_DOMAIN 環境變數設為 s3nsapis.fr。

import com.google.api.gax.rpc.AlreadyExistsException;
import com.google.api.gax.rpc.ApiException;
import com.google.cloud.bigquery.connection.v1.CloudResourceProperties;
import com.google.cloud.bigquery.connection.v1.Connection;
import com.google.cloud.bigquery.connection.v1.CreateConnectionRequest;
import com.google.cloud.bigquery.connection.v1.LocationName;
import com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient;
import java.io.IOException;

public class CreateConnection {

  /**
   * Creates a BigQuery connection to a Cloud Resource. A Cloud Resource connection provisions a
   * service account that can be granted access to other Google Cloud resources for federated
   * queries.
   *
   * @param projectId The Google Cloud project ID (for example, "example-project-id").
   * @param location The geographic location of the connection (for example, "us-central1").
   * @param connectionId The ID of the connection to create (for example, "example-connection-id").
   */
  public static void createConnection(String projectId, String location, String connectionId) {
    LocationName parent = LocationName.of(projectId, location);

    // CloudResourceProperties provisions a managed Google Cloud service account on creation.
    CloudResourceProperties cloudResourceProperties = CloudResourceProperties.newBuilder().build();
    Connection connection =
        Connection.newBuilder()
            .setFriendlyName("Example Connection")
            .setDescription("Cloud Resource connection for federated queries.")
            .setCloudResource(cloudResourceProperties)
            .build();

    CreateConnectionRequest request =
        CreateConnectionRequest.newBuilder()
            .setParent(parent.toString())
            .setConnectionId(connectionId)
            .setConnection(connection)
            .build();

    try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
      Connection response = client.createConnection(request);

      System.out.printf("Successfully created connection: %s%n", response.getName());
      System.out.printf("Friendly name: %s%n", response.getFriendlyName());
      System.out.printf(
          "Service Account: %s%n", response.getCloudResource().getServiceAccountId());
    } catch (AlreadyExistsException err) {
      System.err.printf(
          "error: connection '%s' already exists in location '%s' for project '%s': %s%n",
          connectionId, location, projectId, err.getMessage());
    } catch (ApiException | IOException err) {
      System.err.printf(
          "error: failed to create connection '%s' in location '%s' for project '%s': %s%n",
          connectionId, location, projectId, err.getMessage());
    }
  }

Terraform

使用 google_bigquery_connection 資源。

如要向 BigQuery 進行驗證,請設定應用程式預設憑證。詳情請參閱「設定用戶端程式庫的驗證機制」。

下列範例會在 US 區域中建立名為 my_cloud_resource_connection 的 Cloud 資源連結:


# This queries the provider for project information.
data "google_project" "default" {}

# This creates a cloud resource connection in the US region named my_cloud_resource_connection.
# Note: The cloud resource nested object has only one output field - serviceAccountId.
resource "google_bigquery_connection" "default" {
  connection_id = "my_cloud_resource_connection"
  project       = data.google_project.default.project_id
  location      = "US"
  cloud_resource {}
}

如要在 Cloud de Confiance 專案中套用 Terraform 設定,請完成下列各節的步驟。

準備 Cloud Shell

  1. 啟動 Cloud Shell。
  2. 設定要套用 Terraform 設定的預設 Cloud de Confiance 專案。

    每個專案只需執行這個指令一次,而且可以在任何目錄中執行。

    export GOOGLE_CLOUD_PROJECT=PROJECT_ID

    如果您在 Terraform 設定檔中設定明確的值,環境變數就會遭到覆寫。

準備目錄

每個 Terraform 設定檔都必須有自己的目錄 (也稱為「根模組」)。

  1. 在 Cloud Shell 中建立目錄,並在該目錄中建立新檔案。檔案名稱必須有 .tf 副檔名,例如 main.tf。在本教學課程中,這個檔案稱為 main.tf。
    mkdir DIRECTORY && cd DIRECTORY && touch main.tf
  2. 如果您正在按照教學課程操作,可以複製每個章節或步驟中的程式碼範例。

    將程式碼範例複製到新建立的 main.tf。

    您也可以從 GitHub 複製程式碼。如果 Terraform 程式碼片段是端對端解決方案的一部分,建議您採用這種做法。

  3. 請查看並修改範例參數,以便套用至您的環境。
  4. 儲存變更。
  5. 初始化 Terraform。每個目錄只需執行一次這項操作。
    terraform init

    如要使用最新版 Google 供應商,可以視需要加入 -upgrade 選項:

    terraform init -upgrade

套用變更

  1. 查看設定,確認 Terraform 要建立或更新的資源符合預期:
    terraform plan

    視需要修正設定。

  2. 執行下列指令,並在提示中輸入 yes,套用 Terraform 設定:
    terraform apply

    等待 Terraform 顯示「Apply complete!」訊息。

  3. 開啟 Cloud de Confiance 專案即可查看結果。在 Cloud de Confiance 控制台的 UI 中前往資源,確認 Terraform 已建立或更新資源。

將權限授予連線的服務帳戶

將 Agent Platform 使用者 (roles/aiplatform.user) 角色授予連線的服務帳戶。您必須在「事前準備」一節中建立或選取的專案,授予這個角色。在其他專案中授予角色會導致錯誤 bqcx-1234567890-xxxx@gcp-sa-bigquery-condel.s3ns-system.iam.gserviceaccount.com does not have the permission to access resource。

如要授予角色,請按照下列步驟操作:

  1. 前往「IAM & Admin」(IAM 與管理) 頁面。

    前往「IAM & Admin」(IAM 與管理) 頁面

  2. 按一下「Grant Access」(授予存取權)。

  3. 在「新增主體」欄位,輸入先前複製的服務帳戶 ID。

  4. 在「選取角色」欄位中,搜尋「Agent Platform 使用者」角色。

  5. 按一下「儲存」。

建立遠端模型

使用 CREATE MODEL 陳述式建立遠端模型,代表託管的 Agent Platform gemini-embedding-001 文字嵌入模型:

  1. 前往 Cloud de Confiance 控制台的「BigQuery」頁面。

    前往「BigQuery」

  2. 在查詢編輯器中執行下列陳述式:

    CREATE OR REPLACE MODEL `bqml_tutorial.embedding_model`
      REMOTE WITH CONNECTION `LOCATION.CONNECTION_ID`
      OPTIONS (ENDPOINT = 'gemini-embedding-001');

    更改下列內容:

    • <var>LOCATION</var>:連線位置,例如在 US 多區域建立連線,則為 us。
    • <var>CONNECTION_ID</var>:BigQuery 連線的 ID。在 Cloud de Confiance 控制台查看連線詳細資料時,這個值會顯示在「Connection ID」(連線 ID) 完整 ID 的最後一個區段,例如 projects/myproject/locations/us/connections/myconnection 中的 myconnection。如果使用預設連線,請將 `<var>LOCATION</var>.<var>CONNECTION_ID</var>` 替換為 DEFAULT。

    查詢會在幾秒內完成,之後 embedding_model 模型就會顯示在 bqml_tutorial 資料集中。由於查詢使用 CREATE MODEL 陳述式,因此沒有查詢結果。

生成嵌入項目

使用 AI.GENERATE_EMBEDDING 函式,從 bigquery-public-data.bbc_news.fulltext 公開資料表嵌入新聞報導。輸入查詢必須在名為 content 的 STRING 欄中提供要嵌入的文字。為搜尋文件生成嵌入時,請將 task_type 設為 'RETRIEVAL_DOCUMENT',並加入 title 欄,協助模型生成品質更高的文件嵌入。如要瞭解其他工作類型和選用參數 (例如 output_dimensionality),請參閱「AI.GENERATE_EMBEDDING 語法」和「選擇嵌入工作類型」。

  1. 前往 Cloud de Confiance 控制台的「BigQuery」頁面。

    前往「BigQuery」

  2. 在查詢編輯器中執行下列陳述式,為五篇新聞報導生成嵌入:

    SELECT
      title,
      content,
      embedding,
      statistics,
      status
    FROM
      AI.GENERATE_EMBEDDING(
        MODEL `bqml_tutorial.embedding_model`,
        (
          SELECT
            title,
            body AS content
          FROM
            `bigquery-public-data.bbc_news.fulltext`
          LIMIT 5
        ),
        STRUCT('RETRIEVAL_DOCUMENT' AS task_type)
      );

    輸出結果會與下列內容相似:

    +-------------------------------+------------------------------------+-----------------------+----------------------------------------+--------+
    | title                         | content                            | embedding             | statistics                             | status |
    +-------------------------------+------------------------------------+-----------------------+----------------------------------------+--------+
    | DVD copy protection...        | DVDs will be harder to copy thanks | -0.015901241451501846 | {"token_count":385,"truncated":false}  |        |
    |                               | to new anti-piracy measures...     | -0.001598291913978755 |                                        |        |
    |                               |                                    | ...                   |                                        |        |
    +-------------------------------+------------------------------------+-----------------------+----------------------------------------+--------+
    | Mobile games come of age...   | The BBC News website takes a look  | -0.00565318763256073  | {"token_count":1051,"truncated":false} |        |
    | fall                          | at how games on mobile phones...   | -0.02261657640337944  |                                        |        |
    |                               |                                    | ...                   |                                        |        |
    +-------------------------------+------------------------------------+-----------------------+----------------------------------------+--------+
    | ...                           | ...                                | ...                   | ...                                    | ...    |
    +-------------------------------+------------------------------------+-----------------------+----------------------------------------+--------+
    

    輸出內容包含輸入資料欄和下列資料欄:

    • embedding:包含生成嵌入向量的 ARRAY<FLOAT64> 值 (gemini-embedding-001 預設為 3072 維度)。
    • statistics:JSON 值,用於回報輸入 token_count,以及輸入文字是否為 truncated。
    • status:STRING 值,要求成功時為空白,如果該列的要求失敗,則包含錯誤詳細資料。

依語意相似度為文字排名

生成嵌入後,您可以使用 VECTOR_SEARCH 函式比較嵌入,找出語意相似的項目。餘弦距離值越小,表示語意相似度越高。如要進一步瞭解向量搜尋和向量索引,請參閱「向量搜尋簡介」。

  1. 前往 Cloud de Confiance 控制台的「BigQuery」頁面。

    前往「BigQuery」

  2. 在查詢編輯器中,執行下列多陳述式查詢,將四則範例電影評論的嵌入儲存至臨時資料表,然後依據與查詢 "This movie was average" 的餘弦距離排序:

    CREATE TEMPORARY TABLE movie_review_embeddings AS (
      SELECT *
      FROM
        AI.GENERATE_EMBEDDING(
          MODEL `bqml_tutorial.embedding_model`,
          (
            SELECT 'This movie was fantastic' AS content
            UNION ALL
            SELECT "This was the best movie I've ever seen!!" AS content
            UNION ALL
            SELECT 'This movie was just okay...' AS content
            UNION ALL
            SELECT 'This movie was terrible.' AS content
          )
        )
    );
    
    WITH
      average_review_embedding AS (
        SELECT embedding
        FROM
          AI.GENERATE_EMBEDDING(
            MODEL `bqml_tutorial.embedding_model`,
            (SELECT 'This movie was average' AS content)
          )
      )
    SELECT
      base.content AS content,
      distance AS distance_to_average_review
    FROM
      VECTOR_SEARCH(
        TABLE movie_review_embeddings,
        'embedding',
        (SELECT embedding FROM average_review_embedding),
        distance_type => 'COSINE'
      )
    ORDER BY distance_to_average_review;

    輸出結果會與下列內容相似:

    +------------------------------------------+----------------------------+
    | content                                  | distance_to_average_review |
    +------------------------------------------+----------------------------+
    | This movie was just okay...              | 0.062789813467745592       |
    | This movie was fantastic                 | 0.18579561313064263        |
    | This movie was terrible.                 | 0.35707466240930985        |
    | This was the best movie I've ever seen!! | 0.41844932504542975        |
    +------------------------------------------+----------------------------+
    

    輸出內容顯示,評論 "This movie was just okay..." 與查詢 "This movie was average" 的語意最接近,而 "This was the best movie I've ever seen!!" 的語意最遠。

清除所用資源

為避免因為本教學課程所用資源,導致系統向 Google Cloud 收取費用,請刪除含有相關資源的專案,或者保留專案但刪除個別資源。

刪除專案

    刪除 Cloud de Confiance 專案:

    gcloud projects delete PROJECT_ID

刪除個別資源

如要重複使用專案,請刪除您為本教學課程建立的資源:

控制台

  1. 前往 Cloud de Confiance 控制台的「BigQuery」頁面。

    前往「BigQuery」

  2. 刪除 bqml_tutorial 資料集,這也會刪除遠端模型:

    1. 在「Explorer」窗格中展開專案,然後按一下「Datasets」(資料集)。

    2. 在「Datasets」(資料集) 清單中,按一下 bqml_tutorial。

    3. 在詳細資料窗格中,按一下「 刪除」。

    4. 在「Delete dataset」(刪除資料集) 對話方塊中,按一下「Delete」(刪除)。

  3. 如果您為本教學課程建立了連線,請刪除該連線:

    1. 在「Explorer」窗格中展開專案,然後按一下「Connections」(連線)。

    2. 在「Connections」(連線) 清單中,按一下您建立的連線。

    3. 在詳細資料窗格中,按一下「 刪除」。

    4. 在「Delete connection」(刪除連線) 對話方塊中輸入 delete,然後按一下「Delete」(刪除)。

gcloud

  1. 刪除 bqml_tutorial 資料集和遠端模型:

    bq rm --dataset --recursive bqml_tutorial
  2. 如果您為本教學課程建立了連線,請刪除該連線:

    bq rm --connection \
    PROJECT_ID.LOCATION.CONNECTION_ID

    更改下列內容:

    • <var>PROJECT_ID</var>:您的 Cloud de Confiance by S3NS 專案 ID。
    • <var>LOCATION</var>:連線位置。
    • <var>CONNECTION_ID</var>:連線 ID。

後續步驟