以用戶端事件資料改善預先訓練模型

Cloud Talent Solution 服務能為您的職缺搜尋體驗增添機器學習技術,突破一般關鍵字搜尋方法的限制,向求職者傳回高品質的搜尋結果。CTS 不必經過設定,直接就能將關聯性模型和職缺/技能本體套用到您的職缺詳細資料。您可以根據求職者的活動記錄用戶端事件,藉此提升求職者搜尋結果的準確度。

使用 createClientEventRequest 記錄用戶端事件

求職者執行特定動作時,您可以使用 Job Search 記錄該項動作。舉例來說,與服務進行互動的求職者或其他實體已在畫面上看見工作或工作清單,例如以壓縮或剪輯格式呈現的搜尋結果清單。您可以將 IMPRESSION 事件傳送至 Cloud Talent Solution,藉此提供搜尋相關資訊和求職者會看見的結果。求職者為了查看完整工作說明而點選某項工作搜尋結果時,您可以傳送 VIEW 事件,記錄求職者對所選職缺感興趣。

以下範例說明如何使用 API 將訊息傳送至 Cloud Talent Solution。與服務互動的求職者或其他實體已在畫面上看見工作或工作清單,例如以壓縮或剪輯格式呈現的搜尋結果清單。這個事件通常與求職者在單一頁面中查看工作清單有關。

Go

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Go API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

import (
	"context"
	"fmt"
	"io"
	"time"

	talent "cloud.google.com/go/talent/apiv4beta1"
	"cloud.google.com/go/talent/apiv4beta1/talentpb"
	"github.com/golang/protobuf/ptypes"
)

// createClientEvent creates a client event.
func createClientEvent(w io.Writer, projectID string, requestID string, eventID string, relatedJobNames []string) (*talentpb.ClientEvent, error) {
	ctx := context.Background()

	// Create an eventService client.
	c, err := talent.NewEventClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("talent.NewEventClient: %w", err)
	}
	defer c.Close()

	createTime, _ := ptypes.TimestampProto(time.Now())
	clientEventToCreate := &talentpb.ClientEvent{
		RequestId:  requestID,
		EventId:    eventID,
		CreateTime: createTime,
		Event: &talentpb.ClientEvent_JobEvent{
			JobEvent: &talentpb.JobEvent{
				Type: talentpb.JobEvent_VIEW,
				Jobs: relatedJobNames,
			},
		},
	}

	// Construct a createJob request.
	req := &talentpb.CreateClientEventRequest{
		Parent:      fmt.Sprintf("projects/%s", projectID),
		ClientEvent: clientEventToCreate,
	}

	resp, err := c.CreateClientEvent(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("CreateClientEvent: %w", err)
	}

	fmt.Fprintf(w, "Client event created: %v\n", resp.GetEvent())

	return resp, nil
}

Java

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Java API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


import com.google.cloud.talent.v4beta1.ClientEvent;
import com.google.cloud.talent.v4beta1.CreateClientEventRequest;
import com.google.cloud.talent.v4beta1.EventServiceClient;
import com.google.cloud.talent.v4beta1.JobEvent;
import com.google.cloud.talent.v4beta1.TenantName;
import com.google.protobuf.Timestamp;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class JobSearchCreateClientEvent {

  public static void createClientEvent() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String requestId = "your-req-id-from-response-metadata";
    String eventId = "your-unique-identifier-id";
    createClientEvent(projectId, tenantId, requestId, eventId);
  }

  // Creates a client event.
  public static void createClientEvent(
      String projectId, String tenantId, String requestId, String eventId) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (EventServiceClient eventServiceClient = EventServiceClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);

      // The timestamp of the event as seconds of UTC time since Unix epoch
      // For more information on how to create google.protobuf.Timestamps
      // See:
      // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto
      long seconds = 3L;
      Timestamp createTime = Timestamp.newBuilder().setSeconds(seconds).build();

      // The type of event attributed to the behavior of the end user
      JobEvent.JobEventType type = JobEvent.JobEventType.VIEW;

      // List of job names associated with this event
      String jobsElement = "projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]";
      String jobsElement2 = "projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]";

      List<String> jobs = Arrays.asList(jobsElement, jobsElement2);
      JobEvent jobEvent = JobEvent.newBuilder().setType(type).addAllJobs(jobs).build();
      ClientEvent clientEvent =
          ClientEvent.newBuilder()
              .setRequestId(requestId)
              .setEventId(eventId)
              .setCreateTime(createTime)
              .setJobEvent(jobEvent)
              .build();
      CreateClientEventRequest request =
          CreateClientEventRequest.newBuilder()
              .setParent(parent.toString())
              .setClientEvent(clientEvent)
              .build();
      ClientEvent response = eventServiceClient.createClientEvent(request);
      System.out.println("Created client event. ");
      System.out.println(response.toString());
    }
  }
}

