langchain 初体验
创始人
2025-05-31 04:05:50
0

langchain 初体验

最近的AI发展令人又兴奋又焦虑啊啊啊啊啊啊啊啊啊 🎀🎢👓🎒🏈

  • 早上看medium发来的邮件看到这样一篇文章,感觉很有意思

    Create your Document ChatBot with GPT-3 and Langchain

    medium的免费额度比较头疼,可以尝试把文章名字放到Google里面搜一下,然后看别的

  • 在这篇文章了解到了langchain

    • 然后去了它的官方文档,看到它可以比较容易地实现对话历史记忆

      Adding Memory To an LLMChain

    • 还在huggingface上面看到一个有趣的项目

      GPT + WolframAlpha + Whisper

  • 我用下面那个huggingface上面的项目试了试两个例子

    • (3x/sin2x) 在 x趋近于0的时候,极限是多少,用latex格式写出计算过程

      下面这个回答过程很严谨,但是答案错了哈哈哈,是3/2呀

      As xxx approaches 0, the limit of 3xsin⁡2x\frac{3x}{\sin2x}sin2x3x​ is 3. To calculate this, we start by rewriting the expression as 3x2sin⁡xcos⁡x\frac{3x}{2\sin x \cos x}2sinxcosx3x​. Then, as xxx approaches 0, the sine and cosine terms both approach 0, leaving us with 32cos⁡x\frac{3}{2\cos x}2cosx3​. Finally, as xxx approaches 0, the cosine term approaches 1, leaving us with the limit of 3.

    • (3x/e^x) 在 x趋近于0的时候,极限是多少,用latex格式写出计算过程

      As xxx approaches 0, the limit of 3xex\frac{3x}{e^x}ex3x​ is 0. To calculate this, we must first take the limit of the fraction as xxx approaches 0. This can be done by dividing both the numerator and denominator by xxx. As xxx approaches 0, the numerator will approach 0, while the denominator will approach e0e^0e0, which is equal to 1. Therefore, the limit of 3xex\frac{3x}{e^x}ex3x​ as xxx approaches 0 is 0.

      To calculate this limit, we must first consider the fraction 3xex\frac{3x}{e^x}ex3x​. As xxx approaches 0, the numerator will approach 0, while the denominator will approach e0e^0e0, which is equal to 1. By dividing both the numerator and denominator by xxx, we can simplify the fraction to 3ex\frac{3}{e^x}ex3​. As xxx approaches 0, the denominator will approach 1, and the limit of the fraction will be equal to the numerator, which is 3. Therefore, the limit of 3xex\frac{3x}{e^x}ex3x​ as xxx approaches 0 is 0.

  • 之后试着实践下langchain的代码~

  • 此外CSDN 也有两篇介绍

    大语言模型集成工具 LangChain_kebijuelun的博客-CSDN博客

    使用langchain打造自己的大型语言模型(LLMs)_-派神-的博客-CSDN博客


  • what is langchain ? 以下是 phind.com 的回答

    What is langchain

    ANSWER

    LangChain is a tool that provides many modules to build language model applications [0]. It is a library that can be used to create advanced use cases around large language models (LLMs) by chaining together different components [4]. Here are some of the things that LangChain can help with [3]:

    • Prompt management: LangChain provides a set of utilities for managing prompts, which are inputs that are passed to LLMs to generate outputs.
    • Chains: LangChain provides a standard interface for chains, which are sequences of calls to LLMs or other utilities. This allows for more complex applications to be built.
    • Data Augmented Generation: This involves chains that interact with external data sources to fetch data to use in the generation step. Examples of this include summarization of long pieces of text and question/answering over specific data sources.
    • Agents: These are LLMs that make decisions about which actions to take, take that action, observe the output, and then repeat the process until done. LangChain provides a standard interface for agents, a selection of agents to choose from, and examples of end-to-end agents.
    • Memory: LangChain provides a standard interface for memory, which allows for state to be persisted between calls of a chain or agent.
    • Generative models: LangChain provides prompts/chains for assisting in the evaluation of generative models.

    LangChain can be used to build a variety of language model applications. For example, suppose we want to build a service that generates a company name based on what the company makes. Here’s how we can use LangChain to do this [0]:

    • We first import the LLM wrapper and initialize it with any arguments. In this example, we probably want the outputs to be more random, so we initialize it with a high temperature.
    • We then construct a prompt using the PromptTemplate utility. We take only the user input describing what the company does, and then format the prompt with that information.
    • We create an LLMChain which takes user input, formats it with the prompt, and then passes the formatted response to the LLM.

    LangChain also allows for more complex applications to be built. For example, we can use LangChain to build an agent that uses an LLM to determine which actions to take and in what order [0]. Here’s how we can do this:

    • We first load the language model we’re going to use to control the agent and some tools to use.
    • We then initialize an agent with the tools, the language model, and the type of agent we want to use. In this example, we use the zero-shot-react-description agent.
    • We can then test out the agent by running it with some input.

    LangChain also provides a standard interface for memory, which allows for state to be persisted between calls of a chain or agent [3]. For example, we can use the ConversationChain utility to create a chain that has some concept of “memory”. By default, the ConversationChain has a simple type of memory that remembers all previous inputs/outputs and adds them to the context that is passed. We can use this to build a chatbot that remembers previous messages and uses context from that to have a better conversation [0].

