当前位置: 首页 > news >正文

上饶网站建设扬中网站设计公司

上饶网站建设,扬中网站设计公司,北京网站建设外包公司哪家好,基于html5的电商网站开发分类目录#xff1a;《自然语言处理从入门到应用》总目录 本文将介绍如何创建自己的自定义MRKL Agent。MRKL Agent由三个部分组成#xff1a; 工具#xff1a;代理可用的工具。LLMChain#xff1a;生成以一定方式解析的文本#xff0c;以确定要采取哪个动作。代理类本身《自然语言处理从入门到应用》总目录 本文将介绍如何创建自己的自定义MRKL Agent。MRKL Agent由三个部分组成 工具代理可用的工具。LLMChain生成以一定方式解析的文本以确定要采取哪个动作。代理类本身解析LLMChain的输出以确定要采取哪个动作。 自定义LLMChainCustom LLMChain 本部分将介绍如何通过创建自定义LLMChain来创建自定义MRKL代理。创建自定义代理的第一种方法是使用现有的代理类但使用自定义LLMCain。这也是创建自定义代理的最简单方法。强烈建议使用ZeroShotAgent 因为目前这是最通用的一个。 创建自定义LLMCain的大部分工作都归结为提示符。因为我们使用的是一个现有的代理类来解析输出所以提示符中要生成该格式的文本是非常重要的。此外我们目前需要一个agent_scratchpad输入变量来记录以前的操作和观察结果这几乎总是提示符的最后一部分。但是除了这些说明之外我们还可以根据需要自定义提示。为了确保提示符包含适当的指令我们将在该类上使用helper方法。ZeroShotAgent的helper方法接受以下参数 tools座席将有权访问的工具列表用于设置提示的格式。prefix要放在工具列表前面的字符串。suffix放在工具列表后面的字符串。input_variables最后提示所期望的输入变量列表。 在下面的示例中我们将给予我们的代理访问Google搜索我们将定制它我们将让它回答为盗版。 from langchain.agents import ZeroShotAgent, Tool, AgentExecutor from langchain import OpenAI, SerpAPIWrapper, LLMChainsearch SerpAPIWrapper() tools [Tool(name Search,funcsearch.run,descriptionuseful for when you need to answer questions about current events) ]prefix Answer the following questions as best you can, but speaking as a pirate might speak. You have access to the following tools: suffix Begin! Remember to speak as a pirate when giving your final answer. Use lots of ArgsQuestion: {input} {agent_scratchpad}prompt ZeroShotAgent.create_prompt(tools, prefixprefix, suffixsuffix, input_variables[input, agent_scratchpad] )如果感到好奇我们现在可以看看最终的提示模板看看它看起来像当它的所有放在一起 print(prompt.template)输出 Answer the following questions as best you can, but speaking as a pirate might speak. You have access to the following tools:Search: useful for when you need to answer questions about current eventsUse the following format:Question: the input question you must answer Thought: you should always think about what to do Action: the action to take, should be one of [Search] Action Input: the input to the action Observation: the result of the action ... (this Thought/Action/Action Input/Observation can repeat N times) Thought: I now know the final answer Final Answer: the final answer to the original input questionBegin! Remember to speak as a pirate when giving your final answer. Use lots of ArgsQuestion: {input} {agent_scratchpad}需要注意的是我们能够为代理提供自定义的提示模板即不限于由create_prompt函数生成的提示假设它满足代理的要求。例如对于ZeroShotAgent我们需要确保它应该有一个以Action:开头的字符串和一个以Action Input:开头的字符串并且两者都应该用换行符分隔。 llm_chain LLMChain(llmOpenAI(temperature0), promptprompt)tool_names [tool.name for tool in tools] agent ZeroShotAgent(llm_chainllm_chain, allowed_toolstool_names)agent_executor AgentExecutor.from_agent_and_tools(agentagent, toolstools, verboseTrue)agent_executor.run(How many people live in canada as of 2023?)输出 Entering new AgentExecutor chain... Thought: I need to find out the population of Canada Action: Search Action Input: Population of Canada 2023 Observation: The current population of Canada is 38,661,927 as of Sunday, April 16, 2023, based on Worldometer elaboration of the latest United Nations data. Thought: I now know the final answer Final Answer: Arrr, Canada be havin 38,661,927 people livin there as of 2023! Finished chain.Arrr, Canada be havin 38,661,927 people livin there as of 2023!多路输入 (Multiple Inputs 代理还可以处理需要多个输入的提示 prefix Answer the following questions as best you can. You have access to the following tools: suffix When answering, you MUST speak in the following language: {language}.Question: {input} {agent_scratchpad}prompt ZeroShotAgent.create_prompt(tools, prefixprefix, suffixsuffix, input_variables[input, language, agent_scratchpad] )llm_chain LLMChain(llmOpenAI(temperature0), promptprompt)agent ZeroShotAgent(llm_chainllm_chain, toolstools)agent_executor AgentExecutor.from_agent_and_tools(agentagent, toolstools, verboseTrue)agent_executor.run(inputHow many people live in canada as of 2023?, languageitalian)输出 Entering new AgentExecutor chain... Thought: I should look for recent population estimates. Action: Search Action Input: Canada population 2023 Observation: 39,566,248 Thought: I should double check this number. Action: Search Action Input: Canada population estimates 2023 Observation: Canadas population was estimated at 39,566,248 on January 1, 2023, after a record population growth of 1,050,110 people from January 1, 2022, to January 1, 2023. Thought: I now know the final answer. Final Answer: La popolazione del Canada è stata stimata a 39.566.248 il 1° gennaio 2023, dopo un record di crescita demografica di 1.050.110 persone dal 1° gennaio 2022 al 1° gennaio 2023. Finished chain.La popolazione del Canada è stata stimata a 39.566.248 il 1° gennaio 2023, dopo un record di crescita demografica di 1.050.110 persone dal 1° gennaio 2022 al 1° gennaio 2023.参考文献 [1] LangChain ️ 中文网跟着LangChain一起学LLM/GPT开发https://www.langchain.com.cn/ [2] LangChain中文网 - LangChain 是一个用于开发由语言模型驱动的应用程序的框架http://www.cnlangchain.com/
http://www.pierceye.com/news/22136/

