summaryrefslogtreecommitdiff
path: root/chromium/components/optimization_guide/proto/models.proto
blob: 7d610a156ff5d9c5e9ee591abc133a0d69fbd065 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

syntax = "proto2";
option optimize_for = LITE_RUNTIME;
option java_package = "org.chromium.components.optimization_guide.proto";
option java_outer_classname = "ModelsProto";

package optimization_guide.proto;

import "components/optimization_guide/proto/common_types.proto";

// A generic handle for any type of model.
message Model {
  reserved 1, 2, 3, 4, 123;

  oneof model {
    // When passed from the server, this is the URL that the model can be
    // downloaded from. When used internally within Chrome, this contains the
    // absolute file path where the model file is saved on disk.
    string download_url = 5;
  }
}

// Requests prediction models to be used for a set of optimization targets.
message GetModelsRequest {
  reserved 2, 4;

  // Information about the requested models.
  repeated ModelInfo requested_models = 1;
  // Context in which this request is made.
  //
  // If the context matches one that requires more urgency (i.e.
  // CONTEXT_PAGE_NAVIGATION), then no model updates will be returned for the
  // requested models.
  optional RequestContext request_context = 3;
  // The locale to associate with this request.
  //
  // It is the IETF language tag, defined in BCP 47. The region subtag is not
  // included when it adds no distinguishing information to the language tag
  // (e.g. both "en-US" and "fr" are correct here).
  optional string locale = 5;
  // Information about the request origin.
  optional OriginInfo origin_info = 6;
}

// Response to the GetModels request.
message GetModelsResponse {
  reserved 2;

  // The models to be used during prediction for the requested optimization
  // targets.
  repeated PredictionModel models = 1;
}

// Holds the prediction model for a particular optimization target.
message PredictionModel {
  // Information about the model.
  optional ModelInfo model_info = 1;
  // The model to evaluate for the attached model information.
  //
  // This will only be set if the model that the client claims it has is stale.
  // It is also guaranteed that the value populated as part of this field is one
  // that the client claims to support based on the request's client model
  // capabilities.
  optional Model model = 2;
}

message AdditionalModelFile {
  // When sent by the server, this contains the basenames of the additional
  // files that should be kept and sent to this model's consumers. When used
  // only locally within Chrome, the full path is given.
  optional string file_path = 1;
}

// Metadata for a prediction model for a specific optimization target.
//
// Next ID: 10
message ModelInfo {
  reserved 3;

  // The optimization target for which the model predicts.
  optional OptimizationTarget optimization_target = 1;
  // The version of the model, which is specific to the optimization target.
  optional int64 version = 2;
  // The set of model engine versions the requesting client can use to do model
  // inference.
  repeated ModelEngineVersion supported_model_engine_versions = 4;
  // The set of host model features that are referenced by the model.
  //
  // Note that this should only be populated if part of the response.
  repeated string supported_host_model_features = 5;
  // Additional files required by this model version.
  //
  // If populated, these files are included in the downloaded archive for this
  // model and should be passed along to the consumer.
  //
  // This does not need to be sent to the server in the request for an update to
  // this model. The server will ignore this if sent.
  repeated AdditionalModelFile additional_files = 7;
  // How long the model will remain valid in client storage. If
  // |keep_beyond_valid_duration| is true, will be ignored.
  optional Duration valid_duration = 8;
  // Whether to delete the model once valid_duration has passed.
  optional bool keep_beyond_valid_duration = 9;
  // Mechanism used for model owners to attach metadata to the request or
  // response.
  //
  // In practice, we expect this to be used as a way to negotiate capabilities.
  // The client can provide the model features they can evaluate if this field
  // is part of the request, and the server can provide the model features that
  // are actually present in the model.
  optional Any model_metadata = 6;
}

