TorchLean API

NN.API.Neural.Positional

Positional Encodings #

Configuration records for learned positions, fixed sinusoidal encodings, and rotary positional embeddings. The seeded constructors live in NN.API.Seeded.

Learned positional embedding configuration.

This is a trainable parameter tensor of shape (sequenceLength × embeddingWidth) that is broadcast across batchShape and added to the input.

  • initialization : Init.Scheme

    Initialization scheme for the positional embedding table.

Instances For
    def TorchLean.nn.LearnedPositionalEmbedding.Config.validate (config : Config) (sequenceLength embeddingWidth : ) :

    Validate table dimensions and initialization.

    Instances For

      Sinusoidal positional encoding configuration.

      Classic non-trainable Transformer sinusoidal encoding, added to token embeddings. startPosition is an absolute-position offset for KV-cache decoding.

      • startPosition :

        Absolute position offset for the first row of the encoding table.

      Instances For
        def TorchLean.nn.SinusoidalPositionalEncoding.Config.validate (_config : Config) (sequenceLength embeddingWidth : ) :

        Validate the tensor dimensions before materializing the fixed encoding buffer.

        Instances For

          Rotary positional embedding (RoPE) configuration.

          startPosition is an absolute-position offset for KV-cache decoding.

          • startPosition :

            Absolute position offset for the first row of RoPE angles.

          Instances For
            def TorchLean.nn.RotaryEmbedding.Config.validate (_config : Config) (sequenceLength headWidth : ) :

            Validate the tensor dimensions before materializing the fixed rotation buffers.

            Instances For