Module org.elasticsearch.xcore
Class ByteLevelBpeTokenization
java.lang.Object
org.elasticsearch.xpack.core.ml.inference.trainedmodel.Tokenization
org.elasticsearch.xpack.core.ml.inference.trainedmodel.ByteLevelBpeTokenization
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentObject,NamedXContentObject
Tokenization settings for byte-level BPE models (for example GPT-2 style vocabularies) that ship
a merge table alongside the vocabulary. The in-process tokenizer applies UTF-8 byte mapping and
BPE merges using the same engine as the RoBERTa tokenizer, but special token strings are
configurable so deployments can align with Hugging Face tokenizer metadata.
do_lower_case is not applied by the byte-level BPE analyzer and must not be set to true;
requests that set it to true are rejected like RobertaTokenization.
When with_special_tokens is true, the configured BOS and EOS strings must be present
in the vocabulary; that requirement is enforced when the inference tokenizer is constructed for the model (not only in
validateVocabulary(org.elasticsearch.xpack.core.ml.action.PutTrainedModelVocabularyAction.Request)), consistent with
RobertaTokenization.
The configured mask string is optional for encoding-only inference, and the mask token id may be unset if that token
is missing from the vocabulary (masking-oriented tasks should ensure it exists).-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.xpack.core.ml.inference.trainedmodel.Tokenization
Tokenization.SpanSettings, Tokenization.TruncateNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TransportVersionTokenizationwire format for byte-level BPE; do not send to nodes that do not support this version.static final StringName used in inference configuration XContent and named writeables.Fields inherited from class org.elasticsearch.xpack.core.ml.inference.trainedmodel.Tokenization
DEFAULT_MAX_SEQUENCE_LENGTH, DO_LOWER_CASE, doLowerCase, MAX_SEQUENCE_LENGTH, maxSequenceLength, span, SPAN, truncate, TRUNCATE, UNSET_SPAN_VALUE, WITH_SPECIAL_TOKENS, withSpecialTokensFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateParser(boolean ignoreUnknownFields) booleanstatic ByteLevelBpeTokenizationfromXContent(XContentParser parser, boolean lenient) getName()inthashCode()booleanvoidvoidwriteTo(StreamOutput out) Methods inherited from class org.elasticsearch.xpack.core.ml.inference.trainedmodel.Tokenization
createDefault, doLowerCase, getMaxSequenceLength, getSpan, getTruncate, maxSequenceLength, toXContent, updateWindowSettings, validateSpanAndMaxSequenceLength, validateSpanAndTruncate, withSpecialTokensMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
NAME
Name used in inference configuration XContent and named writeables.- See Also:
-
ML_BYTE_LEVEL_BPE_TOKENIZATION_ADDED
Tokenizationwire format for byte-level BPE; do not send to nodes that do not support this version.
-
-
Constructor Details
-
ByteLevelBpeTokenization
public ByteLevelBpeTokenization(@Nullable Boolean doLowerCase, @Nullable Boolean withSpecialTokens, @Nullable Integer maxSequenceLength, @Nullable Tokenization.Truncate truncate, @Nullable Integer span, @Nullable Boolean addPrefixSpace, @Nullable String unkToken, @Nullable String padToken, @Nullable String bosToken, @Nullable String eosToken, @Nullable String maskToken) -
ByteLevelBpeTokenization
- Throws:
IOException
-
-
Method Details
-
createParser
public static ConstructingObjectParser<ByteLevelBpeTokenization,Void> createParser(boolean ignoreUnknownFields) -
fromXContent
-
isAddPrefixSpace
public boolean isAddPrefixSpace() -
getUnkToken
-
getPadToken
-
getBosToken
-
getEosToken
-
getWriteableName
-
writeTo
- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classTokenization- Throws:
IOException
-
getMaskToken
- Specified by:
getMaskTokenin classTokenization
-
getName
- Returns:
- The name of the XContentObject that is to be serialized
-
validateVocabulary
- Overrides:
validateVocabularyin classTokenization
-
equals
- Overrides:
equalsin classTokenization
-
hashCode
public int hashCode()- Overrides:
hashCodein classTokenization
-