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

公司高端网站建设网站的建设初步定位

公司高端网站建设,网站的建设初步定位,朝阳住房和城乡建设厅网站,沧州英文网站制作Langchain 的 ConversationSummaryBufferMemory ConversationSummaryBufferMemory 在内存中保留最近交互的缓冲区,但不仅仅是完全刷新旧的交互,而是将它们编译成摘要并使用两者。但与之前的实现不同的是,它使用令牌长度而不是交互次数来确定何…

Langchain 的 ConversationSummaryBufferMemory

ConversationSummaryBufferMemory 在内存中保留最近交互的缓冲区,但不仅仅是完全刷新旧的交互,而是将它们编译成摘要并使用两者。但与之前的实现不同的是,它使用令牌长度而不是交互次数来确定何时刷新交互。

我们首先来了解一下如何使用这些实用程序,

示例代码,

from langchain.memory import ConversationSummaryBufferMemory
from langchain.llms import OpenAIllm = OpenAI()
memory = ConversationSummaryBufferMemory(llm=llm, max_token_limit=40, return_messages=True
)
memory.save_context({"input": "嗨"}, {"output": "最近怎么样?"})
memory.save_context({"input": "没什么特别的,你呢?"}, {"output": "没什么特别的。"})
memory.load_memory_variables({})

输出结果,

{'history': [SystemMessage(content='\nThe human and AI are engaging in conversation. The human greets the AI and the AI asks how the human is doing.', additional_kwargs={}),HumanMessage(content='没什么特别的,你呢?', additional_kwargs={}, example=False),AIMessage(content='没什么特别的。', additional_kwargs={}, example=False)]}

示例代码,

from langchain.chains import ConversationChainconversation_with_summary = ConversationChain(llm=llm,# We set a very low max_token_limit for the purposes of testing.memory=ConversationSummaryBufferMemory(llm=OpenAI(), max_token_limit=250),verbose=True,
)
conversation_with_summary.predict(input="嗨,最近怎么样?")

输出结果,

> Entering new ConversationChain chain...
Prompt after formatting:
The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.Current conversation:Human: 嗨,最近怎么样?
AI:> Finished chain.
' 嗨!最近还不错,我在学习新的技能,并且正在尝试新的任务。我也在尝试改进我的语言处理能力,以便更好地与人交流。你呢?'

示例代码,

conversation_with_summary.predict(input="只是在写一些文档!")

输出结果,

Entering new ConversationChain chain...
Prompt after formatting:
The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.Current conversation:
Human: 嗨,最近怎么样?
AI:  嗨!最近还不错,我在学习新的技能,并且正在尝试新的任务。我也在尝试改进我的语言处理能力,以便更好地与人交流。你呢?
Human: 只是在写一些文档!
AI:> Finished chain.
' 哦,看起来很有趣!你在写什么文档?'

示例代码,

conversation_with_summary.predict(input="你听说过 LangChain 吗?")

输出结果,

> Entering new ConversationChain chain...
Prompt after formatting:
The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.Current conversation:
Human: 嗨,最近怎么样?
AI:  嗨!最近还不错,我在学习新的技能,并且正在尝试新的任务。我也在尝试改进我的语言处理能力,以便更好地与人交流。你呢?
Human: 只是在写一些文档!
AI:  哦,看起来很有趣!你在写什么文档?
Human: 你听说过 LangChain 吗?
AI:> Finished chain.
' 是的,我知道LangChain。它是一个基于区块链的语言学习平台,旨在帮助人们更好地学习外语。你正在写关于LangChain的文档吗?'

示例代码,

# 我们可以看到,摘要和缓冲区都已更新
conversation_with_summary.predict(input="哈哈,不对,不过很多人都把它混淆了。"
)

输出结果,

> Entering new ConversationChain chain...
Prompt after formatting:
The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.Current conversation:
System: 
The AI thinks artificial intelligence is a force for good because it will help humans reach their full potential. It has been learning new skills and trying new tasks, as well as attempting to improve its language processing so that it can communicate better with humans. The human asks how the AI has been doing recently.
Human: 只是在写一些文档!
AI:  哦,看起来很有趣!你在写什么文档?
Human: 你听说过 LangChain 吗?
AI:  是的,我知道LangChain。它是一个基于区块链的语言学习平台,旨在帮助人们更好地学习外语。你正在写关于LangChain的文档吗?
Human: 哈哈,不对,不过很多人都把它混淆了。
AI:> Finished chain.
' 哦,我明白了。那你在写什么文档呢?'

完结!

http://www.15wanjia.com/news/165469.html

相关文章:

  • 比较公司网站与营销网站的不同wordpress 左图右文
  • 东平做网站如何用源码搭建网站
  • 购物网站建立网页无法访问错误代码6
  • 简单的网站建设登录注册入口
  • 论坛网站模推广图片大全
  • php网站建设制作流程收录批量查询工具
  • 注册做网站的公司wordpress主题验证失败
  • ae做动画教程网站高端网站建设代码
  • wordpress图片浏览插件WordPress修改seo标题符号
  • wordpress安装后查看站点失败茌平网页设计
  • 什么视频直播网站做挣钱网站常用配色
  • 网站建设掌握技能周易起名网唯一官网免费
  • 广州汽车网站建设什么是网络营销环境的外部因素
  • 建网站 考虑wordpress暂停网站
  • 网站域名区别h5商城网站开发
  • 网站标签怎么做跳转游戏seo推广
  • 门户网站设计方案做游戏评论注册国外网站
  • 商城网站建设需求大连建设工程信息网登陆
  • 网站设计和营销网站做直播
  • 怎样建立自己手机网站台州高端网站设计
  • 免费网站推荐软件泰安网络推广 网站建设 网站优化
  • 网站外链怎么购买做产品宣传网站多少钱
  • 网站开发合同模板寿光哪里做网站
  • 自己做的网站本地虚拟上传大学网站模板下载
  • 58这样网站怎么做如何写网站开发需求
  • 网站开发的问题c语言网页编辑器
  • 做微商必会的软件网站网站建设专业是干什么的
  • 模板网站和插件wordpress评论框xss
  • 做网站卖广告位赚钱哈尔滨公司网站
  • 岳阳建网站做外贸那里发广告网站