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

做加盟童装交流网站网站后台数据处理编辑主要是做什么的啊

做加盟童装交流网站,网站后台数据处理编辑主要是做什么的啊,最新足球新闻头条,白水网站建设分类目录#xff1a;《自然语言处理从入门到应用》总目录 聊天模型是语言模型的一种变体。虽然聊天模型在内部使用语言模型#xff0c;但它们公开的接口略有不同。它们不是提供一个“输入文本#xff0c;输出文本”的API#xff0c;而是提供一个以“聊天消息”作为输入和输…分类目录《自然语言处理从入门到应用》总目录 聊天模型是语言模型的一种变体。虽然聊天模型在内部使用语言模型但它们公开的接口略有不同。它们不是提供一个“输入文本输出文本”的API而是提供一个以“聊天消息”作为输入和输出的接口。 聊天模型的API还比较新因此我们仍在确定正确的抽象层次。本问将介绍如何开始使用聊天模型该接口是基于消息而不是原始文本构建的 from langchain.chat_models import ChatOpenAI from langchain import PromptTemplate, LLMChain from langchain.prompts.chat import (ChatPromptTemplate,SystemMessagePromptTemplate,AIMessagePromptTemplate,HumanMessagePromptTemplate, ) from langchain.schema import (AIMessage,HumanMessage,SystemMessage ) chat ChatOpenAI(temperature0)通过向聊天模型传递一个或多个消息可以获取聊天完成的结果。响应将是一个消息。LangChain目前支持的消息类型有AIMessage、HumanMessage、SystemMessage和ChatMessage其中ChatMessage接受一个任意的角色参数。大多数情况下我们只需要处理HumanMessage、AIMessage和SystemMessage chat([HumanMessage(contentTranslate this sentence from English to French. I love programming.)])输出 AIMessage(contentJaime programmer., additional_kwargs{})OpenAI的聊天模型支持多个消息作为输入。更多信息请参见这里。以下是向聊天模型发送系统消息和用户消息的示例 messages [SystemMessage(contentYou are a helpful assistant that translates English to French.),HumanMessage(contentI love programming.) ] chat(messages)输出 AIMessage(contentJaime programmer., additional_kwargs{})您还可以进一步生成多组消息的完成结果使用generate方法实现。该方法将返回一个带有额外message参数的LLMResult。 batch_messages [[SystemMessage(contentYou are a helpful assistant that translates English to French.),HumanMessage(contentI love programming.)],[SystemMessage(contentYou are a helpful assistant that translates English to French.),HumanMessage(contentI love artificial intelligence.)], ] result chat.generate(batch_messages) result输出 LLMResult(generations[[ChatGeneration(textJaime programmer., generation_infoNone, messageAIMessage(contentJaime programmer., additional_kwargs{}))], [ChatGeneration(textJaime lintelligence artificielle., generation_infoNone, messageAIMessage(contentJaime lintelligence artificielle., additional_kwargs{}))]], llm_output{token_usage: {prompt_tokens: 57, completion_tokens: 20, total_tokens: 77}})我们可以从LLMResult中获取诸如标记使用情况之类的信息 result.llm_output输出 {token_usage: {prompt_tokens: 57,completion_tokens: 20,total_tokens: 77}}PromptTemplates 我们可以使用模板来构建MessagePromptTemplate。我们可以从一个或多个MessagePromptTemplate构建一个ChatPromptTemplate。我们还可以使用ChatPromptTemplate的format_prompt方法它将返回一个PromptValue我们可以将其转换为字符串或消息对象具体取决于我们是否希望将格式化后的值作为输入传递给LLM或Chat模型的输入。为了方便起见模板上公开了一个from_template方法。如果您要使用此模板代码如下所示 templateYou are a helpful assistant that translates {input_language} to {output_language}. system_message_prompt SystemMessagePromptTemplate.from_template(template) human_template{text} human_message_prompt HumanMessagePromptTemplate.from_template(human_template) chat_prompt ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt])# 获取格式化后的消息的聊天完成结果 chat(chat_prompt.format_prompt(input_languageEnglish, output_languageFrench, textI love programming.).to_messages())输出 AIMessage(contentJadore la programmation., additional_kwargs{})如果我们想直接更直接地构建MessagePromptTemplate我们可以在外部创建一个PromptTemplate然后将其传递进去例如 promptPromptTemplate(templateYou are a helpful assistant that translates {input_language} to {output_language}.,input_variables[input_language, output_language], ) system_message_prompt SystemMessagePromptTemplate(promptprompt)LLMChain 我们可以以与以前非常相似的方式使用现有的LLMChain即提供一个提示和一个模型 chain LLMChain(llmchat, promptchat_prompt) chain.run(input_languageEnglish, output_languageFrench, textI love programming.)输出 Jadore la programmation.Streaming 通过回调处理ChatOpenAI支持流式处理。 from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler chat ChatOpenAI(streamingTrue, callbacks[StreamingStdOutCallbackHandler()], temperature0) resp chat([HumanMessage(contentWrite me a song about sparkling water.)])输出 Verse 1: Bubbles rising to the top A refreshing drink that never stops Clear and crisp, its pure delight A taste thats sure to exciteChorus: Sparkling water, oh so fine A drink thats always on my mind With every sip, I feel alive Sparkling water, youre my vibeVerse 2: No sugar, no calories, just pure bliss A drink thats hard to resist Its the perfect way to quench my thirst A drink that always comes firstChorus: Sparkling water, oh so fine A drink thats always on my mind With every sip, I feel alive Sparkling water, youre my vibeBridge: From the mountains to the sea Sparkling water, youre the key To a healthy life, a happy soul A drink that makes me feel wholeChorus: Sparkling water, oh so fine A drink thats always on my mind With every sip, I feel alive Sparkling water, youre my vibeOutro: Sparkling water, youre the one A drink thats always so much fun Ill never let you go, my friend Sparkling参考文献 [1] LangChain ️ 中文网跟着LangChain一起学LLM/GPT开发https://www.langchain.com.cn/ [2] LangChain中文网 - LangChain 是一个用于开发由语言模型驱动的应用程序的框架http://www.cnlangchain.com/
http://www.w-s-a.com/news/510275/

