File: on_device_model_execution_config.proto

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (172 lines) | stat: -rw-r--r-- 6,417 bytes parent folder | download | duplicates (3)
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
// Copyright 2024 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/common_types.proto";
import "components/optimization_guide/proto/descriptors.proto";
import "components/optimization_guide/proto/fieldwise_parser_config.proto";
import "components/optimization_guide/proto/redaction.proto";
import "components/optimization_guide/proto/substitution.proto";
import "components/optimization_guide/proto/model_execution.proto";
import "components/optimization_guide/proto/parser_kind.proto";

message OnDeviceModelExecutionConfig {
  // The set of configs for features that leverage the on-device model.
  //
  // It is expected that there is only one feature config per feature.
  repeated OnDeviceModelExecutionFeatureConfig feature_configs = 1;

  // A config used for validating the model and device after download.
  optional OnDeviceModelValidationConfig validation_config = 2;

  // List of capabilities supported by the base model.
  repeated OnDeviceModelCapability capabilities = 3;
}

enum OnDeviceModelCapability {
  ON_DEVICE_MODEL_CAPABILITY_UNSPECIFIED = 0;
  // The model supports taking image input.
  ON_DEVICE_MODEL_CAPABILITY_IMAGE_INPUT = 1;
  // The model supports taking audio input.
  ON_DEVICE_MODEL_CAPABILITY_AUDIO_INPUT = 2;
}

message OnDeviceModelExecutionFeatureConfig {
  // The feature this configuration is for.
  optional ModelExecutionFeature feature = 1;

  // The config used to construct the input for on-device model execution.
  optional OnDeviceModelExecutionInputConfig input_config = 2;

  // The config used to construct the output for on-device model execution.
  optional OnDeviceModelExecutionOutputConfig output_config = 3;

  // The config used to construct the request for server fallback text safety
  // evaluation.
  optional TextSafetyFallbackConfig text_safety_fallback_config = 4;

  // Whether text safety can be skipped for this feature, if not configured.
  optional bool can_skip_text_safety = 5;

  // Sampling parameters to use with the model.
  // These will override global defaults, but not per session configurations.
  optional SamplingParams sampling_params = 6;

  // Feature defined metadata.
  optional Any feature_metadata = 7;

  // The rank of the LORA associated with this feature.
  optional uint32 adaptation_rank = 8;
}

message OnDeviceModelExecutionInputConfig {
  // The base name of the request metadata proto this input config is applicable
  // for.
  optional string request_base_name = 1;

  // An ordered list of substituted strings to apply for input context.
  //
  // These will be concatenated in the order they appear here if the conditions
  // apply based on the input request.
  repeated SubstitutedString input_context_substitutions = 3;

  // An ordered list of substituted strings to apply when the model is executed.
  //
  // These will be concatenated in the order they appear here if the conditions
  // apply based on the input request.
  //
  // It is expected that the resulting string here will be concatenated with the
  // resulting string for the input context if `should_ignore_input_context` is
  // not set on any of the used substitutions.
  repeated SubstitutedString execute_substitutions = 2;

  // The number of tokens generated from `input_context_substitutions` that are
  // guaranteed to be processed before context processing can be cancelled
  // (truncating any unprocessed tokens) to begin execution. A default value is
  // used when this is not set. To disable cancellations, set this to be the
  // same as `max_context_tokens`.
  optional uint32 min_context_tokens = 4;

  // The maximum number of tokens that can be generated from
  // `input_context_substitutions`. Tokens in excess of this number will be
  // truncated. Uses a default value when unset.
  optional uint32 max_context_tokens = 5;

  // The maximum number of tokens that can be generated from
  // `execute_substitutions`. Tokens in excess of this number will be truncated.
  // Uses a default value when unset.
  optional uint32 max_execute_tokens = 6;
}

// Rules that generated output must follow.
message ResponseConstraint {
  oneof format {
    // A JSON Schema describing an llguidance constraint on the output. See
    // https://github.com/guidance-ai/llguidance/blob/main/docs/json_schema.md
    string json_schema = 1;
    // A regex describing the llguidance constraint on the output.
    // See https://docs.rs/regex/latest/regex/#syntax for syntax.
    string regex = 2;
  }
}

message OnDeviceModelExecutionOutputConfig {
  reserved 7;

  // The proto type to use for the response metadata.
  optional string proto_type = 1;

  // The proto field to populate the output string with. Applies for
  // PARSER_KIND_SIMPLE only.
  optional ProtoField proto_field = 2;

  // Rules that result in redacting the output.
  optional RedactRules redact_rules = 3;

  // Which output parsing implementation to use.
  optional ParserKind parser_kind = 4;

  // A config for specifying parsing logic for the fieldwise parser.
  optional FieldwiseParserConfig fieldwise_parser_config = 8;

  // Whether to suppress parsing incomplete output.
  optional bool suppress_parsing_incomplete_output = 5;

  // The maximum number of tokens that can be generated as output.
  optional uint32 max_output_tokens = 6;

  // The response constraint to use when generating output.
  optional ResponseConstraint response_constraint = 9;
}

message TextSafetyFallbackConfig {
  // The proto field in the input request that contains the URL this request was
  // activated on, if any.
  optional ProtoField input_url_proto_field = 1;
}

message OnDeviceModelValidationConfig {
  // Prompts and responses used for basic model validation.
  repeated ValidationPrompt validation_prompts = 1;
}

message ValidationPrompt {
  // The input prompt to send.
  optional string prompt = 1;

  // A string that the output is expected to contain. This is not case
  // sensitive.
  optional string expected_output = 2;
}

message SamplingParams {
  optional uint32 top_k = 1;
  optional float temperature = 2;
}