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

中文域名可以做网站吗阿里wordpress

中文域名可以做网站吗,阿里wordpress,手游app开发公司,网站制作设计哪家公司好分类目录#xff1a;《自然语言处理从入门到应用》总目录 对话令牌缓冲存储器ConversationTokenBufferMemory ConversationTokenBufferMemory在内存中保留了最近的一些对话交互#xff0c;并使用标记长度来确定何时刷新交互#xff0c;而不是交互数量。 from langchain.me…分类目录《自然语言处理从入门到应用》总目录 对话令牌缓冲存储器ConversationTokenBufferMemory ConversationTokenBufferMemory在内存中保留了最近的一些对话交互并使用标记长度来确定何时刷新交互而不是交互数量。 from langchain.memory import ConversationTokenBufferMemory from langchain.llms import OpenAI llm OpenAI() memory ConversationTokenBufferMemory(llmllm, max_token_limit10) memory.save_context({input: hi}, {output: whats up}) memory.save_context({input: not much you}, {output: not much}) memory.load_memory_variables({})输出 {‘history’: ‘Human: not much you\nAI: not much’} 我们还可以将历史记录作为消息列表获取如果我们正在使用聊天模型将非常有用 memory ConversationTokenBufferMemory(llmllm, max_token_limit10, return_messagesTrue) memory.save_context({input: hi}, {output: whats up}) memory.save_context({input: not much you}, {output: not much})在链式模型中的应用 让我们通过一个例子来演示如何在链式模型中使用它同样设置verboseTrue以便我们可以看到提示信息。 from langchain.chains import ConversationChain conversation_with_summary ConversationChain(llmllm, # We set a very low max_token_limit for the purposes of testing.memoryConversationTokenBufferMemory(llmOpenAI(), max_token_limit60),verboseTrue ) conversation_with_summary.predict(inputHi, whats up?)日志输出 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: Hi, whats up? AI: Finished chain.输出 Hi there! Im doing great, just enjoying the day. How about you?输入 conversation_with_summary.predict(inputJust working on writing some documentation!)日志输出 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: Hi, whats up? AI: Hi there! Im doing great, just enjoying the day. How about you? Human: Just working on writing some documentation! AI: Finished chain.输出 Sounds like a productive day! What kind of documentation are you writing?输入 conversation_with_summary.predict(inputFor LangChain! Have you heard of it?)日志输出 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: Hi, whats up? AI: Hi there! Im doing great, just enjoying the day. How about you? Human: Just working on writing some documentation! AI: Sounds like a productive day! What kind of documentation are you writing? Human: For LangChain! Have you heard of it? AI: Finished chain.输出 Yes, I have heard of LangChain! It is a decentralized language-learning platform that connects native speakers and learners in real time. Is that the documentation youre writing about?输入 # 我们可以看到这里缓冲区被更新了 conversation_with_summary.predict(inputHaha nope, although a lot of people confuse it for that)日志输出 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: For LangChain! Have you heard of it? AI: Yes, I have heard of LangChain! It is a decentralized language-learning platform that connects native speakers and learners in real time. Is that the documentation youre writing about? Human: Haha nope, although a lot of people confuse it for that AI: Finished chain.输出 Oh, I see. Is there another language learning platform youre referring to?基于向量存储的记忆VectorStoreRetrieverMemory VectorStoreRetrieverMemory将内存存储在VectorDB中并在每次调用时查询最重要的前 K K K个文档。与大多数其他Memory类不同它不明确跟踪交互的顺序。在这种情况下“文档”是先前的对话片段。这对于提及AI在对话中早些时候得知的相关信息非常有用。 from datetime import datetime from langchain.embeddings.openai import OpenAIEmbeddings from langchain.llms import OpenAI from langchain.memory import VectorStoreRetrieverMemory from langchain.chains import ConversationChain from langchain.prompts import PromptTemplate初始化VectorStore 根据我们选择的存储方式此步骤可能会有所不同我们可以查阅相关的VectorStore文档以获取更多详细信息。 import faissfrom langchain.docstore import InMemoryDocstore from langchain.vectorstores import FAISSembedding_size 1536 # Dimensions of the OpenAIEmbeddings index faiss.IndexFlatL2(embedding_size) embedding_fn OpenAIEmbeddings().embed_query vectorstore FAISS(embedding_fn, index, InMemoryDocstore({}), {})创建VectorStoreRetrieverMemory 记忆对象是从VectorStoreRetriever实例化的。 # In actual usage, you would set k to be a higher value, but we use k1 to show that the vector lookup still returns the semantically relevant information retriever vectorstore.as_retriever(search_kwargsdict(k1)) memory VectorStoreRetrieverMemory(retrieverretriever)# When added to an agent, the memory object can save pertinent information from conversations or used tools memory.save_context({input: My favorite food is pizza}, {output: thats good to know}) memory.save_context({input: My favorite sport is soccer}, {output: ...}) memory.save_context({input: I dont the Celtics}, {output: ok}) # # Notice the first result returned is the memory pertaining to tax help, which the language model deems more semantically relevant # to a 1099 than the other documents, despite them both containing numbers. print(memory.load_memory_variables({prompt: what sport should i watch?})[history])输出 input: My favorite sport is soccer output: ...在对话链中使用 让我们通过一个示例来演示在此示例中我们继续设置verboseTrue以便查看提示。 llm OpenAI(temperature0) # Can be any valid LLM _DEFAULT_TEMPLATE 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.Relevant pieces of previous conversation: {history}(You do not need to use these pieces of information if not relevant)Current conversation: Human: {input} AI: PROMPT PromptTemplate(input_variables[history, input], template_DEFAULT_TEMPLATE ) conversation_with_summary ConversationChain(llmllm, promptPROMPT,# We set a very low max_token_limit for the purposes of testing.memorymemory,verboseTrue ) conversation_with_summary.predict(inputHi, my name is Perry, whats up?)日志输出 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.Relevant pieces of previous conversation: input: My favorite food is pizza output: thats good to know(You do not need to use these pieces of information if not relevant)Current conversation: Human: Hi, my name is Perry, whats up? AI: Finished chain.输出 Hi Perry, Im doing well. How about you?输入 # Here, the basketball related content is surfaced conversation_with_summary.predict(inputwhats my favorite sport?)日志输出 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.Relevant pieces of previous conversation: input: My favorite sport is soccer output: ...(You do not need to use these pieces of information if not relevant)Current conversation: Human: whats my favorite sport? AI: Finished chain.输出 You told me earlier that your favorite sport is soccer.输入 # Even though the language model is stateless, since relavent memory is fetched, it can reason about the time. # Timestamping memories and data is useful in general to let the agent determine temporal relevance conversation_with_summary.predict(inputWhats my favorite food)日志输出 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.Relevant pieces of previous conversation: input: My favorite food is pizza output: thats good to know(You do not need to use these pieces of information if not relevant)Current conversation: Human: Whats my favorite food AI: Finished chain.输出 You said your favorite food is pizza.输入 # The memories from the conversation are automatically stored, # since this query best matches the introduction chat above, # the agent is able to remember the users name. conversation_with_summary.predict(inputWhats my name?)日志输出 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.Relevant pieces of previous conversation: input: Hi, my name is Perry, whats up? response: Hi Perry, Im doing well. How about you?(You do not need to use these pieces of information if not relevant)Current conversation: Human: Whats my name? AI: Finished chain.输出 Your name is Perry.参考文献 [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.w-s-a.com/news/322306/

