summaryrefslogtreecommitdiffstats
path: root/model-integration/src
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-09-15 10:41:48 +0200
committerGitHub <noreply@github.com>2022-09-15 10:41:48 +0200
commit641561888e998be6d198c651c3c45de9f1915b31 (patch)
tree1b94433c10755a3d02cac6c8183754614a909869 /model-integration/src
parente430aa42191d81b0f0aca9a0c1403575eaea56b1 (diff)
parent8d588c26e716d705c4f1b63fc6b16ce17eed0647 (diff)
Merge pull request #24058 from vespa-engine/bratseth/mode-def-file
Move the BERT config def to model-integration
Diffstat (limited to 'model-integration/src')
-rw-r--r--model-integration/src/main/java/ai/vespa/embedding/BertBaseEmbedder.java4
-rw-r--r--model-integration/src/main/resources/configdefinitions/embedding.bert-base-embedder.def27
2 files changed, 29 insertions, 2 deletions
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 c25fc8704b0..d4a93999dff 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
+