
Instruction-tuning cross entropy (Kamath Ch 4)
Source:R/kamath_llm2_native.R
morie_kamath_instruction_tuning_loss.RdCausal-LM cross entropy with the instruction masked out (-100).
Examples
morie_kamath_instruction_tuning_loss(matrix(c(1, 0, 2, 0, 1,
0), 3), c(0, 1, 1), c(0, 1, 0))
#> $estimate
#> [1] 0.2200948
#>
#> $loss
#> [1] 0.2200948
#>
#> $perplexity
#> [1] 1.246195
#>
#> $token_losses
#> [1] 0.3132617 0.1269280
#>
#> $n_response_tokens
#> [1] 2
#>
#> $vocab_size
#> [1] 2
#>
#> $n
#> [1] 3
#>
#> $method
#> [1] "Instruction-tuning CE over response tokens"
#>