
Entropy-based attention regularisation (Kamath Eq 6.21)
Source:R/kamath_llm2_native.R
morie_kamath_ch6_ear_entropy_reg.Rd-lam times the summed per-layer MEAN attention row entropy. Rows must sum to 1; 0 log 0 is taken as 0.
Examples
morie_kamath_ch6_ear_entropy_reg(list(matrix(c(0.5, 1, 0.5, 0),
2)), lam = 2)
#> $estimate
#> [1] -0.6931472
#>
#> $per_layer_entropy
#> [1] 0.3465736
#>
#> $total_entropy
#> [1] 0.3465736
#>
#> $lam
#> [1] 2
#>
#> $n
#> [1] 1
#>
#> $method
#> [1] "entropy-based attention regularisation (Kamath Eq 6.21)"
#>