Skip to contents

Appends the trigger, then splits reasoning from the answer.

Usage

morie_kamath_chain_of_thought(
  prompt,
  model,
  trigger = "Let's think step by step.",
  answer_marker = "Answer:",
  parser = NULL
)

Arguments

prompt

Question.

model

Function prompt -> text.

trigger

Reasoning trigger.

answer_marker

Split marker.

parser

Optional function text -> list(reasoning, answer).

Value

List with estimate, answer, reasoning, generation.

Examples

morie_kamath_chain_of_thought("Q", function(p) "step one. Answer: 42")
#> $estimate
#> [1] "42"
#> 
#> $answer
#> [1] "42"
#> 
#> $reasoning
#> [1] "step one."
#> 
#> $prompt
#> [1] "Q Let's think step by step."
#> 
#> $generation
#> [1] "step one. Answer: 42"
#> 
#> $n
#> [1] 1
#> 
#> $method
#> [1] "zero-shot chain-of-thought prompting (Kamath Ch 4)"
#>