GitHub - langchain-ai/langchain: 🦜🔗 Build context-aware reasoning applicationsLangChain开源地址
1 LangChain是什么
1.1 官方介绍
LangChain is a framework for developing applications powered by language models. It enables applications that:
- Are context-aware: connect a language model to sources of context (prompt instructions, few shot examples, content to ground its response in, etc.)
- Reason: rely on a language model to reason (about how to answer based on provided context, what actions to take, etc.)
This framework consists of several parts.
- LangChain Libraries: The Python and JavaScript libraries. Contains interfaces and integrations for a myriad of components, a basic run time for combining these components into chains and agents, and off-the-shelf implementations of chains and agents.
- LangChain Templates: A collection of easily deployable reference architectures for a wide variety of tasks.
- LangServe: A library for deploying LangChain chains as a REST API.
- LangSmith: A developer platform that lets you debug, test, evaluate, and monitor chains built on any LLM framework and seamlessly integrates with LangChain.
- LangGraph: LangGraph is a library for building stateful, multi-actor applications with LLMs, built on top of (and intended to be used with) LangChain. It extends the LangChain Expression Language with the ability to coordinate multiple chains (or actors) across multiple steps of computation in a cyclic manner.
The LangChain libraries themselves are made up of several different packages.
- langchain-core: Base abstractions and LangChain Expression Language.
- langchain-community: Third party integrations.
- langchain: Chains, agents, and retrieval strategies that make up an application's cognitive architecture.
1.2 个人理解
LangChain Libraries是一个整合了各种Prompt的工具包。使用这个工具包,开发者能更专注于业务逻辑和业务实现。
除此之外,LangChain Templates、LangServer、LangSmith、LangGraph算是LangChain锦上添花之作,有替代方案,也不是这个系列文章的重点,所以后续不会做分析与演示。
2 我们可以用LangChain构建什么?
2.1 Q&A with RAG
RAG,全称为Retrieval-Augmented Generation,中文翻译为检索增强生成。它是一种为大模型提供外部知识源的策略,使得大模型在回答问题之前,可以先利用一个知识库来获取候选的知识,再由大模型来生成答案。这种方式可以有效地减少模型幻觉问题,即大模型胡说八道的情况,同时也能避免由于数据不及时或未更新而导致的答案不准确的问题。RAG技术在企业不同的领域中有非常宽广的应用领域,可以解决由于数据不及时或未更新而导致的答案不准确的问题。
使用LangChain可以让大模型基于本地知识库进行问答,适用场景:智能客服
2.2 Analyzing structured data
分析结构化数据(这了各位同学应该先了解什么是结构化数据!!!)适用场景:数据分析、数据洞察等等
2.3 Chatbots
聊天机器人的特点是它们可以长时间运行,有状态对话,并可以使用相关信息回答用户问题。
2.4 更多的使用场景
从外部数据中结构化提取信息、对文档做总结、代码理解、工具使用、读取网页信息、访问SQL数据库等等