Internal refactoring for TextEmbedder.

PiperOrigin-RevId: 493766612
This commit is contained in:
MediaPipe Team
2022-12-07 18:56:27 -08:00
committed by Copybara-Service
parent a0efcb47f2
commit 700c7b4b22
9 changed files with 375 additions and 106 deletions
@@ -60,10 +60,16 @@ mediapipe_proto_library(
],
)
mediapipe_proto_library(
name = "text_model_type_proto",
srcs = ["text_model_type.proto"],
)
mediapipe_proto_library(
name = "text_preprocessing_graph_options_proto",
srcs = ["text_preprocessing_graph_options.proto"],
deps = [
":text_model_type_proto",
"//mediapipe/framework:calculator_options_proto",
"//mediapipe/framework:calculator_proto",
],
@@ -0,0 +1,31 @@
/* Copyright 2022 The MediaPipe Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
syntax = "proto2";
package mediapipe.tasks.components.processors.proto;
message TextModelType {
// TFLite text models supported by MediaPipe tasks.
enum ModelType {
UNSPECIFIED_MODEL = 0;
// A BERT-based model.
BERT_MODEL = 1;
// A model expecting input passed through a regex-based tokenizer.
REGEX_MODEL = 2;
// A model taking a string tensor input.
STRING_MODEL = 3;
}
}
@@ -18,25 +18,16 @@ syntax = "proto2";
package mediapipe.tasks.components.processors.proto;
import "mediapipe/framework/calculator.proto";
import "mediapipe/tasks/cc/components/processors/proto/text_model_type.proto";
message TextPreprocessingGraphOptions {
extend mediapipe.CalculatorOptions {
optional TextPreprocessingGraphOptions ext = 476978751;
}
// The type of text preprocessor required for the TFLite model.
enum PreprocessorType {
UNSPECIFIED_PREPROCESSOR = 0;
// Used for the BertPreprocessorCalculator.
BERT_PREPROCESSOR = 1;
// Used for the RegexPreprocessorCalculator.
REGEX_PREPROCESSOR = 2;
// Used for the TextToTensorCalculator.
STRING_PREPROCESSOR = 3;
}
optional PreprocessorType preprocessor_type = 1;
optional TextModelType.ModelType model_type = 1;
// The maximum input sequence length for the TFLite model. Used with
// BERT_PREPROCESSOR and REGEX_PREPROCESSOR.
// BERT_MODEL and REGEX_MODEL.
optional int32 max_seq_len = 2;
}