Skip to content

Commit

Permalink
support training with transformer parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
kermitt2 committed Nov 21, 2022
1 parent cb39dac commit b9d92c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions grobid-core/src/main/java/org/grobid/core/jni/DeLFTModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ public void run() {
localArgs += ", batch_size="+
GrobidProperties.getInstance().getDelftTrainingBatchSize(this.modelName);

if (GrobidProperties.getInstance().getDelftTranformer(modelName) != null) {
localArgs += ", transformer="+
GrobidProperties.getInstance().getDelftTranformer(modelName);
}

// init model to be trained
if (architecture == null)
jep.eval("model = Sequence('"+this.modelName+
Expand Down Expand Up @@ -310,6 +315,10 @@ public static void train(String modelName, File trainingData, File outputModel,
command.add("--architecture");
command.add(architecture);
}
if (GrobidProperties.getInstance().getDelftTranformer(modelName) != null) {
command.add("--transformer");
command.add(GrobidProperties.getInstance().getDelftTranformer(modelName));
}
if (GrobidProperties.getInstance().useELMo(modelName) && modelName.toLowerCase().indexOf("bert") == -1) {
command.add("--use-ELMo");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,20 @@ public static String getDelftEmbeddingsName(final String modelName) {
return param.delft.embeddings_name;
}

public static String getDelftTranformer(final String modelName) {
ModelParameters param = modelMap.get(modelName);
if (param == null) {
LOGGER.debug("No configuration parameter defined for model " + modelName);
return null;
}
DelftModelParameters delftParam = param.delft;
if (delftParam == null) {
LOGGER.debug("No configuration parameter defined for DeLFT engine for model " + modelName);
return null;
}
return param.delft.transformer;
}

/**
* Return -1 if not set in the configuration and the default DeLFT value will be used in this case.
*/
Expand Down

0 comments on commit b9d92c6

Please sign in to comment.