Node.js

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Node.js API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


const talent = require('@google-cloud/talent').v4;

/**
 * Creates a client event
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenant
 * @param requestId {string} A unique ID generated in the API responses.
 * Value should be set to the request_id from an API response.
 * @param eventId {string} A unique identifier, generated by the client application
 */
function sampleCreateClientEvent(projectId, tenantId, requestId, eventId) {
  const client = new talent.EventServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const requestId = '[request_id from ResponseMetadata]';
  // const eventId = '[Set this to a unique identifier]';
  const formattedParent = client.tenantPath(projectId, tenantId);

  // The timestamp of the event as seconds of UTC time since Unix epoch
  // For more information on how to create google.protobuf.Timestamps
  // See: https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto
  const seconds = 0;
  const createTime = {
    seconds: seconds,
  };

  // The type of event attributed to the behavior of the end user
  const type = 'VIEW';

  // List of job names associated with this event
  const jobsElement = 'projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]';
  const jobsElement2 =
    'projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]';
  const jobs = [jobsElement, jobsElement2];
  const jobEvent = {
    type: type,
    jobs: jobs,
  };
  const clientEvent = {
    requestId: requestId,
    eventId: eventId,
    createTime: createTime,
    jobEvent: jobEvent,
  };
  const request = {
    parent: formattedParent,
    clientEvent: clientEvent,
  };
  client
    .createClientEvent(request)
    .then(responses => {
      const response = responses[0];
      console.log('Created client event');
      console.log(`Response: ${response}`);
    })
    .catch(err => {
      console.error(err);
    });
}

Python

如要瞭解如何安裝及使用 CTS 的用戶端程式庫,請參閱 CTS 用戶端程式庫。 詳情請參閱 CTS Python API 參考說明文件

如要向 CTS 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


from google.cloud import talent
from google.cloud.talent import enums


def create_client_event(project_id, tenant_id, request_id, event_id):
    """
    Creates a client event

    Args:
      project_id Your Google Cloud Project ID
      tenant_id Identifier of the Tenant
      request_id A unique ID generated in the API responses.
      Value should be set to the request_id from an API response.
      event_id A unique identifier, generated by the client application
    """

    client = talent.EventServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # request_id = '[request_id from ResponseMetadata]'
    # event_id = '[Set this to a unique identifier]'

    if isinstance(project_id, bytes):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, bytes):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(request_id, bytes):
        request_id = request_id.decode("utf-8")
    if isinstance(event_id, bytes):
        event_id = event_id.decode("utf-8")
    parent = f"projects/{project_id}/tenants/{tenant_id}"

    # The timestamp of the event as seconds of UTC time since Unix epoch
    # For more information on how to create google.protobuf.Timestamps
    # See:
    # https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto
    seconds = 0
    create_time = {"seconds": seconds}

    # The type of event attributed to the behavior of the end user
    type_ = enums.JobEvent.JobEventType.VIEW

    # List of job names associated with this event
    jobs_element = "projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]"
    jobs_element_2 = "projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]"
    jobs = [jobs_element, jobs_element_2]
    job_event = {"type": type_, "jobs": jobs}
    client_event = {
        "request_id": request_id,
        "event_id": event_id,
        "create_time": create_time,
        "job_event": job_event,
    }

    response = client.create_client_event(parent=parent, client_event=client_event)
    print(response)