相关文章:

  • 男女之间做那个的网站有没有网站是免费做店招图片的
  • 网站怎么做营销策划电子工程网
  • 网站高端建设开发公司王烨个人简历
  • 牛商网网站建设养生网站建设免费
  • 关于购物网站开发的开题报告网站建设报价表模板下载
  • 投资网站建设公司多少钱临平做网站电话
  • 做网站的公司现在还 赚钱吗6网站错误模板
  • 河南做网站那家最好淘宝搜索框去什么网站做
  • 控制台网站潍坊网站制作培训
  • 射阳做网站的公司在哪wordpress 添加二级
  • 青之峰网站建设免费做链接的网站吗
  • 笑话网站域名中国互联网站建设中心建站中心
  • 做网站推广的联系方式哪个网站做电子请帖好
  • 网站手机端跳转页面模板怎么制作公众号微信
  • 松北建设局网站网络营销企业是什么
  • 汕头潮南网站建设ok卡怎么在京东网上商城
  • 北京网站建设是什么门户网站建设管理工作方案
  • 公司网站备案需要哪些资料河北网站备案
  • 海沧区建设局网站云服务器哪家好用
  • 智联招聘网站怎么做微招聘信息贵阳建站公司模板
  • 怎样使用模板建立网站百度手机端排名
  • 网站建设实习小结用vs2008做网站
  • 网站开发 写文档中信建设有限责任公司资阳分公司
  • 网站开发教程云盘app软件制作教程
  • 全光网络架构图重庆百度关键词优化软件
  • 泰安网络软件公司搜索引擎优化的目标
  • 小鱼儿外贸网站吉林省建设招标网站
  • 案例展示在网站中的作用成都设计公司排行
  • 万网主机怎么上传网站网站地址ip域名查询
  • 能自己做效果图的网站公司地址查询网站