// The scenarios for which the optimization guide has models for.
enum OptimizationTarget {
  OPTIMIZATION_TARGET_UNKNOWN = 0;
  // Should only be applied when the page load is predicted to be painful.
  OPTIMIZATION_TARGET_PAINFUL_PAGE_LOAD = 1;
  // Target for supplying the language detection model via the model downloader.
  OPTIMIZATION_TARGET_LANGUAGE_DETECTION = 2;
  // Target for determining topics present on a page.
  OPTIMIZATION_TARGET_PAGE_TOPICS = 3;
  // Target for segmentation: New tab page user.
  OPTIMIZATION_TARGET_SEGMENTATION_NEW_TAB = 4;
  // Target for segmentation: Share user.
  OPTIMIZATION_TARGET_SEGMENTATION_SHARE = 5;
  // Target for segmentation: Voice user.
  OPTIMIZATION_TARGET_SEGMENTATION_VOICE = 6;
  // Target for model validation.
  OPTIMIZATION_TARGET_MODEL_VALIDATION = 7;
  // Target for determining entities present on a page.
  OPTIMIZATION_TARGET_PAGE_ENTITIES = 8;
  // Target for Chrome Permissions Suggestions Service: Notification permission.
  OPTIMIZATION_TARGET_NOTIFICATION_PERMISSION_PREDICTIONS = 9;
  // Target that enables data collection on client side for various experiments.
  OPTIMIZATION_TARGET_SEGMENTATION_DUMMY = 10;
  // Target for segmentation: Chrome Android Start user.
  OPTIMIZATION_TARGET_SEGMENTATION_CHROME_START_ANDROID = 11;
  // Target for segmentation: Query Tiles user.
  OPTIMIZATION_TARGET_SEGMENTATION_QUERY_TILES = 12;
  // Target for determining the UI visibility of a page.
  OPTIMIZATION_TARGET_PAGE_VISIBILITY = 13;
  // Target for supplying the Autofill Assistant annotate DOM model via the
  // model downloader.
  OPTIMIZATION_TARGET_AUTOFILL_ASSISTANT = 14;
  // Target for determining topics present on a page.
  // TODO(crbug/1266504): Remove PAGE_TOPICS in favor of this target.
  OPTIMIZATION_TARGET_PAGE_TOPICS_V2 = 15;
  // Target for segmentation: Determine users with low engagement with chrome.
  OPTIMIZATION_TARGET_SEGMENTATION_CHROME_LOW_USER_ENGAGEMENT = 16;
  // Target for segmentation: Determine users who prefer to use Feed.
  OPTIMIZATION_TARGET_SEGMENTATION_FEED_USER = 17;
  // Target for segmentation: Determine whether price tracking should be shown
  // as a contextual page action.
  OPTIMIZATION_TARGET_CONTEXTUAL_PAGE_ACTION_PRICE_TRACKING = 18;
  // Target for smart text selection and entity extraction.
  OPTIMIZATION_TARGET_TEXT_CLASSIFIER = 19;
  // Target for Chrome Permissions Suggestions Service: Geolocation permission.
  OPTIMIZATION_TARGET_GEOLOCATION_PERMISSION_PREDICTIONS = 20;
  // Target for segmentation: Determine users who are interested in shopping.
  OPTIMIZATION_TARGET_SEGMENTATION_SHOPPING_USER = 21;
  // Target for segmentation: Chrome Android Start user V2.
  OPTIMIZATION_TARGET_SEGMENTATION_CHROME_START_ANDROID_V2 = 22;
  // Target for segmentation: Determine users who use search.
  OPTIMIZATION_TARGET_SEGMENTATION_SEARCH_USER = 23;
  // Target for Omnibox on device tail suggest.
  OPTIMIZATION_TARGET_OMNIBOX_ON_DEVICE_TAIL_SUGGEST = 24;
}

// The model engine versions that can be used to do model inference.
//
// Please only update these enums when a new major version of TFLite rolls.
//
// For example: v1.2.3
//                 ^
//                 Change when this number increments.
enum ModelEngineVersion {
  reserved 1;

  MODEL_ENGINE_VERSION_UNKNOWN = 0;
  // A model using only operations that are supported by TensorflowLite 2.3.0.
  MODEL_ENGINE_VERSION_TFLITE_2_3_0 = 2;
  // A model using only operations that are supported by TensorflowLite 2.3.0
  // with updated FULLY_CONNECTED and BATCH_MUL versions for quantized models.
  MODEL_ENGINE_VERSION_TFLITE_2_3_0_1 = 3;
  // TensorflowLite version 2.4.2, and a bit more up to internal rev number
  // 381280669.
  MODEL_ENGINE_VERSION_TFLITE_2_4 = 4;
  // TensorflowLite version 2.7.*. This is where regular ~HEAD rolls started.
  MODEL_ENGINE_VERSION_TFLITE_2_7 = 5;
  // A model using only operations that are supported by TensorflowLite 2.8.0.
  MODEL_ENGINE_VERSION_TFLITE_2_8 = 6;
  // A model using only operations that are supported by TensorflowLite 2.9.0.
  MODEL_ENGINE_VERSION_TFLITE_2_9 = 7;
  // A model using only operations that are supported by TensorflowLite 2.9.0.
  // This adds GELU to the supported ops in Optimiziation Guide.
  MODEL_ENGINE_VERSION_TFLITE_2_9_0_1 = 8;
  // A model using only operations that are supported by TensorflowLite 2.10.0.
  MODEL_ENGINE_VERSION_TFLITE_2_10 = 9;
  // A model using only operations that are supported by TensorflowLite 2.11.0.
  MODEL_ENGINE_VERSION_TFLITE_2_11 = 10;
}