Skip to contents

Ch 3 prompt templates (Kamath Eq 3.5-3.7)

Usage

morie_kamath_ch3_prefix_prompt_template(
  x,
  z = NULL,
  template = "[x] This movie is [z]"
)

morie_kamath_ch3_translate_prefix_prompt(
  x,
  z = NULL,
  template = "Translate the following English sentence to French: [x] [z]"
)

morie_kamath_ch3_cloze_prompt_template(
  x,
  z = NULL,
  template = "[x] This is a [z] movie."
)

Arguments

x

Input text.

z

Answer, or NULL to leave the slot open.

template

Template string.

Value

List with prompt, slot_filled, tokens.

Details

One filler serves all three Python modules exactly as km046/km047/km048 share _fill_template: km046 -> morie_kamath_ch3_prefix_prompt_template, km047 -> morie_kamath_ch3_translate_prefix_prompt, km048 -> morie_kamath_ch3_cloze_prompt_template.

Examples

morie_kamath_ch3_prefix_prompt_template("Loved it.", "great")
#> $prompt
#> [1] "Loved it. This movie is great"
#> 
#> $slot_filled
#> [1] TRUE
#> 
#> $template
#> [1] "[x] This movie is [z]"
#> 
#> $tokens
#> [1] "Loved" "it."   "This"  "movie" "is"    "great"
#> 
#> $estimate
#> [1] 6
#> 
#> $n
#> [1] 6
#> 
#> $method
#> [1] "prompt template (Kamath Eq 3.5)"
#>