Applies scaling to queries: \(q_{\text{scaled}} = q \cdot \text{mlp}(\log n)\), where a small MLP learns to map sequence length to scaling factors.
Arguments
- num_heads
integer(1)Number of attention heads.integer(1)Number of hidden units in the MLP. Default:64L.- elementwise
logical(1)IfTRUE, apply elementwise scaling per head dimension so that each element in the head dimension gets its own scaling factor. Default:FALSE.- head_dim
integer(1)orNULL. Dimension of each attention head. Required whenelementwise = TRUE.
Value
An nn_module object (class generator).