当前位置:首页> AI教程> AutoGPT: 一个基于GPT大模型的自动化程序

AutoGPT: 一个基于GPT大模型的自动化程序

释放双眼,带上耳机,听听看~!
了解AutoGPT,一个基于GPT大模型的自动化程序,具有人工智能代理的能力,可自主执行任务和作出决策,了解其工作原理和用途。

大家最近经常被ChatGPT刷屏,但是最近又出来个AutoGPT,也是一个大模型,它是在GitHub源码地址上开源的一个Python程序。它用了差不多一个月的时间Start数就飙升到100K。

AutoGPT: 一个基于GPT大模型的自动化程序

Auto-GPT是一个开源的人工智能项目,建立在ChatGPT的生成性预训练转化器(GPT)上。它的核心功能使GPT有能力自主行动,而不需要人类代理来提示它的每一个行动。虽然不是一项新技术,但Auto-GPT不是一个新的大型语言模型或人工智能聊天机器人。

Auto-GPT的工作方式与ChatGPT类似,但有AI代理提供的额外能力。你可以把人工智能代理想象成个人助理,可以被编程执行特定的任务,或根据一组规则和预定的目标做出决定。人工智能代理,像个人助理一样,可以代表个人运作,执行诸如安排约会和发送电子邮件等任务。Auto-GPT,其人工智能代理,具有额外的能力,可以在没有人类提示的情况下执行自主行动并作出决定。说了一堆不知道啥意思?我总结一下:

AutoGPT是一个程序,它基于GPT大模型对自然语言的理解能力,能基于用户下达的需求自动的拆解需求和制定计划,并利用AutoGPT程序里内置的一些基本能力(如文件的读写、数据库、逻辑运算、内存、其他小模型的能力)来执行计划并拿到中间数据,最终利用这些中间数据和多轮的自主迭代来完成用户的需求。

AutoGPT是基于OpenAI GPT大模型的能力的一个封装,而和GPT交互最核心的又是prompt,也就是我们平时使用chatGPT时要提供各种丰富的prompt的原因。所以我们就分析一下这个AutoGPT是如何组织prompt,然后实现了上边提到那些酷炫的能力的。我们看一个AutoGPT的prompt,来分析一下:

—以下都是prompt内容

System: You are alice, You are a researcher in the American math training market
Your decisions must always be made independently without seeking user assistance. Play to your strengths as an LLM and pursue simple strategies with no legal complications.

以上是给AutoGPT做一些基础设定,比如名字、身份、行为

  1. Analyze the top10 math training institutions in the United States
  2. The data are analyzed from the dimensions of market size, user distribution and teaching service
  3. Produce a market analysis report in excel format

以上部分是用户输入的目标,也就是你希望AutoGPT帮你做的事情是什么

  1. ~4000 word limit for short term memory. Your short term memory is short, so immediately save important information to files.
  2. If you are unsure how you previously did something or want to recall past events, thinking about similar events will help you remember.
  3. No user assistance
  4. Exclusively use the commands listed in double quotes e.g. “command name”

以上部分是对AutoGPT的一些约束条件,比如Token数的设置、自主分析不要依赖用户帮助、命令的选择说明等

  1. Google Search: “google”, args: “input”: “”
  2. Browse Website: “browse_website”, args: “url”: “”, “question”: “<what_you_want_to_find_on_website>”
  3. Start GPT Agent: “start_agent”, args: “name”: “”, “task”: “<short_task_desc>”, “prompt”: “”
  4. Message GPT Agent: “message_agent”, args: “key”: “”, “message”: “”
  5. List GPT Agents: “list_agents”, args:
  6. Delete GPT Agent: “delete_agent”, args: “key”: “”
  7. Clone Repository: “clone_repository”, args: “repository_url”: “”, “clone_path”: “”
  8. Write to file: “write_to_file”, args: “file”: “”, “text”: “”
  9. Read file: “read_file”, args: “file”: “”
  10. Append to file: “append_to_file”, args: “file”: “”, “text”: “”
  11. Delete file: “delete_file”, args: “file”: “”
  12. Search Files: “search_files”, args: “directory”: “”
  13. Evaluate Code: “evaluate_code”, args: “code”: “<full_code_string>”
  14. Get Improved Code: “improve_code”, args: “suggestions”: “<list_of_suggestions>”, “code”: “<full_code_string>”
  15. Write Tests: “write_tests”, args: “code”: “<full_code_string>”, “focus”: “<list_of_focus_areas>”
  16. Execute Python File: “execute_python_file”, args: “file”: “”
  17. Generate Image: “generate_image”, args: “prompt”: “”
  18. Send Tweet: “send_tweet”, args: “text”: “”
  19. Convert Audio to text: “read_audio_from_file”, args: “file”: “”
  20. Do Nothing: “do_nothing”, args:
  21. Task Complete (Shutdown): “task_complete”, args: “reason”: “”

以上是AutoGPT这个程序的一个核心部分,这里定义了AutoGPT内置的基础命令及命令所需的参数,比如使用google搜索关键字、使用浏览器抓取网页数据、使用语言模型进行文本数据分析、文件的读写等操作。AutoGPT就是通过这些内置的命令,给GPT插上了手脚,让它有了记忆,有了联网等能力。

  1. Internet access for searches and information gathering.
  2. Long Term memory management.
  3. GPT-3.5 powered Agents for delegation of simple tasks.
  4. File output.

