1// Copyright 2023 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.ai.generativelanguage.v1beta; 18 19import "google/api/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/protobuf/timestamp.proto"; 22 23option go_package = "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb;generativelanguagepb"; 24option java_multiple_files = true; 25option java_outer_classname = "TunedModelProto"; 26option java_package = "com.google.ai.generativelanguage.v1beta"; 27 28// A fine-tuned model created using ModelService.CreateTunedModel. 29message TunedModel { 30 option (google.api.resource) = { 31 type: "generativelanguage.googleapis.com/TunedModel" 32 pattern: "tunedModels/{tuned_model}" 33 plural: "tunedModels" 34 singular: "tunedModel" 35 }; 36 37 // The state of the tuned model. 38 enum State { 39 // The default value. This value is unused. 40 STATE_UNSPECIFIED = 0; 41 42 // The model is being created. 43 CREATING = 1; 44 45 // The model is ready to be used. 46 ACTIVE = 2; 47 48 // The model failed to be created. 49 FAILED = 3; 50 } 51 52 // The model used as the starting point for tuning. 53 oneof source_model { 54 // Optional. TunedModel to use as the starting point for training the new 55 // model. 56 TunedModelSource tuned_model_source = 3 57 [(google.api.field_behavior) = OPTIONAL]; 58 59 // Immutable. The name of the `Model` to tune. 60 // Example: `models/text-bison-001` 61 string base_model = 4 [ 62 (google.api.field_behavior) = IMMUTABLE, 63 (google.api.resource_reference) = { 64 type: "generativelanguage.googleapis.com/Model" 65 } 66 ]; 67 } 68 69 // Output only. The tuned model name. A unique name will be generated on 70 // create. Example: `tunedModels/az2mb0bpw6i` If display_name is set on 71 // create, the id portion of the name will be set by concatenating the words 72 // of the display_name with hyphens and adding a random portion for 73 // uniqueness. Example: 74 // display_name = "Sentence Translator" 75 // name = "tunedModels/sentence-translator-u3b7m" 76 string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 77 78 // Optional. The name to display for this model in user interfaces. 79 // The display name must be up to 40 characters including spaces. 80 string display_name = 5 [(google.api.field_behavior) = OPTIONAL]; 81 82 // Optional. A short description of this model. 83 string description = 6 [(google.api.field_behavior) = OPTIONAL]; 84 85 // Optional. Controls the randomness of the output. 86 // 87 // Values can range over `[0.0,1.0]`, inclusive. A value closer to `1.0` will 88 // produce responses that are more varied, while a value closer to `0.0` will 89 // typically result in less surprising responses from the model. 90 // 91 // This value specifies default to be the one used by the base model while 92 // creating the model. 93 optional float temperature = 11 [(google.api.field_behavior) = OPTIONAL]; 94 95 // Optional. For Nucleus sampling. 96 // 97 // Nucleus sampling considers the smallest set of tokens whose probability 98 // sum is at least `top_p`. 99 // 100 // This value specifies default to be the one used by the base model while 101 // creating the model. 102 optional float top_p = 12 [(google.api.field_behavior) = OPTIONAL]; 103 104 // Optional. For Top-k sampling. 105 // 106 // Top-k sampling considers the set of `top_k` most probable tokens. 107 // This value specifies default to be used by the backend while making the 108 // call to the model. 109 // 110 // This value specifies default to be the one used by the base model while 111 // creating the model. 112 optional int32 top_k = 13 [(google.api.field_behavior) = OPTIONAL]; 113 114 // Output only. The state of the tuned model. 115 State state = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; 116 117 // Output only. The timestamp when this model was created. 118 google.protobuf.Timestamp create_time = 8 119 [(google.api.field_behavior) = OUTPUT_ONLY]; 120 121 // Output only. The timestamp when this model was updated. 122 google.protobuf.Timestamp update_time = 9 123 [(google.api.field_behavior) = OUTPUT_ONLY]; 124 125 // Required. The tuning task that creates the tuned model. 126 TuningTask tuning_task = 10 [(google.api.field_behavior) = REQUIRED]; 127} 128 129// Tuned model as a source for training a new model. 130message TunedModelSource { 131 // Immutable. The name of the `TunedModel` to use as the starting point for 132 // training the new model. 133 // Example: `tunedModels/my-tuned-model` 134 string tuned_model = 1 [ 135 (google.api.field_behavior) = IMMUTABLE, 136 (google.api.resource_reference) = { 137 type: "generativelanguage.googleapis.com/TunedModel" 138 } 139 ]; 140 141 // Output only. The name of the base `Model` this `TunedModel` was tuned from. 142 // Example: `models/text-bison-001` 143 string base_model = 2 [ 144 (google.api.field_behavior) = OUTPUT_ONLY, 145 (google.api.resource_reference) = { 146 type: "generativelanguage.googleapis.com/Model" 147 } 148 ]; 149} 150 151// Tuning tasks that create tuned models. 152message TuningTask { 153 // Output only. The timestamp when tuning this model started. 154 google.protobuf.Timestamp start_time = 1 155 [(google.api.field_behavior) = OUTPUT_ONLY]; 156 157 // Output only. The timestamp when tuning this model completed. 158 google.protobuf.Timestamp complete_time = 2 159 [(google.api.field_behavior) = OUTPUT_ONLY]; 160 161 // Output only. Metrics collected during tuning. 162 repeated TuningSnapshot snapshots = 3 163 [(google.api.field_behavior) = OUTPUT_ONLY]; 164 165 // Required. Input only. Immutable. The model training data. 166 Dataset training_data = 4 [ 167 (google.api.field_behavior) = INPUT_ONLY, 168 (google.api.field_behavior) = REQUIRED, 169 (google.api.field_behavior) = IMMUTABLE 170 ]; 171 172 // Immutable. Hyperparameters controlling the tuning process. If not provided, 173 // default values will be used. 174 Hyperparameters hyperparameters = 5 [(google.api.field_behavior) = IMMUTABLE]; 175} 176 177// Hyperparameters controlling the tuning process. Read more at 178// https://ai.google.dev/docs/model_tuning_guidance 179message Hyperparameters { 180 // Options for specifying learning rate during tuning. 181 oneof learning_rate_option { 182 // Optional. Immutable. The learning rate hyperparameter for tuning. 183 // If not set, a default of 0.001 or 0.0002 will be calculated based on the 184 // number of training examples. 185 float learning_rate = 16 [ 186 (google.api.field_behavior) = IMMUTABLE, 187 (google.api.field_behavior) = OPTIONAL 188 ]; 189 190 // Optional. Immutable. The learning rate multiplier is used to calculate a 191 // final learning_rate based on the default (recommended) value. Actual 192 // learning rate := learning_rate_multiplier * default learning rate Default 193 // learning rate is dependent on base model and dataset size. If not set, a 194 // default of 1.0 will be used. 195 float learning_rate_multiplier = 17 [ 196 (google.api.field_behavior) = IMMUTABLE, 197 (google.api.field_behavior) = OPTIONAL 198 ]; 199 } 200 201 // Immutable. The number of training epochs. An epoch is one pass through the 202 // training data. If not set, a default of 5 will be used. 203 optional int32 epoch_count = 14 [(google.api.field_behavior) = IMMUTABLE]; 204 205 // Immutable. The batch size hyperparameter for tuning. 206 // If not set, a default of 4 or 16 will be used based on the number of 207 // training examples. 208 optional int32 batch_size = 15 [(google.api.field_behavior) = IMMUTABLE]; 209} 210 211// Dataset for training or validation. 212message Dataset { 213 // Inline data or a reference to the data. 214 oneof dataset { 215 // Optional. Inline examples. 216 TuningExamples examples = 1 [(google.api.field_behavior) = OPTIONAL]; 217 } 218} 219 220// A set of tuning examples. Can be training or validation data. 221message TuningExamples { 222 // Required. The examples. Example input can be for text or discuss, but all 223 // examples in a set must be of the same type. 224 repeated TuningExample examples = 1 [(google.api.field_behavior) = REQUIRED]; 225} 226 227// A single example for tuning. 228message TuningExample { 229 // The input to the model for this example. 230 oneof model_input { 231 // Optional. Text model input. 232 string text_input = 1 [(google.api.field_behavior) = OPTIONAL]; 233 } 234 235 // Required. The expected model output. 236 string output = 3 [(google.api.field_behavior) = REQUIRED]; 237} 238 239// Record for a single tuning step. 240message TuningSnapshot { 241 // Output only. The tuning step. 242 int32 step = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 243 244 // Output only. The epoch this step was part of. 245 int32 epoch = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; 246 247 // Output only. The mean loss of the training examples for this step. 248 float mean_loss = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; 249 250 // Output only. The timestamp when this metric was computed. 251 google.protobuf.Timestamp compute_time = 4 252 [(google.api.field_behavior) = OUTPUT_ONLY]; 253} 254