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

创建公司网站需要注意什么wordpress 导航 代码

创建公司网站需要注意什么,wordpress 导航 代码,东营会计信息网官网,网站开发合同受托方分类目录#xff1a;《自然语言处理从入门到应用》总目录 本文介绍了如何将链保存#xff08;序列化#xff09;到磁盘和从磁盘加载#xff08;反序列化#xff09;。我们使用的序列化格式是json或yaml。目前#xff0c;只有一些链支持这种类型的序列化。随着时间的推移《自然语言处理从入门到应用》总目录 本文介绍了如何将链保存序列化到磁盘和从磁盘加载反序列化。我们使用的序列化格式是json或yaml。目前只有一些链支持这种类型的序列化。随着时间的推移我们将增加支持的链条数量。 将链保存序列化到磁盘 首先让我们可以使用.save方法将链保存到磁盘并指定一个带有json或yaml扩展名的文件路径。 from langchain import PromptTemplate, OpenAI, LLMChain template Question: {question}Answer: Lets think step by step. prompt PromptTemplate(templatetemplate, input_variables[question]) llm_chain LLMChain(promptprompt, llmOpenAI(temperature0), verboseTrue)llm_chain.save(llm_chain.json)现在让我们来看看保存的文件中的内容 !cat llm_chain.json输出 {memory: null,verbose: true,prompt: {input_variables: [question],output_parser: null,template: Question: {question}\n\nAnswer: Lets think step by step.,template_format: f-string},llm: {model_name: text-davinci-003,temperature: 0.0,max_tokens: 256,top_p: 1,frequency_penalty: 0,presence_penalty: 0,n: 1,best_of: 1,request_timeout: null,logit_bias: {},_type: openai},output_key: text,_type: llm_chain }从磁盘加载反序列化链 我们可以使用load_chain方法从磁盘加载链 from langchain.chains import load_chain chain load_chain(llm_chain.json) chain.run(whats 2 2)日志输出 Entering new LLMChain chain... Prompt after formatting: Question: whats 2 2Answer: Lets think step by step. Finished chain.输出 2 2 4分别保存组件 在上面的例子中我们可以看到提示和LLM配置信息与整个链条保存在同一个json中但我们也可以将它们分开保存。这通常有助于使保存的组件更加模块化。为了做到这一点我们只需要指定llm_path而不是llm组件并且指定prompt_path而不是prompt组件。 llm_chain.prompt.save(prompt.json)输入 !cat prompt.json输出 {input_variables: [question],output_parser: null,template: Question: {question}\n\nAnswer: Lets think step by step.,template_format: f-string }输入 llm_chain.llm.save(llm.json)输入 !cat llm.json输出 {model_name: text-davinci-003,temperature: 0.0,max_tokens: 256,top_p: 1,frequency_penalty: 0,presence_penalty: 0,n: 1,best_of: 1,request_timeout: null,logit_bias: {},_type: openai }输入 config {memory: None,verbose: True,prompt_path: prompt.json,llm_path: llm.json,output_key: text,_type: llm_chain }import jsonwith open(llm_chain_separate.json, w) as f:json.dump(config, f, indent2)输入 !cat llm_chain_separate.json输出 {memory: null,verbose: true,prompt_path: prompt.json,llm_path: llm.json,output_key: text,_type: llm_chain }我们可以以相同的方式加载它 chain load_chain(llm_chain_separate.json) chain.run(whats 2 2)日志输出 Entering new LLMChain chain... Prompt after formatting: Question: whats 2 2Answer: Lets think step by step. Finished chain.输出 2 2 4从LangChainHub加载 本节介绍如何从LangChainHub加载链。 from langchain.chains import load_chainchain load_chain(lc://chains/llm-math/chain.json) chain.run(whats 2 raised to .12)日志输出 Entering new LLMMathChain chain... whats 2 raised to .12 Answer: 1.0791812460476249Finished chain.输出 Answer: 1.0791812460476249有时候链会需要额外的参数这些参数在链序列化时未包含在内。例如一个用于对向量数据库进行问答的链条将需要一个向量数据库作为参数。 from langchain.embeddings.openai import OpenAIEmbeddings from langchain.vectorstores import Chroma from langchain.text_splitter import CharacterTextSplitter from langchain import OpenAI, VectorDBQA from langchain.document_loaders import TextLoader loader TextLoader(../../state_of_the_union.txt) documents loader.load() text_splitter CharacterTextSplitter(chunk_size1000, chunk_overlap0) texts text_splitter.split_documents(documents)embeddings OpenAIEmbeddings() vectorstore Chroma.from_documents(texts, embeddings) # Running Chroma using direct local API. # Using DuckDB in-memory for database. Data will be transient.chain load_chain(lc://chains/vector-db-qa/stuff/chain.json, vectorstorevectorstore) query What did the president say about Ketanji Brown Jackson chain.run(query)输出 The president said that Ketanji Brown Jackson is a Circuit Court of Appeals Judge, one of the nations top legal minds, a former top litigator in private practice, a former federal public defender, has received a broad range of support from the Fraternal Order of Police to former judges appointed by Democrats and Republicans, and will continue Justice Breyers legacy of excellence.参考文献 [1] LangChain官方网站https://www.langchain.com/ [2] LangChain ️ 中文网跟着LangChain一起学LLM/GPT开发https://www.langchain.com.cn/ [3] LangChain中文网 - LangChain 是一个用于开发由语言模型驱动的应用程序的框架http://www.cnlangchain.com/
http://www.dnsts.com.cn/news/34785.html

相关文章:

  • app应用网站单页模板下载西安有哪些好玩的
  • 建设网站要求哪里备案交互式网站设计 深圳
  • 网络推广怎么做最有效大连做优化网站哪家好
  • 建网站的目的高端网站设计找哪个公司
  • 邯郸市建设局网站2017内蒙古网站开发公司
  • 门户网站是专一化好还是多元化好全球最新数据消息
  • 备案期间关闭网站梅州建站塔山双喜
  • 建筑专业网站wordpress 分类 字段
  • 网站开发 策划是干嘛的大棚网站建设
  • wordpress网站外包网页设计师工资一般多少钱
  • ASP.NET2.0网站开发全程解析餐厅装修设计
  • 做投票网站的网站建设的常用技术有哪些
  • 比分网站制作淘宝优惠券网站开发
  • 网站模版防被偷哈尔滨市工程信息网
  • 织梦末班和dw建设网站哪个方便优化WordPress页面怎么html
  • 酒店网站设计方案山东川畅科技做网站多少钱
  • 建设工程自学网站公司域名一年多少费用
  • 商业摄影网站源码医疗网站不备案
  • 卫浴建材网站建设小程序游戏开发成本
  • 做资源网站有哪些网站怎么做会员系统
  • 网站制作职业帮人推广的平台
  • 深圳团购网站设计价格安康市天然气公司
  • 高端网站建设万维科技汇米网站建设
  • 电商网站开发详细介绍做网站加推广多少钱
  • 福建省第一电力建设公司网站佛山外贸网站建设效果
  • 网站电话素材seo实训报告
  • c 网站开发程序员公司免费网站注册
  • 企业网站后台管理手机开发人员选项怎么打开
  • 长沙建网站一般要多少钱个人网站 备案 名称
  • 一些网站只能在微信打开怎么做的html5手机网站模板