| // 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: 11 | |
| 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; | |
| // Cache key of this model. Sent in the request and response. The client can | |
| // set all the parameters based on the user profile characteristics, and the | |
| // server can return the parameters that were used by the model selection | |
| // logic to serve this model. The server should also update this in the model | |
| // info proto that is sent in the downloaded model files. | |
| optional ModelCacheKey model_cache_key = 10; | |
| } | |
| // The scenarios for which the optimization guide has models for. | |
| enum OptimizationTarget { | |
| reserved 14; | |
| 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 determining topics present on a page. | |
| // TODO(crbug.com/40204121): 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; | |
| // Target for client side phishing | |
| OPTIMIZATION_TARGET_CLIENT_SIDE_PHISHING = 25; | |
| // Target for Omnibox URL suggestion scoring. | |
| OPTIMIZATION_TARGET_OMNIBOX_URL_SCORING = 26; | |
| // Target for segmentation: Segment of users who switched devices. | |
| OPTIMIZATION_TARGET_SEGMENTATION_DEVICE_SWITCHER = 27; | |
| // Target for segmentation: Adaptive toolbar button. | |
| OPTIMIZATION_TARGET_SEGMENTATION_ADAPTIVE_TOOLBAR = 28; | |
| // Target for segmentation: Determine users who are tabletproductivity users. | |
| OPTIMIZATION_TARGET_SEGMENTATION_TABLET_PRODUCTIVITY_USER = 29; | |
| // Target for client side phishing image embedding model. | |
| OPTIMIZATION_TARGET_CLIENT_SIDE_PHISHING_IMAGE_EMBEDDER = 30; | |
| // Target for ranking clusters that have passed minimal filtering for the New | |
| // Tab Page History Clusters module. | |
| OPTIMIZATION_TARGET_NEW_TAB_PAGE_HISTORY_CLUSTERS_MODULE_RANKING = 31; | |
| // Target for web app install promotion. | |
| OPTIMIZATION_TARGET_WEB_APP_INSTALLATION_PROMO = 32; | |
| // Target for generic text embedder model. | |
| OPTIMIZATION_TARGET_TEXT_EMBEDDER = 33; | |
| // Target for classifying and extracting search images on web page. | |
| OPTIMIZATION_TARGET_VISUAL_SEARCH_CLASSIFICATION = 34; | |
| // Target for classifying users to target bottom toolbar. | |
| OPTIMIZATION_TARGET_SEGMENTATION_BOTTOM_TOOLBAR = 35; | |
| // Target for Autofill field type classification model. | |
| OPTIMIZATION_TARGET_AUTOFILL_FIELD_CLASSIFICATION = 36; | |
| // Target for ranking ios start page modules. | |
| OPTIMIZATION_TARGET_SEGMENTATION_IOS_MODULE_RANKER = 37; | |
| // Target for segmentation: Determine what modules a user should see on their | |
| // Desktop New Tab Page. | |
| OPTIMIZATION_TARGET_SEGMENTATION_DESKTOP_NTP_MODULE = 38; | |
| // Target for predicting candidate links for speculation-rule based | |
| // preloading. | |
| OPTIMIZATION_TARGET_PRELOADING_HEURISTICS = 39; | |
| // Target for determining text safety. | |
| OPTIMIZATION_TARGET_TEXT_SAFETY = 40; | |
| // Target for ranking Android home modules. | |
| OPTIMIZATION_TARGET_SEGMENTATION_ANDROID_HOME_MODULE_RANKER = 41; | |
| // Target to support running Compose On-Device. | |
| OPTIMIZATION_TARGET_COMPOSE = 42; | |
| // Target for generating passage embeddings. | |
| OPTIMIZATION_TARGET_PASSAGE_EMBEDDER = 43; | |
| // Target for breaking up sentences into phrases. | |
| OPTIMIZATION_TARGET_PHRASE_SEGMENTATION = 44; | |
| // Target to determine whether to show promotion for Compose. | |
| OPTIMIZATION_TARGET_SEGMENTATION_COMPOSE_PROMOTION = 45; | |
| // Target for ranking URL visits used in visit resumption features. | |
| OPTIMIZATION_TARGET_URL_VISIT_RESUMPTION_RANKER = 46; | |
| // Target for background segmentation of video frames. | |
| OPTIMIZATION_TARGET_CAMERA_BACKGROUND_SEGMENTATION = 47; | |
| // Target for History search model. | |
| OPTIMIZATION_TARGET_MODEL_EXECUTION_FEATURE_HISTORY_SEARCH = 48; | |
| // Target for Prompt API feature config. | |
| OPTIMIZATION_TARGET_MODEL_EXECUTION_FEATURE_PROMPT_API = 49; | |
| // Target for metrics based segmentation clustering. | |
| OPTIMIZATION_TARGET_SEGMENTATION_METRICS_CLUSTERING = 50; | |
| // Target for Summarize API feature config. | |
| OPTIMIZATION_TARGET_MODEL_EXECUTION_FEATURE_SUMMARIZE = 51; | |
| } | |
| // 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 Optimization 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; | |
| // A model using only operations that are supported by TensorflowLite 2.12.0. | |
| MODEL_ENGINE_VERSION_TFLITE_2_12 = 11; | |
| // A model using only operations that are supported by TensorflowLite 2.13.0. | |
| MODEL_ENGINE_VERSION_TFLITE_2_13 = 12; | |
| // A model using only operations that are supported by TensorflowLite 2.14.0. | |
| MODEL_ENGINE_VERSION_TFLITE_2_14 = 13; | |
| // A model using only operations that are supported by TensorflowLite 2.14.0. | |
| // This adds RANDOM_UNIFORM and RANDOM_STANDARD_NORMAL to the supported opts | |
| // in Optimization Guide. | |
| MODEL_ENGINE_VERSION_TFLITE_2_14_1 = 14; | |
| // A model using only operations that are supported by 2.16.0. | |
| MODEL_ENGINE_VERSION_TFLITE_2_16 = 15; | |
| // A model using only operations that are supported by 2.16.0. This raises the | |
| // max_version for FULLY_CONNECTED to version 12. | |
| MODEL_ENGINE_VERSION_TFLITE_2_16_1 = 16; | |
| // A model using only operations that are supported by 2.17, and adds int8 | |
| // quantization support in the seq_flow_lite custom ops. | |
| MODEL_ENGINE_VERSION_TFLITE_2_17 = 17; | |
| // A model using only operations that are supported by 2.18. | |
| MODEL_ENGINE_VERSION_TFLITE_2_18 = 18; | |
| } | |
| // The set of parameters that the server can use to vary the served model for | |
| // a given install. It can also vary by OS or Finch seed but those are global | |
| // for the install. | |
| message ModelCacheKey { | |
| optional string locale = 1; | |
| } |