prediction_service.proto 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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.aiplatform.v1beta1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/httpbody.proto";
  20. import "google/api/resource.proto";
  21. import "google/cloud/aiplatform/v1beta1/explanation.proto";
  22. import "google/protobuf/struct.proto";
  23. option csharp_namespace = "Google.Cloud.AIPlatform.V1Beta1";
  24. option go_package = "google.golang.org/genproto/googleapis/cloud/aiplatform/v1beta1;aiplatform";
  25. option java_multiple_files = true;
  26. option java_outer_classname = "PredictionServiceProto";
  27. option java_package = "com.google.cloud.aiplatform.v1beta1";
  28. option php_namespace = "Google\\Cloud\\AIPlatform\\V1beta1";
  29. option ruby_package = "Google::Cloud::AIPlatform::V1beta1";
  30. // A service for online predictions and explanations.
  31. service PredictionService {
  32. option (google.api.default_host) = "aiplatform.googleapis.com";
  33. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  34. // Perform an online prediction.
  35. rpc Predict(PredictRequest) returns (PredictResponse) {
  36. option (google.api.http) = {
  37. post: "/v1beta1/{endpoint=projects/*/locations/*/endpoints/*}:predict"
  38. body: "*"
  39. };
  40. option (google.api.method_signature) = "endpoint,instances,parameters";
  41. }
  42. // Perform an online explanation.
  43. //
  44. // If [deployed_model_id][google.cloud.aiplatform.v1beta1.ExplainRequest.deployed_model_id] is specified,
  45. // the corresponding DeployModel must have
  46. // [explanation_spec][google.cloud.aiplatform.v1beta1.DeployedModel.explanation_spec]
  47. // populated. If [deployed_model_id][google.cloud.aiplatform.v1beta1.ExplainRequest.deployed_model_id]
  48. // is not specified, all DeployedModels must have
  49. // [explanation_spec][google.cloud.aiplatform.v1beta1.DeployedModel.explanation_spec]
  50. // populated. Only deployed AutoML tabular Models have
  51. // explanation_spec.
  52. rpc Explain(ExplainRequest) returns (ExplainResponse) {
  53. option (google.api.http) = {
  54. post: "/v1beta1/{endpoint=projects/*/locations/*/endpoints/*}:explain"
  55. body: "*"
  56. };
  57. option (google.api.method_signature) = "endpoint,instances,parameters,deployed_model_id";
  58. }
  59. }
  60. // Request message for [PredictionService.Predict][google.cloud.aiplatform.v1beta1.PredictionService.Predict].
  61. message PredictRequest {
  62. // Required. The name of the Endpoint requested to serve the prediction.
  63. // Format:
  64. // `projects/{project}/locations/{location}/endpoints/{endpoint}`
  65. string endpoint = 1 [
  66. (google.api.field_behavior) = REQUIRED,
  67. (google.api.resource_reference) = {
  68. type: "aiplatform.googleapis.com/Endpoint"
  69. }
  70. ];
  71. // Required. The instances that are the input to the prediction call.
  72. // A DeployedModel may have an upper limit on the number of instances it
  73. // supports per request, and when it is exceeded the prediction call errors
  74. // in case of AutoML Models, or, in case of customer created Models, the
  75. // behaviour is as documented by that Model.
  76. // The schema of any single instance may be specified via Endpoint's
  77. // DeployedModels' [Model's][google.cloud.aiplatform.v1beta1.DeployedModel.model]
  78. // [PredictSchemata's][google.cloud.aiplatform.v1beta1.Model.predict_schemata]
  79. // [instance_schema_uri][google.cloud.aiplatform.v1beta1.PredictSchemata.instance_schema_uri].
  80. repeated google.protobuf.Value instances = 2 [(google.api.field_behavior) = REQUIRED];
  81. // The parameters that govern the prediction. The schema of the parameters may
  82. // be specified via Endpoint's DeployedModels' [Model's ][google.cloud.aiplatform.v1beta1.DeployedModel.model]
  83. // [PredictSchemata's][google.cloud.aiplatform.v1beta1.Model.predict_schemata]
  84. // [parameters_schema_uri][google.cloud.aiplatform.v1beta1.PredictSchemata.parameters_schema_uri].
  85. google.protobuf.Value parameters = 3;
  86. }
  87. // Response message for [PredictionService.Predict][google.cloud.aiplatform.v1beta1.PredictionService.Predict].
  88. message PredictResponse {
  89. // The predictions that are the output of the predictions call.
  90. // The schema of any single prediction may be specified via Endpoint's
  91. // DeployedModels' [Model's ][google.cloud.aiplatform.v1beta1.DeployedModel.model]
  92. // [PredictSchemata's][google.cloud.aiplatform.v1beta1.Model.predict_schemata]
  93. // [prediction_schema_uri][google.cloud.aiplatform.v1beta1.PredictSchemata.prediction_schema_uri].
  94. repeated google.protobuf.Value predictions = 1;
  95. // ID of the Endpoint's DeployedModel that served this prediction.
  96. string deployed_model_id = 2;
  97. }
  98. // Request message for [PredictionService.Explain][google.cloud.aiplatform.v1beta1.PredictionService.Explain].
  99. message ExplainRequest {
  100. // Required. The name of the Endpoint requested to serve the explanation.
  101. // Format:
  102. // `projects/{project}/locations/{location}/endpoints/{endpoint}`
  103. string endpoint = 1 [
  104. (google.api.field_behavior) = REQUIRED,
  105. (google.api.resource_reference) = {
  106. type: "aiplatform.googleapis.com/Endpoint"
  107. }
  108. ];
  109. // Required. The instances that are the input to the explanation call.
  110. // A DeployedModel may have an upper limit on the number of instances it
  111. // supports per request, and when it is exceeded the explanation call errors
  112. // in case of AutoML Models, or, in case of customer created Models, the
  113. // behaviour is as documented by that Model.
  114. // The schema of any single instance may be specified via Endpoint's
  115. // DeployedModels' [Model's][google.cloud.aiplatform.v1beta1.DeployedModel.model]
  116. // [PredictSchemata's][google.cloud.aiplatform.v1beta1.Model.predict_schemata]
  117. // [instance_schema_uri][google.cloud.aiplatform.v1beta1.PredictSchemata.instance_schema_uri].
  118. repeated google.protobuf.Value instances = 2 [(google.api.field_behavior) = REQUIRED];
  119. // The parameters that govern the prediction. The schema of the parameters may
  120. // be specified via Endpoint's DeployedModels' [Model's ][google.cloud.aiplatform.v1beta1.DeployedModel.model]
  121. // [PredictSchemata's][google.cloud.aiplatform.v1beta1.Model.predict_schemata]
  122. // [parameters_schema_uri][google.cloud.aiplatform.v1beta1.PredictSchemata.parameters_schema_uri].
  123. google.protobuf.Value parameters = 4;
  124. // If specified, overrides the
  125. // [explanation_spec][google.cloud.aiplatform.v1beta1.DeployedModel.explanation_spec] of the DeployedModel.
  126. // Can be used for explaining prediction results with different
  127. // configurations, such as:
  128. // - Explaining top-5 predictions results as opposed to top-1;
  129. // - Increasing path count or step count of the attribution methods to reduce
  130. // approximate errors;
  131. // - Using different baselines for explaining the prediction results.
  132. ExplanationSpecOverride explanation_spec_override = 5;
  133. // If specified, this ExplainRequest will be served by the chosen
  134. // DeployedModel, overriding [Endpoint.traffic_split][google.cloud.aiplatform.v1beta1.Endpoint.traffic_split].
  135. string deployed_model_id = 3;
  136. }
  137. // Response message for [PredictionService.Explain][google.cloud.aiplatform.v1beta1.PredictionService.Explain].
  138. message ExplainResponse {
  139. // The explanations of the Model's [PredictResponse.predictions][google.cloud.aiplatform.v1beta1.PredictResponse.predictions].
  140. //
  141. // It has the same number of elements as [instances][google.cloud.aiplatform.v1beta1.ExplainRequest.instances]
  142. // to be explained.
  143. repeated Explanation explanations = 1;
  144. // ID of the Endpoint's DeployedModel that served this explanation.
  145. string deployed_model_id = 2;
  146. // The predictions that are the output of the predictions call.
  147. // Same as [PredictResponse.predictions][google.cloud.aiplatform.v1beta1.PredictResponse.predictions].
  148. repeated google.protobuf.Value predictions = 3;
  149. }