Packages

object LinAlg

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. LinAlg
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def argmax(scores: Array[Float]): Int

    Gets the index with the highest score.

    Gets the index with the highest score.

    scores

    Array of Scores to max

    returns

    Index of the highest score

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def avgPooling(flattenEmbeddings: Array[Float], attentionMask: Array[Array[Long]], shape: Array[Long]): DenseMatrix[Float]

    Performs average pooling on embeddings using an attention mask.

    Performs average pooling on embeddings using an attention mask.

    This method takes flattened embeddings, an attention mask, and the shape of the embeddings, and computes the average pooling. The pooling is done by grouping the embeddings based on the attention mask and computing the weighted sum of these groups. The result is normalized by the total weight of the attention mask.

    flattenEmbeddings

    Array of flattened embeddings

    attentionMask

    2D Array representing the attention mask

    shape

    Array representing the shape of the embeddings (dimensions)

    returns

    A DenseMatrix of floats representing the average pooled embeddings

  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  8. def clsAvgPooling(embeddings: Array[Array[Array[Float]]], attentionMask: Array[Array[Long]]): Array[Array[Float]]

    Creates pooled embeddings by averaging the embeddings of the CLS token and the average embedding the sequence.

    Creates pooled embeddings by averaging the embeddings of the CLS token and the average embedding the sequence.

    embeddings

    Embeddings in shape (batchSize, sequenceLength, embeddingDim)

    attentionMask

    Attention mask in shape (batchSize, sequenceLength)

    returns

    The pooled embeddings in shape (batchSize, embeddingDim)

  9. def clsPooling(embeddings: Array[Array[Array[Float]]], attentionMask: Array[Array[Long]]): Array[Array[Float]]

    Creates pooled embeddings by using the CLS token as the representative embedding of the sequence.

    Creates pooled embeddings by using the CLS token as the representative embedding of the sequence.

    embeddings

    Embeddings in shape (batchSize, sequenceLength, embeddingDim)

    attentionMask

    Attention mask in shape (batchSize, sequenceLength)

    returns

    The pooled embeddings in shape (batchSize, embeddingDim)

  10. def denseMatrixToArray(matrix: DenseMatrix[Float]): Array[Array[Float]]

    Converts a DenseMatrix to a 2D array of floats.

    Converts a DenseMatrix to a 2D array of floats.

    This method is used to transform a DenseMatrix[Float] into a two-dimensional array. It iterates over the rows and columns of the DenseMatrix, copying each element into the corresponding position in the newly created 2D array.

    matrix

    DenseMatrix[Float] that needs to be converted to a 2D array

    returns

    An 2D array representing the same data as the input DenseMatrix

  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  13. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. def l2Normalize(embeddings: DenseMatrix[Float]): DenseMatrix[Float]

    Normalizes each row of a DenseMatrix using the L2 norm.

    Normalizes each row of a DenseMatrix using the L2 norm.

    This method applies L2 normalization to the embeddings. It first computes the L2 norm for each row (embedding) in the input matrix. Then, it creates a matrix where each row is the computed norms vector, ensuring the dimensions match the input embeddings. Finally, it normalizes each row in the embeddings by dividing by the corresponding L2 norm.

    The result is a DenseMatrix where each row (embedding) is L2 normalized, ensuring that embeddings have a consistent scale for further processing.

    embeddings

    DenseMatrix[Float] representing the embeddings to be normalized

    returns

    DenseMatrix[Float] where each row is an L2 normalized version of the corresponding row in the input matrix

  18. def lastPooling(embeddings: Array[Array[Array[Float]]], attentionMask: Array[Array[Long]]): Array[Array[Float]]

    Creates pooled embeddings by taking the last token embedding of the sequence.

    Creates pooled embeddings by taking the last token embedding of the sequence. Assumes right padding.

    embeddings

    Embeddings in shape (batchSize, sequenceLength, embeddingDim)

    attentionMask

    Attention mask in shape (batchSize, sequenceLength)

    returns

    The pooled embeddings in shape (batchSize, embeddingDim)

  19. def lpNormalizeArray(array: Array[Float], p: Int = 2): Array[Float]
  20. def maxPooling(embeddings: Array[Array[Array[Float]]], attentionMask: Array[Array[Long]]): Array[Array[Float]]

    Creates pooled embeddings by taking the maximum of the embedding features along the sequence.

    Creates pooled embeddings by taking the maximum of the embedding features along the sequence.

    embeddings

    Embeddings in shape (batchSize, sequenceLength, embeddingDim)

    returns

    A 2D array representing the pooled embeddings

  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. def softmax(logitValues: Array[Float]): Array[Float]

    Calculates softmax probabilities for an array of logits.

    Calculates softmax probabilities for an array of logits.

    logitValues

    Predicted raw logits

    returns

    Probabilities for each class

  25. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  26. def toString(): String
    Definition Classes
    AnyRef → Any
  27. def tokenPooling(embeddings: Array[Array[Array[Float]]], index: Int): Array[Array[Float]]

    Creates pooled embeddings by selecting the token at the index position.

    Creates pooled embeddings by selecting the token at the index position.

    embeddings

    Embeddings in shape (batchSize, sequenceLength, embeddingDim)

    index

    Index Position to select for each sequence in the batch

    returns

    A 2D array representing the pooled embeddings

  28. def tokenPooling(embeddings: Array[Array[Array[Float]]], indexes: Array[Int]): Array[Array[Float]]

    Creates pooled embeddings by selecting the token at the index position.

    Creates pooled embeddings by selecting the token at the index position.

    embeddings

    Embeddings in shape (batchSize, sequenceLength, embeddingDim)

    indexes

    Array of Index Positions to select for each sequence in the batch

    returns

    A 2D array representing the pooled embeddings

  29. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  32. object implicits

Inherited from AnyRef

Inherited from Any

Ungrouped