Skip to contents

best_demos() returns the few-shot demonstrations a module currently carries, such as those chosen by LabeledFewShot() or BootstrapFewShot().

Usage

best_demos(module, as_tibble = FALSE)

Arguments

module

A module.

as_tibble

If TRUE, return a tibble with one row per demonstration and one column per input and output field. If FALSE (the default), return the list of demonstrations as stored.

Value

A list or tibble of demonstrations, or NULL when the module has none.

Examples

classifier <- module(signature("text -> sentiment"))
trainset <- data.frame(
  text = c("I love it!", "Terrible experience", "It's okay"),
  sentiment = c("positive", "negative", "neutral")
)
compiled <- compile(classifier, LabeledFewShot(k = 2L), trainset)
best_demos(compiled, as_tibble = TRUE)
#> # A tibble: 2 × 2
#>   text       output  
#>   <chr>      <chr>   
#> 1 It's okay  neutral 
#> 2 I love it! positive

# An uncompiled module has none
best_demos(classifier)
#> NULL