前言

​ 本文简单介绍一下Auto-GPT是什么,以及实现原理,不涉及安装与使用教程和api key的获取。


正文

一、什么是Auto-GPT

​ 官方项目的描述是这样的:Auto-GPT is an experimental open-source application showcasing the capabilities of the GPT-4 language model. This program, driven by GPT-4, chains together LLM “thoughts”, to autonomously achieve whatever goal you set. As one of the first examples of GPT-4 running fully autonomously, Auto-GPT pushes the boundaries of what is possible with AI.

​ 大白话就是自动执行,达到用户的期望目标。

二、Auto-GPT的特性

直接给出官方定义,一目了然。

🌐 Internet access for searches and information gathering

💾 Long-term and short-term memory management

🧠 GPT-4 instances for text generation

🔗 Access to popular websites and platforms

🗃️ File storage and summarization with GPT-3.5

🔌 Extensibility with Plugins


三、Auto-GPT的原理

​ 在解释原理前,需要先介绍一下使用Auto-GPT时需要设定的信息,当运行时,程序会要求用户设置三个变量:机器人名字(ai_name)、机器人的角色(ai_role)、期望完成的目标(ai_goals)。程序会根据这三个变量自动执行得到ai_goals。

​ 那么如何自动执行呢?利用Prompt!逻辑上应该是这样的:

​ 用户抛出一个目标,要求GPT4分解目标,得到几个小目标和下一步目标,将小目标保存,将下一步目标再抛给GPT4,重复这个过程,这样就能既分解了目标又有了执行计划,从而完成自动的、连续的执行流程。

​ 这是我们可以想到的符合逻辑的步骤,其中的细节还有很多,Auto-GPT就做的非常好,原理代码,即Prompt相关代码在项目目录autogpt下的promptgenerator.py文件和prompt.py文件中。

​ 比如先给GPT4设定规则,定义了回复格式,能进行的操作,可以使用的资源以及其他限制:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Add constraints to the PromptGenerator object
prompt_generator.add_constraint(
"~4000 word limit for short term memory. Your short term memory is short, so"
" immediately save important information to files."
)
prompt_generator.add_constraint(
"If you are unsure how you previously did something or want to recall past"
" events, thinking about similar events will help you remember."
)
prompt_generator.add_constraint("No user assistance")
prompt_generator.add_constraint(
'Exclusively use the commands listed in double quotes e.g. "command name"'
)
prompt_generator.add_constraint(
"Use subprocesses for commands that will not terminate within a few minutes"
)
# Define the command list
...
# Add resources to the PromptGenerator object
prompt_generator.add_resource(
"Internet access for searches and information gathering."
)
prompt_generator.add_resource("Long Term memory management.")
prompt_generator.add_resource(
"GPT-3.5 powered Agents for delegation of simple tasks."
)
prompt_generator.add_resource("File output.")

# Add performance evaluations to the PromptGenerator object
prompt_generator.add_performance_evaluation(
"Continuously review and analyze your actions to ensure you are performing to"
" the best of your abilities."
)
prompt_generator.add_performance_evaluation(
"Constructively self-criticize your big-picture behavior constantly."
)
prompt_generator.add_performance_evaluation(
"Reflect on past decisions and strategies to refine your approach."
)
prompt_generator.add_performance_evaluation(
"Every command has a cost, so be smart and efficient. Aim to complete tasks in"
" the least number of steps."
)

有了这样的Prompt,GPT4才能输出符合要求的信息。

四、GUI界面与中文汉化

​ Auto-GPT是一个终端显示的程序,对于普通用户,可能希望在gui界面上点点点就能完成,同时需要支持中文版。

​ 这些都有相关项目实现,比如GUI项目,只需要nodejs环境和python环境即可。

这里要注意的是,这个项目目前没有进一步维护,使用的还是v1版的Auto-GPT,目前Auto-GPT是v2版,两者的执行命令不同,相关代码在项目目录apps\frontend\src\hooks下的useAutoGPTStarter.ts文件中,修改函数useAutoGPTStarter中的command变量,对于v1版Auto-GPT的执行命令是python scripts/main.py,对于v2版执行命令是python -m autogpt

​ Auto-GPT的中文版可以使用这个项目,与官方项目保持同步。

五、总结

​ 基于AutoGPT,未来可以完成许多有趣和有用的工作。以下是一些展望:

​ 1.更加高效的自然语言处理:AutoGPT可以通过自动化模型选择和超参数优化来提高自然语言处理任务的效率和性能。

​ 2.自动文本生成:AutoGPT可以自动完成文本生成,包括自动生成文章、摘要、对话等,为人类提供更多的文本资源。

​ 3.自动代码生成:AutoGPT可以学习现有的代码库,自动生成代码,提高软件开发的效率。

​ 4.自动语音识别和生成:AutoGPT可以用于语音识别和生成,通过学习语音模式和语音特征,自动生成语音内容。

​ 5.自动机器翻译:AutoGPT可以用于机器翻译,通过学习不同语言之间的映射关系,自动翻译文本内容。

​ 以上是ChatGPT给的展望:cry:,于我而言,目前Auto-GPT还是早期阶段,执行流程还不完善,并且访问互联网的能力还不够,所以开发作者又开了Plugin的功能,见项目,随着开发的迭代,估计不久的将来,钢铁侠的javis就不是漫画了:lol:。

​ 最后想说的是,ChatGPT是一个里程碑,不是它有多无敌,而是开创了类似互联网兴起的一股社会变革,会永久改变人类的生活习惯。

​ 想起比尔·盖茨在上世纪末时的一个节目采访,和现在的情形很像,处于初期阶段,人们还没有发展出应用领域,慢慢的就会有应用雏形出现的,有句话叫“人总是高估明年的事,低估10年后的事”,10年是以前的经验,现在可能得改成5年了吧。

最后

参考文章

Auto-GPT官方项目

Auto-GPT中文版

Auto-GPT-GUI

比尔·盖茨脱口秀解释互联网


声明

本文仅作为个人学习记录。

本文永久记录于区块链博客xlog