相关内容

热门资讯

王凤英入职小鹏3年终获股权,此... 5月7日消息,小鹏汽车披露的监管及年报信息显示,公司总裁王凤英已正式进入股东名册,入职小鹏3年后股权...
五块钱红酒卖断货,便宜红酒为何... 最近一段时间,中国的酒类消费市场可以说是显得格外奇怪,一方面,各种高端酒特别是白酒的消费量出现了明显...
财联社C50风向指数调查:4月... 财联社5月8日讯(记者 夏淑媛)新一期财联社“C50风向指数”结果显示,市场机构对4月新增人民币贷款...
央视硬刚国际足联拒掏20亿,背... 作者| 史大郎&猫哥 来源| 是史大郎&大猫财经Pro 央视这次太刚了,离世界杯开幕还有1个月,死活...
新CEO上任直接放大招!Air... 快科技5月8日消息,苹果即将上任的CEO John Ternus对未来一系列新产品充满信心,称这些设...
“特朗普拟邀英伟达、波音等CE... 据路透社当地时间5月7日报道,特朗普政府正邀请英伟达、苹果、埃克森美孚、波音等大公司首席执行官,于下...
世界杯,还能看到直播吗? 2026年美加墨世界杯距离开幕,仅剩一个多月时间。多方信息显示,中央广播电视总台(以下简称“央视”)...
机构警告AI芯片热潮风险,超威... 5月7日,据央视财经,隔夜超威半导体公司(AMD)股价飙升近19%,带动AI芯片热潮持续升温。AMD...
银行员工转走储户1800万最新... 银行员工转走储户1800万最新进展:2名储户已收到银行全部款项
原创 中... 1994年,安徽省的经济格局曾发生过一次戏剧性的转折。在那一年,一座名为安庆的城市,其国内生产总值(...
昆都仑区:政策“蓄力”消费焕新 “一台5000多元的空调,叠加‘国补’和商场的以旧换新活动,能优惠1000元左右,旧机还能免费上门拆...
乐悦置业竞得佛山顺德乐从镇一商... 观点网讯:5月6日,佛山市顺德区乐从镇一商业地块成功出让,由广东省乐悦置业有限公司竞得,乐从南区·邻...
原创 亦... 《爱情没有神话》这部剧,一开始的命运颇为多舛,经历了几次撤档的波折后,终于在观众面前亮相,但其首播的...
美联储34年最大分歧叠加油价飙... 美联储按预期维持利率不变,但内部出现34年来最严重分歧,叠加布油创2022年6月以来新高,美债遭抛售...
支付宝消费券回收后,资金是否支... 摘要: 支付宝消费券回收变现后,资金能否直接转入信用卡?本文解答到账方式的相关规则,帮助用户了解资金...
中医介绍5个化痰穴位!收藏这篇... 很多人忽略了“痰”的危害,觉得咳几下就没事,殊不知,肺里的痰长期堆积,只会一步步加重身体负担。 中医...
黄金平台“杰我睿”涉嫌经济犯罪... 红星资本局5月7日消息,深圳水贝知名金店“杰我睿”兑付困难事件有了新进展。日前,深圳市公安局罗湖分局...
多地出台购房新政促楼市升温 记... 今年的“五一”假期,伴随着多个城市楼市新政密集落地,在叠加市场信心持续修复的作用下,房地产市场热度持...
谁是五一“吸金王”?这5座城市... 来源:市场资讯 (来源:21城市观) 哪座城市成为“五一”假期的大赢家? 图源:摄图网 作者|赵晓...
“低招低裁”格局稳固劳动力市场... 智通财经APP获悉,美国上周初请失业金人数在经历前一周回落至近几十年来最低水平后出现小幅反弹,表明尽...