LanguageModelInput

lamp.nn.languagemodel.LanguageModelInput
See theLanguageModelInput companion object
case class LanguageModelInput(tokens: Constant, maxLength: Option[STen], positions: Option[STen])

Input to language model

Value parameters

maxLength

batch x sequence OR batch, see maskedSoftmax. Used to define masking of the attention matrix. Use cases:

  • Left-to-right (causal) attention with uniform sequence length. In this case use a batch x sequence 2D matrix with arange(0,sequence) in each row.
  • Variable length sequences with bidirectional attention. In this case use a 1D [batch] vector with the real length of each sequence (rest are padded).
  • If empty the attention matrix is not masked
positions

batch x sequence, type long in [0,sequence], selects positions. Final LM logits are computed on the selected positions. If empty then selects all positions.

tokens

batch x sequence, type long

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product