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

html5 单页 响应式 网站模板wordpress手机排版

html5 单页 响应式 网站模板,wordpress手机排版,免费笑话网站系统,网站建设与维护本科教材本教程将介绍如何使用LangChain库和chatglm API来解决一个4x4的数独问题。我们将通过以下步骤实现这一目标#xff1a; 初始化chatglm 的聊天模型。定义数独问题和解决方案。创建一个自定义的检查器来验证每一步的思考。使用ToTChain来运行整个思考过程。 1. 初始化chatglm4…本教程将介绍如何使用LangChain库和chatglm API来解决一个4x4的数独问题。我们将通过以下步骤实现这一目标 初始化chatglm 的聊天模型。定义数独问题和解决方案。创建一个自定义的检查器来验证每一步的思考。使用ToTChain来运行整个思考过程。 1. 初始化chatglm4 的聊天模型 首先我们需要导入langchain_openai库中的ChatOpenAI类并初始化一个聊天模型实例。 from langchain_openai import ChatOpenAIllm ChatOpenAI(temperature1,modelGLM-4-Plus,openai_api_keyyour api key,openai_api_basehttps://open.bigmodel.cn/api/paas/v4/,max_tokens512, )2. 定义数独问题和解决方案 接下来我们定义一个4x4的数独问题和其解决方案并生成问题描述。 sudoku_puzzle 3,*,*,2|1,*,3,*|*,1,*,3|4,*,*,1 sudoku_solution 3,4,1,2|1,2,3,4|2,1,4,3|4,3,2,1 problem_description f {sudoku_puzzle}- This is a 4x4 Sudoku puzzle. - The * represents a cell to be filled. - The | character separates rows. - At each step, replace one or more * with digits 1-4. - There must be no duplicate digits in any row, column or 2x2 subgrid. - Keep the known digits from previous valid thoughts in place. - Each thought can be a partial or the final solution. .strip() print(problem_description)输出结果如下 3,*,*,2|1,*,3,*|*,1,*,3|4,*,*,1- This is a 4x4 Sudoku puzzle. - The * represents a cell to be filled. - The | character separates rows. - At each step, replace one or more * with digits 1-4. - There must be no duplicate digits in any row, column or 2x2 subgrid. - Keep the known digits from previous valid thoughts in place. - Each thought can be a partial or the final solution.3. 创建自定义检查器 我们需要创建一个自定义的检查器MyChecker用于验证每一步的思考是否有效。 import re from typing import Tuplefrom langchain_experimental.tot.checker import ToTChecker from langchain_experimental.tot.thought import ThoughtValidityclass MyChecker(ToTChecker):def evaluate(self, problem_description: str, thoughts: Tuple[str, ...] ()) - ThoughtValidity:last_thought thoughts[-1]clean_solution last_thought.replace( , ).replace(, )regex_solution clean_solution.replace(*, .).replace(|, \\|)if sudoku_solution in clean_solution:return ThoughtValidity.VALID_FINALelif re.search(regex_solution, sudoku_solution):return ThoughtValidity.VALID_INTERMEDIATEelse:return ThoughtValidity.INVALID4. 测试检查器 我们可以通过一些断言来测试检查器的功能。 checker MyChecker() assert (checker.evaluate(, (3,*,*,2|1,*,3,*|*,1,*,3|4,*,*,1,)) ThoughtValidity.VALID_INTERMEDIATE ) assert (checker.evaluate(, (3,4,1,2|1,2,3,4|2,1,4,3|4,3,2,1,)) ThoughtValidity.VALID_FINAL ) assert (checker.evaluate(, (3,4,1,2|1,2,3,4|2,1,4,3|4,3,*,1,)) ThoughtValidity.VALID_INTERMEDIATE ) assert (checker.evaluate(, (3,4,1,2|1,2,3,4|2,1,4,3|4,*,3,1,)) ThoughtValidity.INVALID )5. 运行ToTChain 最后我们使用ToTChain来运行整个思考过程并尝试解决数独问题。 from langchain_experimental.tot.base import ToTChaintot_chain ToTChain(llmllm, checkerMyChecker(), k30, c5, verboseTrue, verbose_llmFalse ) tot_chain.run(problem_descriptionproblem_description)输出结果如下 C:\Users\32564\AppData\Local\Temp\ipykernel_5080\1223294212.py:6: LangChainDeprecationWarning: The method Chain.run was deprecated in langchain 0.1.0 and will be removed in 1.0. Use :meth:~invoke instead.tot_chain.run(problem_descriptionproblem_description) d:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([1m Entering new ToTChain chain...[0m Starting the ToT solve procedure. [33;1m[1;3mThought: 3,*,*,2|1,*,3,*|*,1,*,3|4,*,*,1 [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([31;1m[1;3m Thought: 3,1,*,2|1,*,3,*|*,1,*,3|4,*,*,1 [0m[31;1m[1;3m Thought: 3,*,4,2|1,*,3,*|*,1,*,3|4,*,*,1 [0m[33;1m[1;3m Thought: 3,*,*,2|1,2,3,*|*,1,*,3|4,*,*,1 [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([33;1m[1;3m Thought: 3,*,*,2|1,2,3,4|*,1,*,3|4,*,*,1 [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([33;1m[1;3m Thought: 3,*,*,2|1,2,3,4|2,1,*,3|4,*,*,1 [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([33;1m[1;3m Thought: 3,*,*,2|1,2,3,4|2,1,4,3|4,*,*,1 [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([33;1m[1;3m Thought: 3,*,*,2|1,2,3,4|2,1,4,3|4,3,*,1 [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([33;1m[1;3m Thought: [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([33;1m[1;3m Thought: [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([33;1m[1;3m Thought: 3,*,*,2|1,2,3,4|2,1,4,3|4,3,2,1 [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([33;1m[1;3m Thought: 3,*,*,2|1,2,3,4|2,1,4,3|4,3,2,1 [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([31;1m[1;3m Thought: 3,1,*,2|1,2,3,4|2,1,4,3|4,3,2,1 [0m[33;1m[1;3m Thought: 3,4,*,2|1,2,3,4|2,1,4,3|4,3,2,1 [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([33;1m[1;3m Thought: [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([33;1m[1;3m Thought: [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([33;1m[1;3m Thought: [0md:\soft\anaconda\envs\langchain\Lib\site-packages\langchain\chains\llm.py:341: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.warnings.warn([32;1m[1;3m Thought: 3,4,1,2|1,2,3,4|2,1,4,3|4,3,2,1 [0m [1m Finished chain.[0m3,4,1,2|1,2,3,4|2,1,4,3|4,3,2,1通过以上步骤我们成功地使用LangChain解决了一个4x4的数独问题。希望这个教程对你有所帮助如果有任何问题欢迎随时提问。
http://www.hkea.cn/news/14579447/

