CoTPrompt
Chain-of-Thought prompting is a recently developed prompting method, which encourages the LLM to explain its reasoning process when answering the prompt. This explanation of reasoning often leads to more accurate results. Specifically, we implement
FewshotCoTPrompt
andZeroshotCoTPrompt
.
FewshotCoTPrompt
FewshotCoTPrompt
is the class for few-shot Chain-of-Thought prompts. By showing the LLM some few shot exemplars where the reasoning process is explained in the exemplars, the LLM will also show the reasoning process when answering the prompt.
build_prompt
Description
Build a prompt from a given string input and a list of in-context examples.
Parameters
prompt
(str): The prompt string.in_context_examples
(List[Dict]): A list of in-context examples. Defaults to None.n_shots
(int): The number of in-context examples to use. Defaults to 2.
Example
ZeroshotCoTPrompt
ZeroshotCoTPrompt
is the class for few-shot Chain-of-Thought prompts. LLMs are demonstrated to be zero-shot reasoners by simply adding "Let's think step by step" before each answer, which is refered as Zeroshot-CoT.
build_prompt
Description
Build a prompt from a given string input.
Parameters
prompt
(str): The prompt string.
Example
Last updated