Record Class SentenceVectorsOptions

java.lang.Object
java.lang.Record
opennlp.dl.vectors.SentenceVectorsOptions
Record Components:
pooling - How token vectors are pooled. Not used for a model with a sentence_embedding output. Must not be null.
normalize - true to scale every vector to unit length.
maxLength - The maximum number of tokens per input, including the classification and separator tokens. Longer input is truncated. Must be at least 2.
padding - The padding strategy. Must not be null. PaddingStrategy.AUTO selects the device and model default: SentenceVectorsDL.DEFAULT_GPU_PADDING on a GPU for a token output if the vocabulary has a padding token, SentenceVectorsDL.DEFAULT_CPU_PADDING otherwise. An explicit padded strategy requires a padding token in the vocabulary.

public record SentenceVectorsOptions(Pooling pooling, boolean normalize, int maxLength, PaddingStrategy padding) extends Record
Pooling, normalization, truncation and padding settings for SentenceVectorsDL.
Since:
3.0.0
  • Constructor Details

    • SentenceVectorsOptions

      public SentenceVectorsOptions(Pooling pooling, boolean normalize, int maxLength, PaddingStrategy padding)
      Creates vector settings after validating the pooling mode, maximum length and padding strategy.
      Throws:
      IllegalArgumentException - Thrown if pooling or padding is null, or maxLength is less than 2.
    • SentenceVectorsOptions

      public SentenceVectorsOptions()
      Creates settings for mean pooling, unit length scaling, a maximum of 512 tokens and the device and model padding default.
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • pooling

      public Pooling pooling()
      Returns the value of the pooling record component.
      Returns:
      the value of the pooling record component
    • normalize

      public boolean normalize()
      Returns the value of the normalize record component.
      Returns:
      the value of the normalize record component
    • maxLength

      public int maxLength()
      Returns the value of the maxLength record component.
      Returns:
      the value of the maxLength record component
    • padding

      public PaddingStrategy padding()
      Returns the value of the padding record component.
      Returns:
      the value of the padding record component