专栏名称: 大数据文摘
普及数据思维,传播数据文化
目录
相关文章推荐
人工智能与大数据技术  ·  AI编程新王Claude ... ·  2 天前  
软件定义世界(SDX)  ·  【PPT】AI的前世今生 | ... ·  2 天前  
数据派THU  ·  AAAI 25 | ... ·  3 天前  
51好读  ›  专栏  ›  大数据文摘

某机构:JSON 输出会让 AI 变笨!大佬:是你们太菜了

大数据文摘  · 公众号  · 大数据  · 2024-12-27 14:00

正文

请到「今天看啥」查看全文



一个完整的 prompt 应该是包含了足够多的信息,以便于一个正常的人类能够正确回答问题。于是,博文的作者 Will Kurt对这个 prompt 进行了重新改写!

为 JSON 编写正确的 prompt


改进之后的 prompt 长下面这个样子:
system
You are an expert in solving simple word puzzles using reasoning steps. Your specific  task is going to be to take a list of 4 names and reason about the last letter of each .,  then you will concatenate those letters into a word. The Question will be plaintest from the user  and response will be formatted as JSON below:
{"reasoning": , "answer": }user
Question: Take the last letters of each words in 'Ian Peter Bernard Stephen' and concatenate them.assistant
{"reasoning": "The last letter of 'Ian' is 'N', the last letter of 'Peter' is 'R', the last letter of 'Bernard' is 'D', and the last letter of 'Stephen' is 'N'. Therefore, the answer is 'NRDN'.", "answer": "NRDN"}user
Question: Take the last letters of each words in "Britt Tamara Elvis Nayeli" and concatenate them.",assistant
  

我们可以看到 Will Kurt改进了很多点:

  • 使用了适合模型的指令格式。
  • 提供一个有正确结构并且和任务相匹配的示例。
  • 以一个空的“assistant”prompt 结束,以便以我们想要的结构开始生成输出。


定义自己的结构


接下来, Will Kurt还定义了一个自己的结构。对于论文中的Last Letter 任务,作者使用了一个简单的 Pydantic 模型:


在这里 Will Kurt 限制了推理步骤为 250 个字符,以确保推理不会花费太长时间,并且还将答案限制为 4 个有效字母。

过程中有一个重要步骤是验证 prompt 中是否包含了定义的结构。prompt 的重点是为大模型做好充分的准备,如果我们没有向它展示我们想要的确切结构,模型就不得不花更大的代价去学习。以下是确保 prompt 与结构匹配的代码:


验证后,终于可以进入正题了!

JSON 结果


现在,让我们看看结构化生成和非结构化生成进行公平对比之后的结果。


是好消息!结构化生成优于非结构化生成。上图可以看出,非结构化 JSON 结果(73% 的准确率)优于结构化 NL 的(68% 的准确率)结果,但最后的赢家还是准确率为 77% 的结构化 JSON!


当然啦,博文中 diss 的可不仅仅是 prompt 设置的不够合理这一个问题, Will Kurt认为“Speak Freely”中对结构化生成理解有些偏颇,导致整个实验过程逻辑不够流畅。






请到「今天看啥」查看全文