
DALL-E autoregressive image-token scoring (Geron Ch 16, morie.fn grdal)
Source:R/geron_ml_native.R
morie_geron_dalle_autoregressive_token.RdTeacher-forced log-likelihood of the prefix plus the next-token
distribution after temperature and optional top-k truncation.
logits_fn receives the 0-based context as a numeric vector.
Usage
morie_geron_dalle_autoregressive_token(
text_tokens,
image_tokens_prefix,
logits_fn,
temperature = 1,
top_k = NULL
)Value
List with log_likelihood, token_logprobs, perplexity,
next_token_probs, next_token, vocab_size.
Examples
skew <- function(ctx) c(0, 1, 2) + 0.1 * length(ctx)
morie_geron_dalle_autoregressive_token(c(0, 1), c(2, 0), skew,
temperature = 0.5)
#> $log_likelihood
#> [1] -2.815212
#>
#> $token_logprobs
#> [1] -0.407606 -2.407606
#>
#> $perplexity
#> [1] 4.086161
#>
#> $next_token_probs
#> [1] 0.01587624 0.11731043 0.86681333
#>
#> $next_token
#> [1] 2
#>
#> $vocab_size
#> [1] 3
#>
#> $context_length
#> [1] 4
#>
#> $estimate
#> [1] -2.815212
#>
#> $n
#> [1] 2
#>
#> $method
#> [1] "Autoregressive image-token likelihood"
#>