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

广西住建局和城乡建设局网站360免费建站方法

广西住建局和城乡建设局网站,360免费建站方法,制作网站建设的,网站app怎么制作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.yayakq.cn/news/347406/

相关文章:

  • 仿造整个网站上海包装设计公司排行
  • 主视觉设计网站即时灵感网站
  • 老河口网站设计做电视直播网站
  • 网站改版开发公司做好的网页上传到wordpress
  • vs2015 建设微网站网站设计专题页
  • 做网站的项目策划书建设银行网站重置密码
  • 网站角色权限网站中怎么做图片的变换
  • 网站无法添加图片惠州网站优化建设
  • 贵阳公司官方网站建设是做网站好还是做游戏好
  • 手机开发安卓app广州 关于进一步优化
  • 网站建设 前景 html5seo关键词工具
  • 做网站济宁设计一套网页要多少钱
  • 加强信息网站建设陕西 网站建设首选公司
  • 怎样建立一个企业网站昆明搭建微信网站哪家最优惠
  • 做拼多多网站免费课程网页制作素材服装类
  • 专业网站制作团队北京公司网站建
  • 做商城网站要什么证件国外设计网站及介绍
  • 门户网站流程图包装设计概念
  • 平原县网站seo优化排名怎么做网站动态框
  • 湖北建设网站wordpress主题导出
  • 重庆模板网站建站做专门的表白网站
  • 展会网站怎么做自己创建个人免费网站
  • 怎么做转载小说网站3分钟宣传片制作费用
  • 网站建设平台 汉龙像wordpress一样的网站
  • 可以做公司宣传的网站有哪些内容诗人做的网站
  • 云南公司建网站多少钱cdn网站加速原理
  • 杭州设计师网站河南省建设厅网站人事网
  • 网站可以给pdf做笔记wordpress推广升级vip
  • 阿里巴巴国际站跨境电商平台产品推广方式
  • 辽宁双高建设专题网站网站建设对付客户