model.proto 16 KB

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