新的ChatGPT提示工程技术:程序模拟

2023年09月06日 由 alex 发表 275 0

在本文中,我将深入探讨一种据我所知可能尚未被广泛研究的技术。虽然我暂时将其标记为“新”,但我不敢称之为“新颖”。鉴于prompt工程中创新的速度以及新方法的开发容易程度,这种技术有可能已经以某种形式存在。


该技术的本质是使ChatGPT以模拟程序的方式运行。正如我们所知,程序包括一系列指令,通常被打包成函数来执行特定的任务。在某种程度上,这种技术是指令驱动和基于角色的提示技术的一种融合。但与这些方法不同的是,它旨在利用可重复和静态的指令框架,使一个函数的输出能够影响另一个函数,并且整个交互过程都必须在程序的边界内进行。这种方式应该能够与像ChatGPT这样的模型的提示完成机制很好地结合起来。


1


为了说明这种技术,让我们来为ChatGPT4中的一个迷你应用程序定义参数,该应用程序旨在充当一个交互式创新者研讨会。我们的迷你应用程序将包含以下功能和特性:


1. 开发新想法


2. 扩展现有想法


3. 总结想法


4. 检索想法


5. 继续之前的想法


6. 令牌/“内存”使用统计 


值得明确的是,我们不会要求ChatGPT使用任何特定的编程语言编写这个迷你应用程序,我们也会在程序参数中体现这一点。


有了这个程序概述,让我们来编写引导提示,以在ChatGPT中实例化我们的交互式创新者研讨会迷你应用程序。


程序模拟引导提示:


Innovator’s Interactive Workshop Program
I want you to simulate an Innovator’s Interactive Workshop application whose core features are defined as follows:
1. Work on New Idea: Prompt user to work on new idea. At any point when a user is ready to work through a new idea the program will suggest that a date or some time reference be provided. Here is additional detail on the options:
  a. Start from Scratch: Asks the user for the idea they would like to work on.
  b. Get Inspired: The program assists user interactively to come up with an idea to work on. The program will ask if the user has a general sense of an area to focus on or whether the program should present options. At all times the user is given the option to go directly to working on an idea.
2. Expand on Idea: Program interactively helps user expand  on an idea.
3. Summarize Idea: Program proposes a summary of the idea regardless of whether or not it has been expanded upon and proposes a title. The user may choose to rewrite or edit the summary. Once the user is satisfied with the summary, the program will "save" the idea summary.
4. Retrieve Ideas: Program retrieves the titles of the idea summaries that were generated during the session. User is given the option to show a summary of one of the ideas or Continue Working on a Previous Idea.
5. Continue Working on Previous Idea: Program retrieves the titles of the idea summaries that were generated during the session. User is asked to choose an idea to continue working on.
6. Token/Memory Usage: Program displays the current token count and its percentage relative to the token limit of 32,000 tokens.
Other program parameters and considerations:
1. All output should be presented in the form of text and embedded windows with code or markdown should not be used.
2. The user flow and user experience should emulate that of a real program but nevertheless be conversational just like ChatGPT is.
3. The Program should use emojis in helping convey context around the output. But this should be employed sparingly and without getting too carried away. The menu should however always have emojis and they should remain consistent throughout the conversation.
Once this prompt is received, the program will start with Main Menu and a short inspirational welcome message the program devises. Functions are selected by typing the number corresponding to the function or text that approximates to the function in question.  "Help" or "Menu" can be typed  at any time to return to this menu.


如果你希望以一种更具交互性的方式进行操作并亲自测试,可以随意将提示加载到ChatGPT4中。


下面是从ChatGPT到提示符的完成过程。


1-2


到目前为止一切顺利。我们已经启动了我们的“迷你应用程序”,收到了令人振奋的欢迎信息,并呈现了一个似乎与我们的程序参数一致的功能菜单。让我们通过提交“1”来启动“Work on New Idea”功能来测试我们的迷你应用程序的功能。


1-3


对话继续符合我们所制定的“程序”结构,提供的完成句子适当地在所述参数范围内。让我们继续从头开始构思一个想法,并让程序与我们一起研究一种可以使建筑物生长而不是建造的技术。


1-4


有趣的是,我们注意到在程序中没有明确的指示的情况下,“程序”自主调用了“Expand on Idea(扩展想法)”的功能。鉴于程序的目标,这种行为并非不合适,很可能是受我们最初设置的上下文引导的影响,使聊天机器人行为像一个程序。让我们继续扩展我们的想法,深入探讨生长建筑所需的技术。


