1// Copyright 2021 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.cloud.retail.v2alpha; 18 19import "google/api/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/cloud/retail/v2alpha/common.proto"; 22import "google/protobuf/timestamp.proto"; 23 24option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; 25option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; 26option java_multiple_files = true; 27option java_outer_classname = "ModelProto"; 28option java_package = "com.google.cloud.retail.v2alpha"; 29option objc_class_prefix = "RETAIL"; 30option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; 31option ruby_package = "Google::Cloud::Retail::V2alpha"; 32 33// Metadata that describes the training and serving parameters of a 34// [Model][google.cloud.retail.v2alpha.Model]. A 35// [Model][google.cloud.retail.v2alpha.Model] can be associated with a 36// [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] and then queried 37// through the Predict API. 38message Model { 39 option (google.api.resource) = { 40 type: "retail.googleapis.com/Model" 41 pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}" 42 }; 43 44 // The PageOptimizationConfig for model training. 45 // 46 // This determines how many panels to optimize for, and which serving 47 // configs to consider for each panel. 48 // The purpose of this model is to optimize which 49 // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to show on which 50 // panels in way that optimizes the visitors shopping journey. 51 message PageOptimizationConfig { 52 // A candidate to consider for a given panel. Currently only 53 // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] are valid 54 // candidates. 55 message Candidate { 56 oneof candidate { 57 // This has to be a valid 58 // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] 59 // identifier. For example, for a ServingConfig with full name: 60 // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/my_candidate_config`, 61 // this would be `my_candidate_config`. 62 string serving_config_id = 1; 63 } 64 } 65 66 // An individual panel with a list of 67 // [ServingConfigs][google.cloud.retail.v2alpha.ServingConfig] to consider 68 // for it. 69 message Panel { 70 // Optional. The name to display for the panel. 71 string display_name = 1 [(google.api.field_behavior) = OPTIONAL]; 72 73 // Required. The candidates to consider on the panel. 74 repeated Candidate candidates = 2 75 [(google.api.field_behavior) = REQUIRED]; 76 77 // Required. The default candidate. If the model fails at serving time, 78 // we fall back to the default. 79 Candidate default_candidate = 3 [(google.api.field_behavior) = REQUIRED]; 80 } 81 82 // Restrictions of expected returned results. 83 enum Restriction { 84 // Unspecified value for restriction. 85 RESTRICTION_UNSPECIFIED = 0; 86 87 // Allow any [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to 88 // be show on any number of panels. 89 // 90 // Example: 91 // 92 // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity 93 // 94 // `Panel2 candidates`: home_page_ctr_no_diversity, 95 // home_page_ctr_diversity, 96 // pdp_cvr_no_diversity 97 // 98 // `Restriction` = NO_RESTRICTION 99 // 100 // `Valid combinations`: 101 // 102 // * <i> (pdp_ctr, home_page_ctr_no_diversity) 103 // * (pdp_ctr, home_page_ctr_diversity) 104 // * (pdp_ctr, pdp_cvr_no_diversity) 105 // * (pdp_cvr, home_page_ctr_no_diversity) 106 // * (pdp_cvr, home_page_ctr_diversity) 107 // * (pdp_cvr, pdp_cvr_no_diversity) 108 // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) 109 // * (home_page_ctr_no_diversity, home_page_ctr_diversity) 110 // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) </i> 111 // 112 // `Invalid combinations`: [] 113 NO_RESTRICTION = 1; 114 115 // Do not allow the same 116 // [ServingConfig.name][google.cloud.retail.v2alpha.ServingConfig.name] to 117 // be shown on multiple panels. 118 // 119 // Example: 120 // 121 // `Panel1 candidates`: <i> pdp_ctr, pdp_cvr, home_page_ctr_no_diversity 122 // </i> 123 // 124 // `Panel2 candidates`: <i> home_page_ctr_no_diversity, 125 // home_page_ctr_diversity_low, 126 // pdp_cvr_no_diversity </i> 127 // 128 // `Restriction` = `UNIQUE_SERVING_CONFIG_RESTRICTION` 129 // 130 // `Valid combinations`: 131 // 132 // * <i> (pdp_ctr, home_page_ctr_no_diversity) 133 // * (pdp_ctr, home_page_ctr_diversity_low) 134 // * (pdp_ctr, pdp_cvr_no_diversity) 135 // * (pdp_ctr, pdp_cvr_no_diversity) 136 // * (pdp_cvr, home_page_ctr_no_diversity) 137 // * (pdp_cvr, home_page_ctr_diversity_low) 138 // * (pdp_cvr, pdp_cvr_no_diversity) 139 // * (home_page_ctr_no_diversity, home_page_ctr_diversity_low) 140 // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) </i> 141 // 142 // `Invalid combinations`: 143 // 144 // * <i> (home_page_ctr_no_diversity, home_page_ctr_no_diversity) </i> 145 UNIQUE_SERVING_CONFIG_RESTRICTION = 2; 146 147 // Do not allow multiple 148 // [ServingConfigs][google.cloud.retail.v2alpha.ServingConfig] with same 149 // [Model.name][google.cloud.retail.v2alpha.Model.name] to be show on on 150 // different panels. 151 // 152 // Example: 153 // 154 // `Panel1 candidates`: <i> pdp_ctr, pdp_cvr, home_page_ctr_no_diversity 155 // </i> 156 // 157 // `Panel2 candidates`: <i> home_page_ctr_no_diversity, 158 // home_page_ctr_diversity_low, 159 // pdp_cvr_no_diversity </i> 160 // 161 // `Restriction` = `UNIQUE_MODEL_RESTRICTION` 162 // 163 // `Valid combinations`: 164 // 165 // * <i> (pdp_ctr, home_page_ctr_no_diversity) 166 // * (pdp_ctr, home_page_ctr_diversity) 167 // * (pdp_ctr, pdp_cvr_no_diversity) 168 // * (pdp_ctr, pdp_cvr_no_diversity) 169 // * (pdp_cvr, home_page_ctr_no_diversity) 170 // * (pdp_cvr, home_page_ctr_diversity_low) 171 // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) </i> 172 // 173 // `Invalid combinations`: 174 // 175 // * <i> (home_page_ctr_no_diversity, home_page_ctr_no_diversity) 176 // * (pdp_cvr, pdp_cvr_no_diversity) </i> 177 UNIQUE_MODEL_RESTRICTION = 3; 178 179 // Do not allow multiple 180 // [ServingConfigs][google.cloud.retail.v2alpha.ServingConfig] with same 181 // [Model.type][google.cloud.retail.v2alpha.Model.type] to be shown on 182 // different panels. 183 // 184 // Example: 185 // 186 // `Panel1 candidates`: <i> pdp_ctr, pdp_cvr, home_page_ctr_no_diversity 187 // </i> 188 // 189 // `Panel2 candidates`: <i> home_page_ctr_no_diversity, 190 // home_page_ctr_diversity_low, 191 // pdp_cvr_no_diversity </i> 192 // 193 // `Restriction` = `UNIQUE_MODEL_RESTRICTION` 194 // 195 // `Valid combinations`: 196 // 197 // * <i> (pdp_ctr, home_page_ctr_no_diversity) 198 // * (pdp_ctr, home_page_ctr_diversity) 199 // * (pdp_cvr, home_page_ctr_no_diversity) 200 // * (pdp_cvr, home_page_ctr_diversity_low) 201 // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) </i> 202 // 203 // `Invalid combinations`: 204 // 205 // * <i> (pdp_ctr, pdp_cvr_no_diversity) 206 // * (pdp_ctr, pdp_cvr_no_diversity) 207 // * (pdp_cvr, pdp_cvr_no_diversity) 208 // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) 209 // * (home_page_ctr_no_diversity, home_page_ctr_diversity) </i> 210 UNIQUE_MODEL_TYPE_RESTRICTION = 4; 211 } 212 213 // Required. The type of [UserEvent][google.cloud.retail.v2alpha.UserEvent] 214 // this page optimization is shown for. 215 // 216 // Each page has an associated event type - this will be the 217 // corresponding event type for the page that the page optimization 218 // model is used on. 219 // 220 // Supported types: 221 // 222 // * `add-to-cart`: Products being added to cart. 223 // * `detail-page-view`: Products detail page viewed. 224 // * `home-page-view`: Homepage viewed 225 // * `category-page-view`: Homepage viewed 226 // * `shopping-cart-page-view`: User viewing a shopping cart. 227 // 228 // `home-page-view` only allows models with type `recommended-for-you`. 229 // All other page_optimization_event_type allow all 230 // [Model.types][google.cloud.retail.v2alpha.Model.type]. 231 string page_optimization_event_type = 1 232 [(google.api.field_behavior) = REQUIRED]; 233 234 // Required. A list of panel configurations. 235 // 236 // Limit = 5. 237 repeated Panel panels = 2 [(google.api.field_behavior) = REQUIRED]; 238 239 // Optional. How to restrict results across panels e.g. can the same 240 // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] be shown on 241 // multiple panels at once. 242 // 243 // If unspecified, default to `UNIQUE_MODEL_RESTRICTION`. 244 Restriction restriction = 3 [(google.api.field_behavior) = OPTIONAL]; 245 } 246 247 // Represents an ordered combination of valid serving configs, which 248 // can be used for `PAGE_OPTIMIZATION` recommendations. 249 message ServingConfigList { 250 // Optional. A set of valid serving configs that may be used for 251 // `PAGE_OPTIMIZATION`. 252 repeated string serving_config_ids = 1 253 [(google.api.field_behavior) = OPTIONAL]; 254 } 255 256 // The serving state of the model. 257 enum ServingState { 258 // Unspecified serving state. 259 SERVING_STATE_UNSPECIFIED = 0; 260 261 // The model is not serving. 262 INACTIVE = 1; 263 264 // The model is serving and can be queried. 265 ACTIVE = 2; 266 267 // The model is trained on tuned hyperparameters and can be 268 // queried. 269 TUNED = 3; 270 } 271 272 // The training state of the model. 273 enum TrainingState { 274 // Unspecified training state. 275 TRAINING_STATE_UNSPECIFIED = 0; 276 277 // The model training is paused. 278 PAUSED = 1; 279 280 // The model is training. 281 TRAINING = 2; 282 } 283 284 // Describes whether periodic tuning is enabled for this model 285 // or not. Periodic tuning is scheduled at most every three months. You can 286 // start a tuning process manually by using the `TuneModel` 287 // method, which starts a tuning process immediately and resets the quarterly 288 // schedule. Enabling or disabling periodic tuning does not affect any 289 // current tuning processes. 290 enum PeriodicTuningState { 291 // Unspecified default value, should never be explicitly set. 292 PERIODIC_TUNING_STATE_UNSPECIFIED = 0; 293 294 // The model has periodic tuning disabled. Tuning 295 // can be reenabled by calling the `EnableModelPeriodicTuning` 296 // method or by calling the `TuneModel` method. 297 PERIODIC_TUNING_DISABLED = 1; 298 299 // The model cannot be tuned with periodic tuning OR the 300 // `TuneModel` method. Hide the options in customer UI and 301 // reject any requests through the backend self serve API. 302 ALL_TUNING_DISABLED = 3; 303 304 // The model has periodic tuning enabled. Tuning 305 // can be disabled by calling the `DisableModelPeriodicTuning` 306 // method. 307 PERIODIC_TUNING_ENABLED = 2; 308 } 309 310 // Describes whether this model have sufficient training data 311 // to be continuously trained. 312 enum DataState { 313 // Unspecified default value, should never be explicitly set. 314 DATA_STATE_UNSPECIFIED = 0; 315 316 // The model has sufficient training data. 317 DATA_OK = 1; 318 319 // The model does not have sufficient training data. Error 320 // messages can be queried via Stackdriver. 321 DATA_ERROR = 2; 322 } 323 324 // Training configuration specific to a 325 // [Model.type][google.cloud.retail.v2alpha.Model.type] - currently, only for 326 // page optimization. 327 oneof training_config { 328 // Optional. The page optimization config. 329 PageOptimizationConfig page_optimization_config = 17 330 [(google.api.field_behavior) = OPTIONAL]; 331 } 332 333 // Required. The fully qualified resource name of the model. 334 // 335 // Format: 336 // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` 337 // catalog_id has char limit of 50. 338 // recommendation_model_id has char limit of 40. 339 string name = 1 [(google.api.field_behavior) = REQUIRED]; 340 341 // Required. The display name of the model. 342 // 343 // Should be human readable, used to display Recommendation Models in the 344 // Retail Cloud Console Dashboard. UTF-8 encoded string with limit of 1024 345 // characters. 346 string display_name = 2 [(google.api.field_behavior) = REQUIRED]; 347 348 // Optional. The training state that the model is in (e.g. 349 // `TRAINING` or `PAUSED`). 350 // 351 // Since part of the cost of running the service 352 // is frequency of training - this can be used to determine when to train 353 // model in order to control cost. If not specified: the default value for 354 // `CreateModel` method is `TRAINING`. The default value for 355 // `UpdateModel` method is to keep the state the same as before. 356 TrainingState training_state = 3 [(google.api.field_behavior) = OPTIONAL]; 357 358 // Output only. The serving state of the model: `ACTIVE`, `NOT_ACTIVE`. 359 ServingState serving_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; 360 361 // Output only. Timestamp the Recommendation Model was created at. 362 google.protobuf.Timestamp create_time = 5 363 [(google.api.field_behavior) = OUTPUT_ONLY]; 364 365 // Output only. Timestamp the Recommendation Model was last updated. E.g. 366 // if a Recommendation Model was paused - this would be the time the pause was 367 // initiated. 368 google.protobuf.Timestamp update_time = 6 369 [(google.api.field_behavior) = OUTPUT_ONLY]; 370 371 // Required. The type of model e.g. `home-page`. 372 // 373 // Currently supported values: `recommended-for-you`, `others-you-may-like`, 374 // `frequently-bought-together`, `page-optimization`, `similar-items`, 375 // `buy-it-again`, `on-sale-items`, and `recently-viewed`(readonly value). 376 // 377 // 378 // This field together with 379 // [optimization_objective][google.cloud.retail.v2alpha.Model.optimization_objective] 380 // describe model metadata to use to control model training and serving. 381 // See https://cloud.google.com/retail/docs/models 382 // for more details on what the model metadata control and which combination 383 // of parameters are valid. For invalid combinations of parameters (e.g. type 384 // = `frequently-bought-together` and optimization_objective = `ctr`), you 385 // receive an error 400 if you try to create/update a recommendation with 386 // this set of knobs. 387 string type = 7 [(google.api.field_behavior) = REQUIRED]; 388 389 // Optional. The optimization objective e.g. `cvr`. 390 // 391 // Currently supported 392 // values: `ctr`, `cvr`, `revenue-per-order`. 393 // 394 // If not specified, we choose default based on model type. 395 // Default depends on type of recommendation: 396 // 397 // `recommended-for-you` => `ctr` 398 // 399 // `others-you-may-like` => `ctr` 400 // 401 // `frequently-bought-together` => `revenue_per_order` 402 // 403 // This field together with 404 // [optimization_objective][google.cloud.retail.v2alpha.Model.type] 405 // describe model metadata to use to control model training and serving. 406 // See https://cloud.google.com/retail/docs/models 407 // for more details on what the model metadata control and which combination 408 // of parameters are valid. For invalid combinations of parameters (e.g. type 409 // = `frequently-bought-together` and optimization_objective = `ctr`), you 410 // receive an error 400 if you try to create/update a recommendation with 411 // this set of knobs. 412 string optimization_objective = 8 [(google.api.field_behavior) = OPTIONAL]; 413 414 // Optional. The state of periodic tuning. 415 // 416 // The period we use is 3 months - to do a 417 // one-off tune earlier use the `TuneModel` method. Default value 418 // is `PERIODIC_TUNING_ENABLED`. 419 PeriodicTuningState periodic_tuning_state = 11 420 [(google.api.field_behavior) = OPTIONAL]; 421 422 // Output only. The timestamp when the latest successful tune finished. 423 google.protobuf.Timestamp last_tune_time = 12 424 [(google.api.field_behavior) = OUTPUT_ONLY]; 425 426 // Output only. The tune operation associated with the model. 427 // 428 // Can be used to determine if there is an ongoing tune for this 429 // recommendation. Empty field implies no tune is goig on. 430 string tuning_operation = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; 431 432 // Output only. The state of data requirements for this model: `DATA_OK` and 433 // `DATA_ERROR`. 434 // 435 // Recommendation model cannot be trained if the data is in 436 // `DATA_ERROR` state. Recommendation model can have `DATA_ERROR` state even 437 // if serving state is `ACTIVE`: models were trained successfully before, but 438 // cannot be refreshed because model no longer has sufficient 439 // data for training. 440 DataState data_state = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; 441 442 // Optional. If `RECOMMENDATIONS_FILTERING_ENABLED`, recommendation filtering 443 // by attributes is enabled for the model. 444 RecommendationsFilteringOption filtering_option = 18 445 [(google.api.field_behavior) = OPTIONAL]; 446 447 // Output only. The list of valid serving configs associated with the 448 // PageOptimizationConfig. 449 repeated ServingConfigList serving_config_lists = 19 450 [(google.api.field_behavior) = OUTPUT_ONLY]; 451} 452