diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-09-14 17:51:12 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-09-14 17:51:12 +0200 |
commit | c172d09ebb17b47ebb2e75bb04d09a8533350450 (patch) | |
tree | 52b8f915bd2bc1352c05912b7f9597eb2b7ba73b /model-integration | |
parent | 027390f4a619bee2a713610f5057e79f2c1eb36c (diff) |
Move the BERT config def to model-integration
Diffstat (limited to 'model-integration')
3 files changed, 32 insertions, 3 deletions
diff --git a/model-integration/CMakeLists.txt b/model-integration/CMakeLists.txt index 4423746ccbc..9a19c5c31b0 100644 --- a/model-integration/CMakeLists.txt +++ b/model-integration/CMakeLists.txt @@ -3,4 +3,6 @@ install_jar(model-integration-jar-with-dependencies.jar) vespa_install_script(src/main/python/vespa-convert-tf2onnx.py vespa-convert-tf2onnx bin) -install(FILES src/main/config/model-integration.xml DESTINATION conf/configserver-app)
\ No newline at end of file +install(FILES src/main/config/model-integration.xml DESTINATION conf/configserver-app) + +install_config_definitions()
\ No newline at end of file diff --git a/model-integration/src/main/java/ai/vespa/embedding/BertBaseEmbedder.java b/model-integration/src/main/java/ai/vespa/embedding/BertBaseEmbedder.java index 149598ee2dd..4a1f59cc5cf 100644 --- a/model-integration/src/main/java/ai/vespa/embedding/BertBaseEmbedder.java +++ b/model-integration/src/main/java/ai/vespa/embedding/BertBaseEmbedder.java @@ -17,7 +17,7 @@ import java.util.Map; /** * A BERT Base compatible embedder. This embedder uses a WordPiece embedder to - * produce a token sequence that is input to a transformer model. A BERT base + * produce a token sequence that is then input to a transformer model. A BERT base * compatible transformer model must have three inputs: * * - A token sequence (input_ids) @@ -76,7 +76,7 @@ public class BertBaseEmbedder implements Embedder { private void validateName(Map<String, TensorType> types, String name, String type) { if ( ! types.containsKey(name)) { throw new IllegalArgumentException("Model does not contain required " + type + ": '" + name + "'. " + - "Model contains: " + String.join(",", types.keySet())); + "Model contains: " + String.join(",", types.keySet())); } } diff --git a/model-integration/src/main/resources/configdefinitions/embedding.bert-base-embedder.def b/model-integration/src/main/resources/configdefinitions/embedding.bert-base-embedder.def new file mode 100644 index 00000000000..14d953eeef9 --- /dev/null +++ b/model-integration/src/main/resources/configdefinitions/embedding.bert-base-embedder.def @@ -0,0 +1,27 @@ + +namespace=embedding + +# Wordpiece tokenizer +tokenizerVocab model + +transformerModel model + +# Max length of token sequence model can handle +transformerMaxTokens int default=384 + +# Pooling strategy +poolingStrategy enum { cls, mean } default=mean + +# Input names +transformerInputIds string default=input_ids +transformerAttentionMask string default=attention_mask +transformerTokenTypeIds string default=token_type_ids + +# Output name +transformerOutput string default=output_0 + +# Settings for ONNX model evaluation +onnxExecutionMode enum { parallel, sequential } default=sequential +onnxInterOpThreads int default=1 +onnxIntraOpThreads int default=-4 # n=number of threads -> n<0: CPUs/(-n), n==0: CPUs, n>0: n + |