相关文章:

  • 怎么用手机做一个网站门户网站建设工作的自查报告
  • 网站搭建怎么收费浙江建设集团网站
  • 建网站怎么赚钱免费引流软件下载
  • 自建网站服务器备案做基础销量的网站
  • 淘宝 网站建设 发货音乐网站首页设计
  • 丽水做网站杭州建电商网站多少钱
  • 建设网站能解决什么问题wordpress 模板 中文
  • 平台型网站建设预算表友情链接中有个网站域名过期了会影响
  • 漯河网站开发运营seo是什么意思
  • 网站建设的征求意见稿iis 网站 红
  • 网站搭建教室企业网站开发实训心得
  • 阿克苏建设网站佛山app定制
  • 做淘宝网站要求与想法大型网站建设推荐
  • 在百度做网站赚钱吗跨境电商网站开发
  • 酒店网站建设策划方案南昌网站建设南昌
  • 临沂罗庄做网站房产cms
  • 五合一网站做优化好用吗网站设计的专业流程
  • 毕业设计论文网站开发需要多少网站seo建设方案
  • h5页面用什么做杭州优化外包哪里好
  • 许昌网站建设百姓国货app下载
  • 什么是建站装修公司做宣传在哪个网站
  • 阿里云虚拟主机多个网站吗大庆油田建设集团网站
  • 坂田公司做网站公司有网站域名后如何建网站
  • 自媒体网站程序淘宝网站维护
  • 凡科网站建设网站wordpress 七牛oss
  • 搬瓦工的主机可以用来做网站吗分类信息网站开发需求方案
  • 上海高端网站开发站霸网络国际网站建设的目的
  • 程序员招聘求职的网站做网站加入广告联盟
  • 网站建设的技术方案模板易做文学网站的logo
  • 建设国家标准官方网站响应式网站切图