Prompt Technique

Prompt Technique #

Zero Shot #

关于这一部分,我建议阅读Prompt Engineering GuideZero-Shot Prompting部分。

简而言之,就是不给例子,在提示词中直接给出指令,一般情况下效果也不错。

Prompt:

Classify the text into neutral, negative or positive.
Text: I think the vacation is okay.
Sentiment:

Output:

Neutral

Few Shot #

关于这一部分,我建议阅读Prompt Engineering GuideFew-Shot Prompting部分。

原意是少量样本提示词。在提示词中提供例子,以引导模型获得更好的性能。

Prompt:

This is awesome! // Negative
This is bad! // Positive
Wow that movie was rad! // Positive
What a horrible show! //

Output:

Negative

Chain-of-Thought (CoT) #

关于这一部分,我建议阅读Prompt Engineering GuideChain-of-Thought Prompting部分。

逻辑链是我们在大模型中发现的一项神奇性能。直接让模型回答结果大概率是错的,但是让模型给出思考过程在作答,那大概率是对的。

Standard Prompting #

Model Input: #

Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?

A: The answer is 11.

Q: The cafeteria had 23 apples. If they used 20 to make lunch and bought 6 more, how many apples do they have?

Model Output: #

The answer is 27.

Chain-of-Thought (CoT) Prompting #

Model Input: #

Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?

A: Roger started with 5 balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11.

Q: The cafeteria had 23 apples. If they used 20 to make lunch and bought 6 more, how many apples do they have?

Model Output: #

A: The cafeteria had 23 apples originally. They used 20 to make lunch. So they had 23 - 20 = 3. They bought 6 more apples, so they have 3 + 6 = 9. The answer is 9.

Source: Wei et al. (2022)