相关文章:

  • 太原网站推广优化网络管理系统设计
  • 龙华专业做网站学生建筑设计说明模板
  • 站群优化公司适合美工的设计网站
  • 如何将aaa云主机做网站如何申请邮箱免费注册
  • 网站建设合同要注意什么企业官网制作公司
  • 深圳市手机网站建设公司创建网站需要哪些过程
  • 做微商好还是开网站好网站群管理平台建设
  • 句容工程建设招标网站网站等级保护必须做吗
  • 做网站的一般多少钱科技型中小企业服务平台登录
  • 海南营销网站建设被代运营骗了去哪投诉
  • 大型网站建设济南兴田德润o评价做网站卖产品要注册公司吗
  • 电子商务网站建设训练总结网站建设得花多钱
  • 个人网站开发的意义wordpress html5 音乐
  • 学校网站下载儿童教育网站怎么做有趣
  • 做网站需要多少钱啊手机网站开发团队
  • 太原网站制作公司哪家好俄语网站建设
  • 南昌net网站开发wordpress主题404
  • 如何自助建网站专业的集团网站开发费用多少钱
  • 江门网站制作案例网页设计报价多少
  • 网站福利你们会回来感谢我的开发电商网站多少钱
  • 有保障的广州网站建设怎么建设一个开源平台网站
  • 网站开发接口文档模板中国采购网招标公告
  • 网页视频下载提取关键词优化
  • 有关建设网站的论文做excel的网站
  • 网站建设客户功能详细要求2022年十大流行语
  • 网站验证码 php哪些网站可以做平面设计
  • 杭州小程序开发外包清远做网站seo
  • 学网站开发需要学什么网站开发怎么进行数据库连接
  • 三网合一的模板网站郑州经纬网络做网站吗
  • 做网站要学编程麽最新远程网站建设服务