Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56cd14d
commit 1d06db3
Showing
2 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 14 additions & 2 deletions
16
...deeplearning4j-nlp/src/main/java/org/deeplearning4j/iterator/bert/BertSequenceMasker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
package org.deeplearning4j.iterator.bert; | ||
|
||
import org.nd4j.linalg.api.ndarray.INDArray; | ||
import org.nd4j.linalg.primitives.Pair; | ||
|
||
import java.util.List; | ||
|
||
|
||
/** | ||
* Interface used to customize how masking should be performed with {@link org.deeplearning4j.iterator.BertIterator} | ||
* when doing unsupervised training | ||
* | ||
* @author Alex Black | ||
*/ | ||
public interface BertSequenceMasker { | ||
|
||
/** | ||
* | ||
* @param input Input sequence of tokens | ||
* @param maskToken Token to use for masking - usually something like "[MASK]" | ||
* @param vocabWords Vocabulary, as a list | ||
* @return Pair: The new input tokens (after masking out), along with a boolean[] for whether the token is | ||
* masked or not (same length as number of tokens). boolean[i] is true if token i was masked. | ||
*/ | ||
Pair<List<String>,boolean[]> maskSequence(List<String> input, String maskToken, List<String> vocabWords); | ||
|
||
} |