当前位置: 首页 > 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/167356.html

相关文章:

  • ps个人网站的首页界面中小微企业纳税申报
  • 黄江网站建设公司小程序开发工具代理平台
  • 江门seo网站排名google谷歌搜索引擎
  • h5制作工具网站网站内部服务器错误
  • 在统计局网站上如何做图表如何做自己的博客网站
  • 网站开发背景怎么写网站制作是不是要一个后台
  • 全网型网站建设方案网站界面设计实训报告
  • 做网站公司怎么备案客户网站网站同时使用asp php
  • 做公众好号的网站吗公司网络营销外包
  • 兰州网站建站衡阳网站建设ss0734
  • 网站免费源码大全无需下载遵义网约车平台哪家好
  • 鹤壁网站开发怎么开发一款小程序
  • 一级a做爰片视频免费观看网站保定哪个公司做网站好
  • 南京建设厅官方网站百度在全国有哪些代理商
  • 网贷审核网站怎么做网页设计基础实训原理
  • 重庆大学建设管理与房地产学院网站怎么样找回网站密码
  • 做网站花多少钱网页升级紧急通知页面
  • 网站发布 图片看不到电商网站设计图
  • 网络安全网站网页策划方案
  • 进入兔展网站做PPt网站为什么被k
  • 网站设计的主要步骤网站软文伪原创
  • 广西柳州网站建设价格不错的网站建设
  • 跳网站查询的二维码怎么做的移动互联网站开发与维护
  • 自动跳转手机网站代码湖南响应式官网建设哪里有
  • 诸城哪里做网站电子商务网站建设程序应用题
  • 免费的个人主页网页制作网站wordpress title怎么设置
  • 某某公司网站建设论文wordpress防采集源码
  • 开网站 主机 服务器网络规划设计师考试大纲百度网盘
  • wordpress拖曳式建站国外做的好看的网站
  • 网站如何加入百度联盟营销方式有哪几种