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

wap网站源码二级域名搭wordpress

wap网站源码,二级域名搭wordpress,服务器iis搭建网站,wordpress点击图片弹出本教程将介绍如何使用LangChain库和智谱清言的 GLM-4-Plus 模型来理解和推理一个自定义的运算符#xff08;例如使用鹦鹉表情符号#x1f99c;#xff09;。我们将通过一系列示例来训练模型#xff0c;使其能够理解和推断该运算符的含义。 环境准备 首先#xff0c;确保…本教程将介绍如何使用LangChain库和智谱清言的 GLM-4-Plus 模型来理解和推理一个自定义的运算符例如使用鹦鹉表情符号。我们将通过一系列示例来训练模型使其能够理解和推断该运算符的含义。 环境准备 首先确保你已经安装了以下库 langchain_openailangchain_corelangchain_chromalangchain_community 你可以使用以下命令进行安装 pip install langchain_openai langchain_core langchain_chroma langchain_community第一步初始化模型 首先初始化OpenAI的Chat模型。 from langchain_openai import ChatOpenAImodel ChatOpenAI(temperature0,modelGLM-4-Plus,openai_api_keyyour api key,openai_api_basehttps://open.bigmodel.cn/api/paas/v4/ )第二步初步测试模型 测试一下模型对自定义运算符的理解。 response model.invoke(What is 2 9?) print(response.content)输出结果 The notation 2 9 is not a standard mathematical or widely recognized symbol. It appears to be using an emoji (a parrot) in place of a traditional operator. Without additional context or clarification, its difficult to determine the intended meaning.However, if we consider the parrot emoji as a playful or whimsical substitute for a standard mathematical operation, we might speculate on a few possibilities:1. **Repetition or Iteration**: Parrots are known for repeating sounds. If the parrot emoji is meant to imply repetition, 2 9 could be interpreted as repeating the number 2 nine times, resulting in 222222222.2. **Multiplication**: If the parrot is whimsically standing in for a multiplication sign, 2 9 could mean \(2 \times 9 18\).3. **Concatenation**: If the parrot is meant to indicate combining the numbers, 2 9 could simply mean concatenating 2 and 9 to form the number 29.Without further context, these are just educated guesses. If you have more information about the context or the specific rules governing the use of the parrot emoji in this notation, please provide it for a more accurate interpretation.第三步构建示例提示 为了让模型更好地理解自定义运算符提供一些示例。 from langchain_core.prompts import ChatPromptTemplate, FewShotChatMessagePromptTemplateexamples [{input: 2 2, output: 4},{input: 2 3, output: 5}, ]example_prompt ChatPromptTemplate.from_messages([(human, {input}),(ai, {output}),] ) few_shot_prompt FewShotChatMessagePromptTemplate(example_promptexample_prompt,examplesexamples, )print(few_shot_prompt.invoke({}).to_messages())输出结果 [HumanMessage(content2 2, additional_kwargs{}, response_metadata{}), AIMessage(content4, additional_kwargs{}, response_metadata{}), HumanMessage(content2 3, additional_kwargs{}, response_metadata{}), AIMessage(content5, additional_kwargs{}, response_metadata{})]第四步构建最终提示 将示例提示与系统提示结合起来构建最终的提示。 final_prompt ChatPromptTemplate.from_messages([(system, You are a wondrous wizard of math.),few_shot_prompt,(human, {input}),] )第五步链式调用模型 我们将最终提示与模型结合起来进行链式调用。 chain final_prompt | modelresponse chain.invoke({input: What is 2 9?}) print(response.content)输出结果 The symbol seems to represent an operation, and based on the previous examples:- 2 2 4 - 2 3 5It appears that the operation adds the second number to the first number. So, following this pattern:2 9 2 9 11Therefore, 2 9 is 11.第六步使用语义相似性选择示例 为了进一步提高模型的推理能力我们可以使用语义相似性来选择最相关的示例。 from langchain_chroma import Chroma from langchain_core.example_selectors import SemanticSimilarityExampleSelectorexamples [{input: 2 2, output: 4},{input: 2 3, output: 5},{input: 2 4, output: 6},{input: What did the cow say to the moon?, output: nothing at all},{input: Write me a poem about the moon,output: One for the moon, and one for me, who are we to talk about the moon?,}, ]from langchain_community.embeddings import ZhipuAIEmbeddingsto_vectorize [ .join(example.values()) for example in examples] embeddings ZhipuAIEmbeddings(modelembedding-3,api_keyyour api key, ) vectorstore Chroma.from_texts(to_vectorize, embeddings, metadatasexamples)example_selector SemanticSimilarityExampleSelector(vectorstorevectorstore,k2, )selected_examples example_selector.select_examples({input: Whats 3 3?}) print(selected_examples)输出结果 [{input: 2 3, output: 5}, {input: 2 4, output: 6}]第七步构建新的提示并调用模型 使用选定的示例构建新的提示并调用模型。 from langchain_core.prompts import ChatPromptTemplate, FewShotChatMessagePromptTemplate# Define the few-shot prompt. few_shot_prompt FewShotChatMessagePromptTemplate(# The input variables select the values to pass to the example_selectorinput_variables[input],example_selectorexample_selector,example_promptChatPromptTemplate.from_messages([(human, {input}), (ai, {output})]), )print(few_shot_prompt.invoke(inputWhats 3 3?).to_messages()) 输出结果 [HumanMessage(content2 3, additional_kwargs{}, response_metadata{}), AIMessage(content5, additional_kwargs{}, response_metadata{}), HumanMessage(content2 4, additional_kwargs{}, response_metadata{}), AIMessage(content6, additional_kwargs{}, response_metadata{})]final_prompt ChatPromptTemplate.from_messages([(system, You are a wondrous wizard of math.),few_shot_prompt,(human, {input}),] )print(final_prompt.invoke(inputWhats 3 3?).to_messages())输出结果 [SystemMessage(contentYou are a wondrous wizard of math., additional_kwargs{}, response_metadata{}), HumanMessage(content2 3, additional_kwargs{}, response_metadata{}), AIMessage(content5, additional_kwargs{}, response_metadata{}), HumanMessage(content2 4, additional_kwargs{}, response_metadata{}), AIMessage(content6, additional_kwargs{}, response_metadata{}), HumanMessage(contentWhats 3 3?, additional_kwargs{}, response_metadata{})]chain final_prompt | modelprint(chain.invoke({input: Whats 3 3?}).content)输出结果 It seems like the symbol is being used as an operation, but its specific rules arent standard in mathematics. Based on the previous examples:- 2 3 5 - 2 4 6One possible interpretation is that might represent an operation where you add the two numbers together. Following this pattern:- 3 3 would be 3 3 6So, 3 3 6. However, if theres a different rule or context for this operation, please provide more details for a precise answer! 参考链接https://python.langchain.com/docs/how_to/few_shot_examples_chat/ 希望这个教程对你有所帮助如果有任何问题欢迎随时提问。
http://www.sczhlp.com/news/169329/

