public class BertMaskedLMMasker extends Object implements BertSequenceMasker
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_MASK_PROB |
static double |
DEFAULT_MASK_TOKEN_PROB |
static double |
DEFAULT_RANDOM_WORD_PROB |
protected double |
maskProb |
protected double |
maskTokenProb |
protected Random |
r |
protected double |
randomTokenProb |
Constructor and Description |
---|
BertMaskedLMMasker()
Create a BertMaskedLMMasker with all default probabilities
|
BertMaskedLMMasker(Random r,
double maskProb,
double maskTokenProb,
double randomTokenProb)
See:
BertMaskedLMMasker for details. |
Modifier and Type | Method and Description |
---|---|
org.nd4j.common.primitives.Pair<List<String>,boolean[]> |
maskSequence(List<String> input,
String maskToken,
List<String> vocabWords) |
public static final double DEFAULT_MASK_PROB
public static final double DEFAULT_MASK_TOKEN_PROB
public static final double DEFAULT_RANDOM_WORD_PROB
protected final Random r
protected final double maskProb
protected final double maskTokenProb
protected final double randomTokenProb
public BertMaskedLMMasker()
public BertMaskedLMMasker(Random r, double maskProb, double maskTokenProb, double randomTokenProb)
BertMaskedLMMasker
for details.r
- Random number generatormaskProb
- Probability of masking each tokenmaskTokenProb
- Probability of replacing a selected token with the mask tokenrandomTokenProb
- Probability of replacing a selected token with a random tokenpublic org.nd4j.common.primitives.Pair<List<String>,boolean[]> maskSequence(List<String> input, String maskToken, List<String> vocabWords)
maskSequence
in interface BertSequenceMasker
input
- Input sequence of tokensmaskToken
- Token to use for masking - usually something like "[MASK]"vocabWords
- Vocabulary, as a listCopyright © 2022. All rights reserved.