以上部分声明了AutoGPT在执行过程中,可以利用的数据源,比如网络、内存等

  1. Continuously review and analyze your actions to ensure you are performing to the best of your abilities.
  2. Constructively self-criticize your big-picture behavior constantly.
  3. Reflect on past decisions and strategies to refine your approach.
  4. Every command has a cost, so be smart and efficient. Aim to complete tasks in the least number of steps.

以上部分声明了GPT要如何更好的工作和调优

You should only respond in JSON format as described below
Response Format:

{
  "thoughts":
  {
    "text": "thought",
    "reasoning": "reasoning",
    "plan": "- short bulletedn- list that conveysn- long-term plan",
    "criticism": "constructive self-criticism",
    "speak": "thoughts summary to say to user"
  },
  "command":
  {
    "name": "command name",
    "args":
    {
      "arg name": "value"
    }
  }
}
Ensure the response can be parsed by Python json.loads

以上这部分是AutoGPT的另一个核心,它要求GPT的返回不再是一个简单的文本,而是一个标准的Json结构的数据,这个json结构所携带的内容就是AutoGPT能自主执行的原因所在,个人认为这部分也是AutoGPT思路的精华所在。接下来我们一起看分析一下这个JSON结构的各个字段。
1、thoughts字段可以理解为GPT对用户需求的思考,大家重点关注它内部字段的一些说明,比如:
a.text字段的说明是”thought”;
b.plan字段的说明是”- short bulletedn- list that conveysn- long-term plan”;
c.speak字段的说明是”thoughts summary to say to user”;
AutoGPT就是通过这些对字段的说明,来引导GPT基于对用户需求的理解来填充这个Json结构,GPT在填充这个结果的过程中,会展示它对用户目标是如何理解的,这么理解的原因是什么,基于这个理解生成的计划是什么,对这个计划的结果要如何评价以及想对用户说的话。
2、command字段是要求gpt基于用户的目标和thoughts字段的思考,从上面的Commands列表里选择一个命令和参数提取。

看到这里,大家有没有觉得这个思路很厉害!!打开了一个新的方向有木有!!这个数据结构非常重要,它直接决定了AutoGPT的具体执行效果和聪明程度。这部分大家需要重点消化一下,不管是命令的选择还是参数的提取,是不是和我们工程师写代码有点类似呢?

System: This reminds you of these events from your past:

这部分会填充上AutoGPT在每轮迭代过程中产生的中间数据和对话历史,让GPT有了记忆,也可以理解为是内存。当然这部分内存不是可以无限填充的,它受maxtokens的限制。

User: Determine which next command to use, and respond using the format specified above:

最后一句,用user的身份告诉GPT,基于用户的目标和你的思考以及记忆,选择下一个命令

—以上都是prompt内容

好了,这就是AutoGPT内部prompt的组织形式,它就是通过这个prompt的结构来和GPT交互的,基本上也可以理解为这就是AutoGPT的工作原理。建议大家好好消化一下这部分,为了让大家更直观的理解这部分,看一个实际的例子:
AutoGPT: 一个基于GPT大模型的自动化程序
上面这个例子是下达完任务的第一轮迭代,后面AutoGPT还会根据这个任务目标自己迭代多轮,但篇幅有限,这里就不展开了。当然AutoGPT能实现这么好的效果,不单单只是靠写一个prompt就能实现的。它其实做了很多工程化的编码来支撑这个prompt,比如那些基础命令的实现、数据的管理、记忆的管理等,这部分不是今天的重点,建议大家有兴趣的直接去阅读源码。这里给大家贴一张代码的整体逻辑图。

AutoGPT: 一个基于GPT大模型的自动化程序

在AutoGPT出来之前,我们的注意力都在ChatGPT上,它上线以后表现出来的对自然语言理解的能力,让我们都很震惊。我们也在第一时间学习了openAI的开发文档,并做了一些应用场景的尝试,比如文本生成等,这些应用场景都是基于文本处理的。因为我们对它的认识就是文本处理能力很强,所以这也就决定了我们如何应用它。但在学习了AutoGPT以后,突然发现,原来还可以这么玩!思路一下就打开了,我们可以自己内置一些自定义的基础命令,然后有逻辑的组织交给AutoGPT,然后让它返回给我需要的结构化数据。这是不是和我们日常的编码工作有点像?OpenAI的插件系统其实也是这样一个设计思路,对用户输入的自然语言做理解分析,然后转发给特定插件去做更具体的动作。所以也就间接印证了一个好的prompt的重要性。

本网站的内容主要来自互联网上的各种资源,仅供参考和信息分享之用,不代表本网站拥有相关版权或知识产权。如您认为内容侵犯您的权益,请联系我们,我们将尽快采取行动,包括删除或更正。
AI教程

文本转视频工具实现原理及效果展示

2023-11-28 10:26:14

AI教程

单目摄像头测距原理及应用

2023-11-28 10:41:14

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索