2.4 模板

本节介绍了笔者常用的两类 Prompt 模板。但这里所谓的模板并不是需要强制遵循的格式,而是一种编写时的思路。模板中的各个部分也并不都是必须的,可以根据实际情况进行组合使用。就像在 2.3 Principles 中说的,我们编写 Prompt 时,应该从最简单的开始,逐步迭代优化,直至满足我们的需求。

2.4.1 Basic Template: Instruction, Context, Input, Outcome

componentsdescriptionnessesary?
Instructiona specific task or instruction you want the model to perform.Yes
Contextexternal information or additional context that can steer the model to better responses.Optional
Inputthe input or question that we are interested to find a response forOptional
Outcomethe type or format of the output.Optional
{.table .table-bordered .border-secondary}
  • 示例 1:

2.4.2 Advanced Template: Role, Instruction, Context, Example, Input, Outcome

componentsdescriptionnessesary?
RoleSpecify ChatGPT’s role.Yes
Instructiona specific task or instruction you want the model to performYes
Contextexternal information or additional context that can steer the model to better responses.Optional
Examplegive examples to illustrate the input and outcome, or examples of probolem solving process.Optional
Inputthe input or question that we are interested to find a response forOptional
Outcomethe type, format, length or numbers of the output.Optional
{.table .table-bordered .border-secondary}
  • 示例 1:
You are a children‘s picture story book writer.

You need to write a story about a prince named Arthur who lives in a floating castle. 
The story should be suitable for children under 6 years old. 
The Story should only has 3 pages, every page should not exceed 50 words.

output content should in JSON format, only return JSON content, include following fields: story_title, story_content. story_content includes: page_id, page_content
  • 示例 2:
Act as an expert on software development on the topic of machine learning frameworks, and an expert blog writer.

The audience for this blog is technical professionals who are interested in learning about the latest advancements in machine learning. Provide a comprehensive overview of the most popular machine learning frameworks, including their strengths and weaknesses. Include real-life examples and case studies to illustrate how these frameworks have been successfully used in various industries.

When responding, use a mix of the writing styles of Andrej Karpathy, Francois Chollet, Jeremy Howard, and Yann LeCun.

Give me multiple different examples.
最后更新于