| // Copyright 2023 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 = "ModelExecutionProto"; |
| |
| package optimization_guide.proto; |
| |
| import "components/optimization_guide/proto/model_execution.proto"; |
| import "components/optimization_guide/proto/substitution.proto"; |
| |
| message TextSafetyModelMetadata { |
| // The number of categories the model is expected to output. |
| optional uint32 num_output_categories = 1; |
| |
| // The set of feature configurations used to determine whether the text is |
| // safe. |
| repeated FeatureTextSafetyConfiguration feature_text_safety_configurations = |
| 2; |
| } |
| |
| message SafetyCategoryThreshold { |
| // Label for the category. E.g. 'TOXICITY', 'SEXUAL', 'HEALTH', etc. |
| optional string category_label = 1; |
| |
| // Index of the category from the output (scores) of the text safety model. |
| optional uint32 output_index = 2; |
| |
| // Threshold for the category, scores >= to the threshold will be filtered. |
| optional float threshold = 3; |
| } |
| |
| message RequestSafetyCheck { |
| // How to generate input for the text safety check from the request message. |
| repeated SubstitutedString input_template = 1; |
| |
| // The set of thresholds to apply per category, overriding those in the |
| // parent. |
| repeated SafetyCategoryThreshold safety_category_thresholds = 2; |
| |
| // Whether to only perform the allowed language check. |
| optional bool check_language_only = 3; |
| |
| // Whether to ignore the language result of the safety check. |
| optional bool ignore_language_result = 4; |
| } |
| |
| message RawOutputCheck { |
| // How to generate input for the text safety check. |
| // Should be written against a google.protobuf.StringValue proto with the raw |
| // output. |
| repeated SubstitutedString input_template = 1; |
| } |
| |
| message FeatureTextSafetyConfiguration { |
| // The feature this configuration pertains to. |
| optional ModelExecutionFeature feature = 1; |
| |
| // The default set of thresholds to apply per category. |
| repeated SafetyCategoryThreshold safety_category_thresholds = 2; |
| |
| // The set of languages allowed for text safety evaluation. If empty, no |
| // language constraints are enforced. |
| repeated string allowed_languages = 3; |
| |
| // Safety checks to run on the feature request message. |
| repeated RequestSafetyCheck request_check = 4; |
| |
| // Configures the checks to run on raw model output. |
| optional RawOutputCheck raw_output_check = 5; |
| } |