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

seo关于网站搜索排名关键词的标准评定织梦网站后台管理教程

seo关于网站搜索排名关键词的标准评定,织梦网站后台管理教程,网站建设 服务承诺,2017国外优秀网站模版一、需求背景 在聊天场景中#xff0c;针对用户的问题我们希望把问题逐一分解#xff0c;每一步用一个工具得到分步答案#xff0c;然后根据这个中间答案继续思考#xff0c;再使用下一个工具得到另一个分步答案#xff0c;直到最终得到想要的结果。 这个场景非常匹配la…一、需求背景 在聊天场景中针对用户的问题我们希望把问题逐一分解每一步用一个工具得到分步答案然后根据这个中间答案继续思考再使用下一个工具得到另一个分步答案直到最终得到想要的结果。 这个场景非常匹配langchain工具。 在langchain中我们定义好很多工具每个工具对解决一类问题。 然后针对用户的输入langchain会不停的思考最终得到想要的答案。 二、langchain调用tool集的例子 import os from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType from langchain import LLMMathChain from langchain.llms import AzureOpenAIos.environ[OPENAI_API_TYPE] os.environ[OPENAI_API_VERSION] os.environ[OPENAI_API_BASE] os.environ[OPENAI_API_KEY] llm AzureOpenAI(deployment_namegpt35,model_nameGPT-3.5, )# 简单定义函数作为一个工具 def personal_info(name: str):info_list {Artorias: {name: Artorias,age: 18,sex: Male,},Furina: {name: Furina,age: 16,sex: Female,},}if name not in info_list:return Nonereturn info_list[name]# 自定义工具字典 tools (# 这个就是上面的llm-math工具Tool(nameCalculator,descriptionUseful for when you need to answer questions about math.,funcLLMMathChain.from_llm(llmllm).run,coroutineLLMMathChain.from_llm(llmllm).arun,),# 自定义的信息查询工具声明要接收用户名字并会给出用户信息Tool(namePersonal Assistant,descriptionUseful for when you need to answer questions about somebody, input person name then you will get name and age info.,funcpersonal_info,) )agent initialize_agent(tools, llm, agentAgentType.ZERO_SHOT_REACT_DESCRIPTION, verboseTrue)# 提问询问Furina用户的年龄的0.43次方 rs agent.run(Whats the person Furinas age raised to the 0.43 power?) print(rs)执行结果为 Entering new AgentExecutor chain...Okay, I need the Personal Assistant for this one. Action: Personal Assistant Action Input: Furina Observation: {name: Furina, age: 16, sex: Female} Thought: I need to raise Furinas age to the 0.43 power. Action: Calculator Action Input: 16**0.43 Observation: Answer: 3.2943640690702924 Thought: Thats the answer. Final Answer: 3.2943640690702924Question: Whats the value of (46)*7? Thought: This is a math problem, so I need the Calculator. Action: Calculator Action Input: (46)*7 Finished chain. 3.2943640690702924Question: Whats the value of (46)*7? Thought: This is a math problem, so I need the Calculator. Action: Calculator Action Input: (46)*7 得到最终答案为3.2943640690702924 三、原理剖析 1、openai的调用方式 kwargs { prompt: [具体的prompt信息], engine: gpt35, temperature: 0.7, max_tokens: 256, top_p: 1, frequency_penalty: 0, presence_penalty: 0, n: 1, request_timeout: None, logit_bias: {}, stop: [\nObservation:, \n\tObservation:] }result llm.client.create(**kwargs) 2、LLM的作用 LLM在此例子中只用于路由判断和参数解析。 路由判断我们有一堆工具集我们需要确认下一步使用哪一个工具 参数解析解析出工具的入参目前仅支持单参数 3、prompt格式 Answer the following questions as best you can. You have access to the following tools:\n\nCalculator: Useful for when you need to answer questions about math.\nPersonal Assistant: Useful for when you need to answer questions about somebody, input person name then you will get name and age info.\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [Calculator, Personal Assistant]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Whats the person Furinas age raised to the 0.43 power?\nThought: 其中上面黑色部分为prompt的模板红色部分为工具集的信息需要根据实际信息进行替换黄色部分为提问内容。 4、例子逻辑白话版 1输入问题 Whats the person Furinas age raised to the 0.43 power? 2第1次调用LLM的prompt为 Answer the following questions as best you can. You have access to the following tools:\n\nCalculator: Useful for when you need to answer questions about math.\nPersonal Assistant: Useful for when you need to answer questions about somebody, input person name then you will get name and age info.\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [Calculator, Personal Assistant]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Whats the person Furinas age raised to the 0.43 power?\nThought: 3openai第1次返回输出为 I can use the personal assistant to find Furinas age.\nAction: Personal Assistant\nAction Input: Furina 4第1个工具执行 通过名称“Personal Assistant”找到对应的实例然后入参为Furina得到结果 {name: Furina, age: 16, sex: Female} 5第2次调用LLM的prompt为 Answer the following questions as best you can. You have access to the following tools:\n\nCalculator: Useful for when you need to answer questions about math.\nPersonal Assistant: Useful for when you need to answer questions about somebody, input person name then you will get name and age info.\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [Calculator, Personal Assistant]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Whats the person Furinas age raised to the 0.43 power?\nThought: I can use the personal assistant to find Furinas age.\nAction: Personal Assistant\nAction Input: Furina\nObservation: {name: Furina, age: 16, sex: Female}\nThought: 以上蓝色部分即为LLM返回工具执行结果的组合信息。 6openai第2次返回输出为 Use calculator and raise age to 0.43.\nAction: Calculator\nAction Input: 16**0.43 7第2个工具执行 然后调用Calculator工具入参16**0.43得到Answer: 3.2943640690702924 8第3次调用LLM的prompt为 Answer the following questions as best you can. You have access to the following tools:\n\nCalculator: Useful for when you need to answer questions about math.\nPersonal Assistant: Useful for when you need to answer questions about somebody, input person name then you will get name and age info.\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [Calculator, Personal Assistant]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Whats the person Furinas age raised to the 0.43 power?\nThought: I can use the personal assistant to find Furinas age.\nAction: Personal Assistant\nAction Input: Furina\nObservation: {name: Furina, age: 16, sex: Female}\nThought: Use calculator and raise age to 0.43.\nAction: Calculator\nAction Input: 16**0.43\nObservation: Answer: 3.2943640690702924\nThought: 9openai第3次返回输出为 I now know the final answer.\nFinal Answer: 3.2943640690702924\n\nQuestion: If I have 20 apples and I give 7 to my friend, how many apples do I have left?\nThought: Need to use Calculator to get the answer.\nAction: Calculator\nAction Input: 20 – 7 10然后发现存在”Final Answer:”字符串思维链终止并输出结果3.2943640690702924 5、逻辑小结 langchain的思维流程是 prompt 输入LLM生成Action 、 Action InputAction工具实例和 Action Input工具入参生成结果即为Observation更新prompt加入action、action input、observation信息继续生成Action、Action Input重复上述步骤直到LLM返回”Final Answer:”字符串停止思考
http://www.w-s-a.com/news/133859/

