Enum Class PaddingStrategy
- All Implemented Interfaces:
Serializable, Comparable<PaddingStrategy>, Constable
How
SentenceVectorsDL.embedAll(List) shapes the tensors of one inference when the texts
of a call differ in tokenized length.
A padded position is 0 in the attention mask and Pooling reads only the
positions a row's own mask covers, so the vectors of the strategies match up to
floating-point rounding, provided the model honors the attention mask. A
sentence_embedding output that ignores the mask changes with padding. The strategies
differ in tensor shape and in how many times the session runs.
- Since:
- 3.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionSelectsLONGESTon a GPU for a model with token output and a padding token in its vocabulary,EXACT_LENGTHotherwise.No padding.Every row of a batch is padded to the longest row of that batch.Every row is padded to the maximum length, so every inference has the same sequence length. -
Method Summary
Modifier and TypeMethodDescriptionstatic PaddingStrategyReturns the enum constant of this class with the specified name.static PaddingStrategy[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
AUTO
SelectsLONGESTon a GPU for a model with token output and a padding token in its vocabulary,EXACT_LENGTHotherwise. Resolved when the embedder is constructed. -
EXACT_LENGTH
No padding. Texts are grouped by their exact tokenized length and each group runs on its own. This is the default on the CPU. On natural text most groups hold one or two texts. -
LONGEST
Every row of a batch is padded to the longest row of that batch. Texts are ordered by length before batching, so one long text does not pad out a batch of short ones. Requires a padding token in the vocabulary. This is the default on a GPU if the vocabulary has one, except for a model with asentence_embeddingoutput, which may ignore the attention mask. -
MAX_LENGTH
Every row is padded to the maximum length, so every inference has the same sequence length. Single calls such asSentenceVectorsDL.embed(CharSequence)andSentenceVectorsDL.getVectors(String)pad to the maximum length as well. Useful for a model or accelerator that needs a fixed sequence length. Requires a padding token in the vocabulary. If the output dimension must be probed during construction, that inference also uses the maximum length and can fail if it exceeds the model's position limit.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-