Package ai.djl.huggingface.tokenizers
Class Encoding
java.lang.Object
ai.djl.huggingface.tokenizers.Encoding
A class holds token encoding information.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns if tokens exceed max length.long[]Returns the attention masks.CharSpan[]Returns char token spans.long[]getIds()Returns the token ids.Encoding[]Returns an array of overflowing encodings.long[]Returns the special token masks.String[]Returns the tokens.long[]Returns the token type ids.long[]Returns the word ids.ai.djl.ndarray.NDListtoNDList(ai.djl.ndarray.NDManager manager, boolean withTokenType) Returns theNDListrepresentation of the encoding.
-
Constructor Details
-
Encoding
-
-
Method Details
-
toNDList
public ai.djl.ndarray.NDList toNDList(ai.djl.ndarray.NDManager manager, boolean withTokenType) Returns theNDListrepresentation of the encoding.- Parameters:
manager- theNDManagerto create the NDListwithTokenType- true to include the token type id- Returns:
- the
NDList
-
getIds
public long[] getIds()Returns the token ids.- Returns:
- the token ids
-
getTypeIds
public long[] getTypeIds()Returns the token type ids.- Returns:
- the token type ids
-
getTokens
Returns the tokens.- Returns:
- the tokens
-
getWordIds
public long[] getWordIds()Returns the word ids.- Returns:
- the word ids
-
getAttentionMask
public long[] getAttentionMask()Returns the attention masks.- Returns:
- the attention masks
-
getSpecialTokenMask
public long[] getSpecialTokenMask()Returns the special token masks.- Returns:
- the special token masks
-
getCharTokenSpans
Returns char token spans.- Returns:
- char token spans
-
exceedMaxLength
public boolean exceedMaxLength()Returns if tokens exceed max length.- Returns:
trueif tokens exceed max length
-
getOverflowing
Returns an array of overflowing encodings.- Returns:
- the array of overflowing encodings
-