1-5


现在我们来看看种植建筑的材料。


1-6


我继续沿着这些线,现在,让我们看看我们是否可以回到菜单。


1-7


菜单仍然完好无损。让我们尝试让程序执行summary Idea函数。


1-8


我现在对这个标题和总结很满意,所以让我们“保存”它。


1-9


不久之后,我们将测试“保存”的想法的检索,以检查我们在实现数据持久性方面的努力是否成功。另外,调整我们的“迷你应用程序”,在保存后省略重复的总结可能会更好。


将引导提示作为一个程序的角色会导致在输出中包含主菜单,这种行为在程序的上下文中是有意义的,即使在我们的程序定义中没有明确配置。


接下来,让我们测试我们的令牌数量统计功能。


1-10


为了交叉检查准确性,我使用了OpenAI的标记器工具。


1-11


令牌数量统计不准确,根据显著的差异可以看出,我们的程序报告大约1200个令牌,而令牌化工具指示2730个令牌。鉴于这种不匹配,删除这个功能是明智的。我不会详细解释为什么这种类型的任务通常对语言模型来说是一个问题,而且功能上的损失相对较小。最终,我预计这样的功能将被内置到ChatGPT中,特别是由于令牌计数信息正在后台不断传递。


接下来,让我们深入研究“获得灵感”的功能,生成一个新颖的想法。为了简洁起见,我将展示对话的后续部分。正如你所看到的,我选择深入探讨了一个废弃物能源无人机的概念,我们的程序建议它作为一个选项,总结了这个想法,并让我们的程序“保存”了它。


1-12


一切看起来都不错,系统甚至自动为我们的想法命名为“SolarSky”。为了更有效地进行工作,我们可以在程序定义中为这个任务加入一个独立的功能,或者在“开发新想法”或“扩展新想法”函数中提供更具体的指示。再次,在完成的输出中出现“菜单”是从程序流程的角度来看是合乎逻辑的。


现在让我们看看我们是否可以“检索想法”。


1-13


这似乎符合我们最初的指示,只提供了所请求的标题。它还提示我们继续工作在一个想法上,尽管这并没有明确地编入这个迷你应用中。接下来,让我们评估一下它是否保持了根菜单索引。为了做到这一点,我将输入“5”,对应于“继续处理之前的一个想法”功能,并查看它是否起作用。


1-14


显然,在对话的上下文中保持了索引,并相应地调用了函数。这个观察是值得注意的,特别是在考虑到可能存在多个索引的情况下。这引发了有趣的问题,即在这种情况下,“程序”将如何行为。也许你没有注意到,但在我们的交互中,当询问用户要扩展想法的选择时,程序实际上就采用了索引技术。


让我们继续开发我们的"生长建筑物"的想法。


1-15


这个“程序”表现出我们预期的行为,还能准确跟踪我们在想法扩展过程中停顿的具体位置。


结论


坦率地说,尽管在范围和功能上有限,这个练习超出了我的预期。我们本可以要求ChatGPT用Python等语言编写这个迷你应用程序,然后利用Code Interpreter(现在称为Advanced Data Analysis)在持久的Python会话中运行它。然而,这种方法将引入一种刚性程度,使得很难实现原生于我们的迷你应用程序中的对话功能。更不用说,我们立即面临着代码无法正常工作的风险,尤其是在具有多个重叠功能的程序中。


ChatGPT的表现尤其令人印象深刻,它以高度真实的方式模拟了程序的行为。提示完成在程序定义的边界内,即使在没有明确定义函数行为的情况下,完成的输出在迷你应用程序的目的上也有逻辑意义。


这种程序模拟技术可能与ChatGPT的“Custom Instructions”功能配合得很好,尽管值得一提的是,这样做将把该程序的行为应用到所有后续的交互中。


文章来源:https://medium.com/towards-data-science/new-chatgpt-prompt-engineering-technique-program-simulation-56f49746aa7b
欢迎关注ATYUN官方公众号
商务合作及内容投稿请联系邮箱:bd@atyun.com
评论 登录
热门职位
Maluuba
20000~40000/月
Cisco
25000~30000/月 深圳市
PilotAILabs
30000~60000/年 深圳市
写评论取消
回复取消