
Counterfactual-pair debiasing and the gender direction (Eq 6.18-6.19)
Source:R/kamath_llm2_native.R
morie_kamath_ch6_debias_regularizer.RdCounterfactual-pair debiasing and the gender direction (Eq 6.18-6.19)
Details
One pair reader serves both Python modules exactly as km095
imports km094's _pair_vectors: km094 ->
morie_kamath_ch6_debias_regularizer (lam * sum of squared within-pair
distances), km095 -> morie_kamath_ch6_gender_direction
(mean of E(second) - E(first) over the pairs).
Examples
E <- list(m1 = c(1, 0), f1 = c(0, 1), m2 = c(2, 0), f2 = c(0,
2))
P <- list(c("m1", "f1"), c("m2", "f2"))
morie_kamath_ch6_debias_regularizer(P, E, 0.5)
#> $estimate
#> [1] 5
#>
#> $per_pair
#> [1] 2 8
#>
#> $unweighted
#> [1] 10
#>
#> $lam
#> [1] 0.5
#>
#> $n
#> [1] 2
#>
#> $method
#> [1] "counterfactual-pair debiasing regulariser (Kamath Eq 6.18)"
#>