LLM application development based on LangChain 1 - Introduction

This is the first article in a series of large language model application development based on LangChain.

The content of the article will refer to the short course of deeplearning.ai (https://learn.deeplearning.ai/langchain/), plus Other information and personal understanding.

Who is Harrison Chase

Harrison Chase is the founder and CEO of LangChain.

Prior to founding LangChain, Harrison Chase led the ML team at Robust Intelligence, an MLOps company focused on testing and validating machine learning models, and the entity linking team at Kensho, a fintech startup. He studied statistics and computer science at Harvard University.

What is LangChain

LangChain was launched as an open source project in October 2022 by Harrison Chase, who was working at machine learning startup Robust Intelligence. The project quickly exploded in popularity, with discussions on Twitter booming, the project's Discord server active, tutorials popping up on YouTube, and meetups held in San Francisco and London.

By using prompts for large language models, the difficulty of developing AI applications has been greatly reduced, and the development speed is also faster. But an AI application may need to write prompts to a large language model multiple times and parse the output of the large language model. Here are tips to optimize Prompt so that the large language model can output results that are beneficial to program parsing: for example, if a result in json format cannot be output, "Invalid Request" will be returned directly without generating additional output. But this approach still requires developers to write a lot of glue code to integrate large language models. LangChain created by Harrison Chase greatly simplifies the development process of large language model applications.

LangChain is an open source development framework for building LLM applications. It currently has Python and JavaScript (TypeScript) versions of the library (no java! I always feel that java has become a coward in the AI ​​​​era, and the earliest support is always Python), focusing on combination and modularity.

A valuable aspect of LangChain is that there are many independent components that can be used alone or in combination with other components. Another valuable aspect is that there are many different use cases, and these components can be chained (Chain) into more complete and complex applications. program and is very easy to use.

The URL of LangChain (Python version) on GitHub is:https://github.com/langchain-ai/langchain, which is currently available There are more than 60,000 (64.9k) Stars, the source code is very active, there are 1,700 contributors, and the Baichuan model was just added today (Add baichuan model) .

Insert image description here

Specific components in LangChain

Insert image description here

  • Models

Abstraction of major language models, connecting major language models (yes, you can easily switch between major language models), including the LangChain interface and calling details of major language models, as well as the output parsing mechanism.

  • Prompts

Streamline hint engineering to further unlock the potential of large language models. Implemented through Prompt Templates.

  • Data retrieval (Indexes)

Methods to build and operate documents, accept user queries and return the most relevant documents (retrieve recall data), combine data with models, and easily build a local knowledge base.

  • Memory

Let Chatbot remember who you are by storing and retrieving data during conversations through short-term and long-term memory.

  • Chains

It is the core mechanism in LangChain, which encapsulates various functions in a specific way and completes common use cases automatically and flexibly through a series of combinations. Similar to pipes in Unix systems? The output of the previous stage can be used as the input of the next stage.

  • Agents

It is another core mechanism in LangChain. It uses a large language model as an inference engine, allowing the large model to autonomously call external tools and internal tools, making a powerful "intelligent" autonomous Agent possible.

Reference content:

  1. https://learn.deeplearning.ai/langchain/lesson/1/introduction
  2. Document address of Python version LangChain:https://python.langchain.com/docs/get_started/introduction

Guess you like

Origin blog.csdn.net/fireshort/article/details/133883899