相关文章:

  • 延安有哪些做网站的公司如何建设网站?
  • 网站建设者属于广告经营者吗网站管理程序
  • 网站内容优化方法深圳市宝安区怎么样
  • 视频网站开发视频公司网站制作多少钱
  • 单页简洁手机网站模板购物软件
  • 素材网站官网低价网站建设费用预算
  • 苏州网站设计kgwl个人网站有什么外国广告做
  • 浙江省网站建设报价简单网站开发工具
  • 物流网站的建设wordpress电视直播插件下载
  • 简述网站开发流程青岛做网站建设价格低
  • 网站开发的业务需求分析杭州推广公司
  • 网站建设技术实现难点app开发需要哪些软件
  • 响水建设局网站做网站需要会哪些知识
  • 企业制作企业网站个人网站可以做百度竞价
  • 做网站找投资人wordpress 5 主题教程
  • 做国外网站汇款用途是什么wordpress图片主题晨曦
  • 网站设计跟网站开发区别为什么网站需要维护
  • m 的手机网站怎么做网络推广方式和方法
  • wordpress图片自动轮播插件seo门户网站建设
  • 制作商业网站传奇网页游戏排名
  • 网站免费推广方案长沙房地产网站设计
  • 济南网站建设cnwenhui中交路桥建设网站
  • 韶关网站开发网站建设任务分解
  • 网站建设核心点阿根廷网站后缀
  • 哪些网站可以做招商广告语学校官网页面设计
  • 十堰城市建设网站网站开发流程宜春
  • 内江网站建设郑州网站优化外包
  • 土地流转网站建设项目云南抖音推广
  • 建设银行网站无法打开2021年有没有人给个网站
  • 高端手机网站建设网站建设岗位绩效