相关文章:

  • 怎么推广自己的网站链接公司建设网站公司
  • 无锡哪里有做网站的公司四川省优质校建设 网站
  • 模板网站更改广州网站建设信科公司
  • 建设银行网站打不开别的网站可以用吗设计wordpress主题下载
  • 江苏德丰建设集团网站网架结构
  • 网站入口类型设计室内装修效果图
  • 改成 响应式 网站营销工具有哪些
  • 网站诊断与优化的作用wordpress中用户注册
  • 如何制作wap网站网站备案流程及资料
  • 运营网站需要多少钱驾校网上约车网站开发
  • 郑州开发小程序平台邢台做网站建设优化制作公司
  • 下什么软件做网站2344网页游戏大全
  • 为女朋友做网站企业做淘宝网站需要多少钱
  • 深圳龙岗区网站建设建设外贸网站多少钱
  • 重庆市住房和城乡建设网站加强社区网站建设
  • 免费动态素材网站wordpress文章格式引用
  • 岳阳博物馆网站公司网站要多少钱
  • 微信公众号如何做微网站服务器租用收费标准
  • 家电网站源码东莞优化seo网站关键词优化
  • 网站建设制作设计营销公司杭州简述电子商务网站的建设
  • 做电脑游戏破解的网站微信公众号搭建网站
  • 完整教程:Microsoft Word使用技巧分享(本科毕业论文版)
  • (转)The Ten Commandments of Digital Cotrol(Part1)
  • 20251005 模拟测 总结
  • 织梦dedecms电影网站模板WordPress托管如果使用插件
  • 园艺建设网站广西建设厅办事大厅网站
  • 公司的服务器能建设网站吗上海十大装修公司口碑排名
  • 网站建设 的销售图片delphi xe10网站开发
  • 阿里巴巴做网站的电话号码wordpress阿里云数据库
  • 网站开发 方案 报价单自己学做网站需要学多久