大语言模型提示模板与输出解析器的深度解析
1. 提示模板的初步预览与示例选择
在使用大语言模型时,提示模板是引导模型生成准确回答的重要工具。我们可以通过以下代码预览格式化后的提示模板:
print(prompt.format(input="What is the capital of Australia?"))
输出示例如下:
Question: What is the largest planet in our solar system?
Answer: Jupiter is the largest planet in our solar system.
Question: Who painted the Mona Lisa?
Answer: The Mona Lisa was painted by Leonardo da Vinci.
Question: What is the currency of Japan?
Answer: The currency of Japan is the Japanese yen.
Question: What is the capital of Australia?
当我们有大量示例时,可以使用示例选择器来挑选最相关的示例。这里以 LengthBasedExampleSelector 为例,它会根据示例的长度来选择示例。以下是初始化选择器并选择示例的代码:
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