活動訊息

必填欄位:

  • eventId (由客戶定義):每一個傳送至 Cloud Talent Solution 的訊息都必須要有唯一的 eventId。最佳做法是在定義這個欄位時加入時間戳記,確保不會出現重複。這個欄位的長度上限為 255 個字元。

  • requestId:搜尋回應物件傳回的 requestId 值。這個值對特定 SearchJobsRequest API 呼叫來說是唯一的。 源自原始搜尋 IMPRESSION 事件的所有後續訊息都會使用這個值。執行新的 SearchJobsRequest API 呼叫時 (例如:求職者前往結果的下一頁),requestId 會跟著改變。

  • createTime 事件的時間戳記 (採用時間戳記格式,精確度達奈秒單位)。這個時間戳記應反映出實際發生事件的時間,而不是傳送訊息的時間。

  • 聯集欄位 eventjobEvent 物件會與求職功能搭配使用,並在求職者與服務互動時發出。

範例事件訊息

上述程式碼範例中的 API 呼叫應會產生下列格式的 JSON 訊息:

JSON

{
  "requestId": string,
  "eventId": string,
  "createTime": string,
  "eventNotes": string,

// Union field event can be only be a jobEvent: "jobEvent": { object (JobEvent) }, // End of list of possible types for union field event. }

情境和工作流程

以下兩例說明求職者搜尋、查看和應徵工作的各種情境。

工作流程 1

  1. 求職者執行搜尋。 例如:「產品經理 SF」

    服務將搜尋結果傳回給求職者。

    回傳給客戶伺服器的職缺搜尋回應物件包含一個唯一的 requestId (例如:8d2bdd5d-1361-42a5-a0fd-bd2b58b7d8fb:APAb7ISd4Sc5faibw2V5hTU/OoC2WAW5AA==)。 這個 requestId 將用於未來與這個特定 SearchJobsRequest API 呼叫相關的所有訊息。

    IMPRESSION 訊息傳送至 Cloud Talent Solution。

    範例事件訊息:

    {
      "requestId": "8d2bdd5d-1361-42a5-a0fd-bd2b58b7d8fb:APAb7ISd4Sc5faibw2V5hTU/OoC2WAW5AA==",
      "eventId": "ID1",
      "createTime": "2018-12-19T16:39:57-08:00",
      "jobEvent":
      {"type":"IMPRESSION",
      "jobs":["jobs/4000000000", "jobs/4000000001","jobs/4000000002",
      "jobs/4000000003", "jobs/4000000004"]}
    }
    
  2. 求職者選取一筆結果 (職缺公告) 來查看該職缺的完整詳細資料。

    將 VIEW 訊息傳送到 Cloud Talent Solution。

    {
      "requestId": "8d2bdd5d-1361-42a5-a0fd-bd2b58b7d8fb:APAb7ISd4Sc5faibw2V5hTU/OoC2WAW5AA==",
      "eventId": "ID2",
      "createTime": "2018-12-19T16:40:57-08:00",
      "jobEvent":
      {"type":"VIEW",
      "jobs":["jobs/4000000000"]}
    
    }
    
  3. 求職者應徵查看過的職缺公告。

    a. 如果服務將求職者重新導向至同一網域內的頁面 (內部應徵頁面),則將 APPLICATION_START 訊息傳送至 Cloud Talent Solution。

    {
      "requestId": "8d2bdd5d-1361-42a5-a0fd-bd2b58b7d8fb:APAb7ISd4Sc5faibw2V5hTU/OoC2WAW5AA==",
      "eventId": "ID3",
      "createTime": "2018-12-19T16:41:57-08:00",
      "jobEvent":
      {"type":"APPLICATION_START",
    "jobs":["jobs/4000000000"]}
    }
    

    b. 如果服務將求職者重新導向至外部應徵頁面,則將 APPLICATION_REDIRECT 訊息傳送至 Cloud Talent Solution。

    {
      "requestId": "8d2bdd5d-1361-42a5-a0fd-bd2b58b7d8fb:APAb7ISd4Sc5faibw2V5hTU/OoC2WAW5AA==",
      "eventId": "ID3",
      "createTime": "2018-12-19T16:41:57-08:00",
      "jobEvent":
      {"type":"APPLICATION_REDIRECT",
      "jobs":["jobs/4000000000"]}
    
    }
    
  4. 當求職者完成內部應徵,傳送 APPLICATION_FINISH 訊息至 Cloud Talent Solution:

    {
      "requestId": "8d2bdd5d-1361-42a5-a0fd-bd2b58b7d8fb:APAb7ISd4Sc5faibw2V5hTU/OoC2WAW5AA==",
      "eventId": "ID4",
      "createTime": "2018-12-19T16:43:57-08:00",
      "jobEvent":
      {"type":"APPLICATION_FINISH",
      "jobs":["jobs/4000000000"]}
    
    }
    
  5. 求職者回到搜尋結果,並繼續查看第 2 頁 (或者,求職者未點選任何職缺公告,直接查看第 2 頁)。

    將含有第 2 頁下一組結果的 IMPRESSION 訊息傳送至 Cloud Talent Solution。注意:SearchJobsRequest API 呼叫會產生搜尋結果第 2 頁,在此呼叫的回應中會產生新的 requestId。例如 99e5b99c-f1ba-4f85-b17d-ccf878f451f9:APAb7IRESj+/Hzwa3bBd54P3qPx2yOWm5w==

    {
      "requestId": "99e5b99c-f1ba-4f85-b17d-ccf878f451f9:APAb7IRESj+/Hzwa3bBd54P3qPx2yOWm5w==",
      "eventId": "ID5",
      "createTime": "2018-12-19T18:39:57-08:00",
      "jobEvent":
      {"type":"IMPRESSION",
      "jobs":["jobs/4000000005", "jobs/4000000006","jobs/4000000007",
      "jobs/4000000008", "jobs/4000000009"]}
    }
    
  6. 求職者繼續查看搜尋結果第 3 頁。

    將含有下一組結果的 IMPRESSION 訊息傳送至 Cloud Talent Solution。注意:服務會產生新的 requestId (例如 e2d2b916-78c3-4c65-aecc-d8452bc0afb0:APAb7IRvCsNPiRXYkgF8PN5e8BkbFzKOyg==)。

    {
      "requestId": "e2d2b916-78c3-4c65-aecc-d8452bc0afb0:APAb7IRvCsNPiRXYkgF8PN5e8BkbFzKOyg==",
      "eventId": "ID6",
      "createTime": "2018-12-19T16:41:57-08:00",
      "jobEvent":
      {"type":"IMPRESSION",
      "jobs":["jobs/4000000010", "jobs/4000000011","jobs/4000000012",
      "jobs/400000013", "jobs/4000000014"]}
    }
    

工作流程 2

  1. 求職者執行搜尋。 例如:「產品經理 SF」

    服務將搜尋結果傳回給求職者。

    職缺搜尋回應物件會包含一個唯一的 requestId (例如:a2179a9b-cf73-413e-8076-98af08b991ad)。這個 requestId 將用於未來與這個 SearchJobsRequest API 呼叫相關的所有訊息。

    將 IMPRESSION 訊息傳送至 Cloud Talent Solution。

    {
      "requestId": "a2179a9b-cf73-413e-8076-98af08b991ad",
      "eventId": "ID1",
      "createTime": "2018-12-19T16:39:57-08:00",
      "jobEvent":
      {"type":"IMPRESSION",
      "jobs":["jobs/4000000000", "jobs/4000000001","jobs/4000000002",
      "jobs/4000000003", "jobs/4000000004"]}
    }
    
  2. 求職者選取一筆結果 (職缺公告) 來查看該職缺的完整詳細資料。

    將 VIEW 訊息傳送到 Cloud Talent Solution。

    {
      "requestId": "8d2bdd5d-1361-42a5-a0fd-bd2b58b7d8fb:APAb7ISd4Sc5faibw2V5hTU/OoC2WAW5AA==",
      "eventId": "ID2",
      "createTime": "2018-12-19T16:40:57-08:00",
      "jobEvent":
      {"type":"VIEW",
      "jobs":["jobs/4000000000"]}
    }
    
  3. 求職者按一下滑鼠來應徵工作,如「APPLICATION_QUICK_SUBMISSION」所述。

    將含有下一組結果的 APPLICATION_QUICK_SUBMISSION 訊息傳送至 Cloud Talent Solution。

    {
      "requestId": "8d2bdd5d-1361-42a5-a0fd-bd2b58b7d8fb:APAb7ISd4Sc5faibw2V5hTU/OoC2WAW5AA==",
      "eventId": "ID3",
      "createTime": "2018-12-19T16:41:57-08:00",
      "jobEvent":
      {"type":"APPLICATION_QUICK_SUBMISSION",
      "jobs":["jobs/4000000000"]}
     }
    
  4. 求職者執行下列動作。

    a. 求職者回到搜尋結果頁面,直接從該頁面應徵工作。應徵程序所耗費的時間比 APPLICATION_QUICK_SUBMISSION 定義的還久,因為這是一個有多個步驟的應徵程序。

    將 APPLICATION_START_FROM_SERP 訊息傳送至 Cloud Talent Solution。

    {
      "requestId": "8d2bdd5d-1361-42a5-a0fd-bd2b58b7d8fb:APAb7ISd4Sc5faibw2V5hTU/OoC2WAW5AA==",
      "eventId": "ID4",
      "createTime": "2018-12-19T16:43:57-08:00",
      "jobEvent":
      {"type":"APPLICATION_START_FROM_SERP",
      "jobs":["jobs/4000000000"]}
    }
    

    b. 求職者完成應徵工作。 將 APPLICATION_FINISH 訊息傳送至 Cloud Talent Solution。

    {
      "requestId": "8d2bdd5d-1361-42a5-a0fd-bd2b58b7d8fb:APAb7ISd4Sc5faibw2V5hTU/OoC2WAW5AA==",
      "eventId": "ID5",
      "createTime": "2018-12-19T16:44:57-08:00",
      "jobEvent":
      {"type":"APPLICATION_FINISH",
      "jobs":["jobs/4000000000"]}
    }
    
  5. 求職者回到搜尋結果頁面,直接從該頁面應徵工作。應徵程序會將求職者重新導向至位於用戶群網站外的另一個網域 (外部應徵)。服務將無法追蹤應徵者的進度。

    將 APPLICATION_REDIRECT_FROM_SERP 訊息傳送至 Cloud Talent Solution。

    {
      "requestId": "8d2bdd5d-1361-42a5-a0fd-bd2b58b7d8fb:APAb7ISd4Sc5faibw2V5hTU/OoC2WAW5AA==",
      "eventId": "ID6",
      "createTime": "2018-12-19T16:45:57-08:00",
      "jobEvent":
      {"type":"APPLICATION_START_FROM_SERP",
      "jobs":["jobs/4000000001"]}
    }
    

    與 APPLICATION_REDIRECT 不同,服務重新轉送求職者時會位於職缺說明頁面。

驗證用戶端事件導入狀態

Cloud Talent Solution 提供自助式工具,可供您驗證用戶端事件的實作成果。如要進一步瞭解可用的自助式選項,請參閱管理工具