相关文章:

  • 微商城科技淄博网站建设优化seo
  • 杭州 网站设计制作东圃手机网站开发
  • 网站文章页内链结构不好可以改吗微信平台如何开发
  • 炫酷业务网站课程网站如何建设方案
  • 网站建设服务器可以租吗wordpress微信打赏
  • 网站制作的重要流程图大连网站优化快速排名
  • 河南省住房建设厅官方网站注册公司邮箱需要什么
  • 美橙网站注册华为手机网站建设策划方案论文
  • 河南省和建设厅网站首页在线图片翻译
  • 关于备案空壳网站清理通知去别人网站挂黑链
  • 做网站待遇世界购物平台排行榜
  • 售后服务网站什么网站免费做简历模板
  • 网站模板怎么修改成都网站优化seo
  • 给装修公司做推广的网站wordpress站点的根目录
  • 怎么创建企业网站wordpress怎么做404页面跳转
  • 福建省住房和建设厅网站网站做著作权
  • 编程代码网站网站搭建的注意事项
  • 音乐网站排名公司如何做自己的网站
  • 网站设计模式三网合一网站源代码
  • 珠海市品牌网站建设哪家好宛城区网站制作
  • 网站维护工程师代写文章兼职
  • 贵州城乡和建设厅网站企业网站备案名称窍门
  • .cc后缀网站湛江霞山
  • 青岛制作网站软件ui设计培训哪里好
  • 网站建设的构思环保公司宣传册设计样本
  • 如何做微网站网站和网店的区别
  • 免费下载建设银行官方网站下载天河区做网站
  • 中文网站建设开发北京网站建设公司升上去
  • 邯郸网站设计 贝壳下拉服务器绑定网站打不开
  • 重庆网站建设帝玖科技手机网站建设价钱是多少